Commit Graph

1507 Commits

Author SHA1 Message Date
Vladimir Koshelev
68f82c0a1c [pycharm] get rid of PyBoundFunction
GitOrigin-RevId: f851c339dcf9f3e8e6ff9e3554451279bdcefea4
2024-07-17 14:21:09 +00:00
Daniil Kalinin
e9a6246df3 PY-72185 Implement incremental parsing for PSI leaves for Python
Merge-request: IJ-MR-138193
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: 7d004677a5b7a4637ea956f13ed85abc0d88604e
2024-07-17 12:15:36 +00:00
Vladimir Koshelev
1aaaf77781 [pycharm] restrict analysis in order to improve completion performance
GitOrigin-RevId: 1c2427d1dbb07d88672347311ec5d6f362881847
2024-07-16 14:55:52 +00:00
Vladimir Koshelev
82e8947e95 [pycharm] move type guards from control flow to PyDefUse stage
GitOrigin-RevId: e66971e619978ad179bb49a15820a7482b27df7c
2024-07-15 18:43:02 +00:00
Vladimir Koshelev
d649ae4e61 [pycharm] add un-reachability support to PyUnboundLocalVariableInspection
GitOrigin-RevId: ea1125977ea8b4de370973d606cc5ba7b258dd82
2024-07-10 14:22:00 +00:00
Vladimir Koshelev
2625d2472b [pycharm] remove NoReturn logic from control flow builder
GitOrigin-RevId: 85ba28fd8b86fe0b6337703798a0b869bb793e88
2024-07-10 14:22:00 +00:00
Vladimir Koshelev
8a4dfe563c [pycharm] add type eval context to PyDefUseUtil
GitOrigin-RevId: a6973f48d9e1f5c473209df25ff507be482e8904
2024-07-10 14:21:59 +00:00
Aleksandr Sorotskii
097939cc6b PY-11963: add package mappings for 5k most downloaded packages pypi
GitOrigin-RevId: 95cf83695ad0031ffb009cd5cca8b68a0b49d6d3
2024-07-10 11:34:52 +00:00
Aleksandr Sorotskii
8a4013db94 trim whitespaces
GitOrigin-RevId: 97014ede7f4df5b9ec07e9d6b64abe6878581df4
2024-07-10 11:34:52 +00:00
Aleksandr Sorotskii
292c6e0837 PY-11963 Sort lines
(cherry picked from commit 8c998e6ace23604f29382d4547bdeebb0583e954)

IJ-MR-139247

GitOrigin-RevId: c0d0f76a36073d25506e0446bbb406ea97f73d8f
2024-07-08 19:39:36 +00:00
Aleksandr Sorotskii
aa7a9353cf PY-11963 Add some packages
(cherry picked from commit 7d465f3823c0f9f0a31b49a0b675cbfda4a2f79b)

IJ-MR-139247

GitOrigin-RevId: 27c8ac0e17a2e04d2fd919b777ad98614dbb3bd9
2024-07-08 19:39:35 +00:00
Petr
a6fc2c09c6 PY-53693 PyCharm adds _: KW_ONLY to dataclass' init signature
GitOrigin-RevId: 471e10b4e12a36a640da2f3006719372797b5cf1
2024-07-08 17:53:13 +00:00
Tagir Valeev
6bb83bc8e5 [stubs] Reduce amount of raw types
GitOrigin-RevId: 169895a6ee3c98db193443dbb0ced98497221430
2024-07-04 21:05:23 +00:00
Tagir Valeev
15fb25d32e [python] Fix redundant formatted call
GitOrigin-RevId: b972c2605e3aee85b91bd9f7bd88ade24c417b43
2024-07-03 12:47:15 +00:00
Mikhail Golubev
eb63148798 PY-73246 Don't insert square brackets after classes not having free type parameters
Even if they transitively extend typing.Generic, such as the builtin str.

GitOrigin-RevId: 9389ef5846e21ba5e0fed8b835beb2d458e42f13
2024-07-02 14:08:48 +00:00
Mikhail Golubev
ebba681c85 PY-62208 Don't suggest names shorter than five characters unless it's an extended completion
Otherwise, we end up with dozens of unintentionally public names such as "s", "i", "k"
even in the standard library (e.g. `this.s` or `pickletools.i`).

Ideally, we should rely on .pyi stubs and the content of `__all__` to offer only explicitly
exposed API, but not every module has any of those two, and it's not clear how to match
.py files and the corresponding .pyi stubs fast enough for completion.

GitOrigin-RevId: 163c472654e60ae63ff893142b8ddb9accc56393
2024-07-02 14:08:48 +00:00
Mikhail Golubev
1a3e6c2a64 PY-73246 Automatically insert square brackets on completion of parameterized types
GitOrigin-RevId: 5e81bc984fa3c7b4f83c564c85d872c5a49cf391
2024-07-02 14:08:48 +00:00
Mikhail Golubev
52850e21d8 PY-62208 Include importable names in basic completion results
Previously, such names were visible only on so-called "extended" completion,
activated when the hotkey for the basic completion was hit twice. The main reason
was that collecting such variants from indexes was a slow process, and we
didn't want to harm the responsiveness of completion for basic names.
Now it becomes possible thanks to a number of performance optimizations:

* Instead of using three separate indexes for classes, functions and variables,
we use one -- PyExportedModuleAttributeIndex. By definition, it includes only top-level
"importable" names, so we additionally save time by not filtering out irrelevant
entries. Also, it doesn't contain private definitions starting with an underscore.
It might bother some users, but given that the previous completion was used
extremely rarely, and the new one is going to be visible everywhere, it seems
that pruning unlikely entries as much as possible is a fare tradeoff. In the future,
we might enable them back on the "extended" completion if there is a demand.
Also, this index binds its keys to the project (`traceKeyHashToVirtualFileMapping`),
further eliminating useless index lookups.

* Thanks to the recent fixes in the platform (IJPL-265), it's now possible to
simultaneously iterate over all keys in an index and request values for a given key
without deadlocks, which is much faster than eagerly fetching all keys first.

* While scanning through all matching entries from indexes, we terminate
the lookup if the number of items exceeds the size of the lookup list.
We can further reduce this number by adjusting the "ide.completion.variant.limit"
registry value.

* Calculating expensive "canonical" import paths (e.g. "pkg.private.Name" is importable as
"pkg.Name") is offloaded to a background thread thanks to the `withExpensiveRenderer` API.
We still calculate these paths synchronously, though, for names whose raw qualified names
contain components starting with an underscore to decide whether these private names are
publicly re-exported and, hence, should be displayed.

The rest of the work has been put into reducing the number of entries on the list, e.g.

* The prefix under caret is now matched from the beginning of a name, e.g. `Bar<caret>`
matches `BarBaz`, but not `FooBar`.
* We don't suggest imported names clashing with those already available in scope.
* Some kinds of definitions are not suggested in specific contexts, e.g.
functions and variables are not suggested inside patterns and type hints.
* Nothing is suggested at the top-level of a class body, where dangling
reference expressions or calls are not normally expected.

Additionally, we don't suggest names from .pyi stubs at the moment, because
it pollutes the suggestion list with entries coming from the stubs for
third-party packages in Typeshed. We should probably enable them back once
we are able to properly disable Typeshed entries for not installed packages.

Some legacy forms of completion are left in the extended mode. In particular,
qualified names of classes are offered inside string literals only in this mode.
Also, module and package names are suggested only in the extended mode, because
top-level packages and modules are already suggested for the basic completion
by PyModuleNameCompletionContributor.

A few tests in PyClassNameCompletionTest were updated or removed entirely because
* we no longer suggest private names
* we no longer suggest names from private modules not re-exported in a public module
* we no longer suggest names clashing with those already available in scope
* prefix matching policy was changed to start at the beginning of an identifier

The whole feature can be disabled with the option "Suggest importable classes,
functions and variables in basic completion" in settings.

GitOrigin-RevId: 0787d42ce337b73b01a60f0bb7aa434fee43e659
2024-07-02 14:08:48 +00:00
Petr
5054f4a9b5 [python] Do not store unused decorator arguments in stubs
GitOrigin-RevId: d1a5f63dbed11a4f373d1d7936700af3bc74f70f
2024-07-02 14:04:36 +00:00
Egor.Eliseev
58d8eddeb8 PY-73525 Split HelpersLocator into Community/Pro versions
Merge-request: IJ-MR-138058
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

GitOrigin-RevId: cd82bc44337e7fdd182262c44ea5ca29e1804ad2
2024-07-02 11:43:46 +00:00
Daniil Kalinin
3186ddfc5b PY-58497 Cleanup, fix failing tests for Java parameter infos.
GitOrigin-RevId: d9950dfea02d95e6673f20eb940b65dbf85e7861
2024-07-02 09:57:32 +00:00
Daniil Kalinin
35aa2b43b4 PY-58497 Add a custom bottom component for Python Parameter Info window.
Make it possible to expand/collapse overloads by clicking the action link in the bottom component or calling Parameter Info window on the same place for the second time.

GitOrigin-RevId: a65de4124b4530dd9cc5f16b0a709e3a6489071c
2024-07-02 09:57:32 +00:00
Daniil Kalinin
d47bd34358 PY-58497 Refactor parameter info logic for Python
Show type hints only for the highlighted parameter

GitOrigin-RevId: f55d8ecc27dcbca5e6c24c5ca347ea3995e69ca8
2024-07-02 09:57:32 +00:00
Mikhail Golubev
ded1e5d860 [python] Implement acceptPyVisitor in PyStatementListImpl and PyAstStatementList
In PyStatementListImpl, it was seemingly accidentally removed as part of
892acbe0c95fde6aec74b7595b0a58f902c426f5.

GitOrigin-RevId: 17b8db2ee2c779cb32cee346f59fb3cc56911288
2024-07-01 16:43:01 +00:00
Egor.Eliseev
2317f2b12d PY-73492 Fix errors with "helpers-pro" dir path
Change the "helpers-pro" path from `python-ce/helpers-pro` to `python/helpers-pro`


Merge-request: IJ-MR-137799
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

GitOrigin-RevId: 097aebb0e82024bcee84d7527a39813285e94414
2024-06-26 15:21:35 +00:00
Nikita.Ashihmin
2f85fa81e2 PY-73366 Jupyter: Remove ability to set own language
GitOrigin-RevId: 27cbc3d76b21f139859c33179cb637e91ba8101b
2024-06-22 21:47:44 +00:00
Nikita.Ashihmin
4d5bff8b61 PY-73366 Jupyter: Add ability to use own language of psi elements
GitOrigin-RevId: 57a4df0c69209f58f99762f293b47ce2d535bf3f
2024-06-22 09:20:24 +00:00
Andrey Vokin
3f81ae2ba0 PY-61413 Freeze due to non-cancelable RA in PythonLanguageLevelPusher
Do not iterate over all files in a directory. Because PythonSdkPathCache defined by SDK and SDK can be found by a directory

GitOrigin-RevId: 9575e24b9c38a3203f387e8aaea32ab28507be4c
2024-06-21 20:18:37 +00:00
Egor.Eliseev
0c73c9eff9 PY-72274 separating content for python core/pro plugins
1. Delete `intellij.python.community.impl.xml` (move content to `PythonCore` plugin). It is necessary to fix incorrect dependencies: `PythonCore`, `Pythonid` include the same module.
2. Fixed dependencies: if some plugin/module needs Python core functionality, then it should depend on `PythonCore`.


Co-authored-by: Vladimir Koshelev <Vladimir.Koshelev@jetbrains.com>

Merge-request: IJ-MR-136158
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

GitOrigin-RevId: ce9ed4c17f601ee1ca2b6cf608f4e30fdac1d879
2024-06-19 21:39:24 +00:00
Andrey.Matveev
2854de57c0 PY-62301 Not highlight Self in __new__ method
GitOrigin-RevId: 099d4ca6f34b30e757ad030f418c9db827a71abe
2024-06-19 15:03:24 +00:00
Tagir Valeev
440654c48f Pattern variable can be used fixes; other warning fixes
GitOrigin-RevId: 49f37e7f5d748be50ee66fdf66a5c9b98b1b7432
2024-06-18 19:55:23 +00:00
Andrey Vokin
170506beaa PY-73102 Presence of @warnings.deprecated or @typing_extensions.deprecated decorator suppressed errors about incorrect call arguments
GitOrigin-RevId: d1a5a4ce224fe92af9f0df376b63b8cb38ca3990
2024-06-17 22:26:51 +00:00
Andrey Vokin
f2a322c6d9 PY-73107 Usages of @warnings.deprecated inside .pyi stubs are ignored
GitOrigin-RevId: 7682eff8c8ca8ae8241ddee3191add34ab2ac22e
2024-06-17 22:26:51 +00:00
Petr
ee91d6a211 PY-72661 Literal completion inside nested parenthesis
GitOrigin-RevId: 14f18efcbaa520ac36ddd4892b774ed60a01cfdc
2024-06-17 20:36:23 +00:00
Mikhail Mazurkevich
5224cc5e77 [workspace model] Hide entity field EntityChange.Removed and EntityChange.Added
GitOrigin-RevId: 8cf5fda04c6b86c370b40b199f5e0e7faf879a02
2024-06-17 15:09:37 +00:00
Daniil Kalinin
a43fd578d5 PY-54345 Revert changes in PyOperatorReference, return the first metaclass of type which PyCustomType mimics in PyCustomType#getMetaClassType
GitOrigin-RevId: ca58de8f4c98a9e77af45884e55dbe167316aff2
2024-06-13 16:59:19 +00:00
Mikhail Golubev
aff932b7c9 [python] Add methods visitPyKeyValueExpression to PyElementVisitor and PyAstElementVisitor
GitOrigin-RevId: 247a02160e18c93a00b1630e2ed70cea6dcefbbf
2024-06-13 11:59:38 +00:00
Andrey Vokin
673383c3da PY-61651 Deprecation highlighting with PEP 702 @deprecated decorator
GitOrigin-RevId: 426e7001d20849d7029fea55431d3e2cfae3eb11
2024-06-10 15:58:53 +00:00
Petr
3f43255122 PY-73076 Ctrl+Z doesn't work in RemDev
GitOrigin-RevId: e80b54e1a43e9f83be921096a1bc3a0059795cb7
2024-06-05 17:51:13 +00:00
Daniil Kalinin
1cfcce3b7a PY-54356 fix "Callable | None" raises the warning "Cannot find reference '|' in 'Callable'"
Previously, there was no chance to resolve `__or__` member for class references like `Callable`, `Generic` as its type is PyCustomType that always returns `null` from getMetaClassType(). Now in operator references we at least resolve such references in types which PyCustomTypes mimic to

GitOrigin-RevId: ff05ae62e4c1a17026310a3407f40597154bc946
2024-06-03 17:32:16 +00:00
Petr
35ab642bdb [python] Lift typed dict keys higher in completion lookup
GitOrigin-RevId: 82be304d1187fb464eb45ff467e99cf8c41064c1
2024-05-29 19:22:44 +00:00
Mikhail Golubev
d99a86efeb PY-35190 Fix resolving the register method of ABCMeta
The root cause was introduced in PY-23540 (see cb598c94c5).
Namely, abs.ABCMeta was explicitly filtered out from the list of metaclasses in
`PyClassImpl.getMostDerivedClassType` because for some reason in Typeshed stubs for
Python 2 `basestring`, and hence `str`, uses `ABCMeta` as its metaclass,
which is not true at runtime. It caused a metaclass conflict when inheriting `str`
with another user-defined metaclass (`ABCMeta` and a user metaclass didn't extend
each other), so we didn't detect any metaclass in a class as a result.

I've updated Typeshed stubs for Python 2 manually to process ABCMeta normally.
We don't update these stubs anyway, so these changes won't be lost on a future
Typeshed sync.

GitOrigin-RevId: 680e9fa890d00ea63987f3cf73e636e430685f34
2024-05-28 08:41:05 +00:00
Mikhail Golubev
8322bb476d PY-55086 Do not report raising a BaseException instance directly
See https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement.
I decided not to update the inspection description, because BaseException is not
intended to be inherited by user classes.
The check for Exception was removed because Exception itself extends BaseException.

GitOrigin-RevId: 5782c9351aebb524c4d0fc0c9f3307d8db682efb
2024-05-28 01:10:12 +00:00
Mikhail Golubev
46d7223d9f PY-70528 Refactor handling of the *Ts and Unpack[Ts] syntax in type hints
to have better code re-use between PEP 692 and PEP 646 implementations.

GitOrigin-RevId: 39d714fcb14ba1014099fd57325c5185df34ce45
2024-05-28 01:10:09 +00:00
Mikhail Golubev
93ac5fe566 PY-70528 Add support for typing_extensions.TypeVarTuple and Unpack
I've add-hoc updated typing_extensions.pyi in the bundled Typeshed to
recognize Unpack there.

GitOrigin-RevId: 953402e42984712a630c1772cf2f2cd4cbacdccf
2024-05-28 01:10:05 +00:00
Petr
c8509ccc80 [python] Support TypeVarTuple from typing_extensions
GitOrigin-RevId: 02ed108a55d3feed54d95bfb5552f31cdf3e4880
2024-05-24 22:15:34 +00:00
lada.gagina
625373b47a [python] requirements.txt: check entries regardless of dash/underscore in the package name (PY-65403, PY-70173)
Since pip [normalizes](https://github.com/pypa/packaging-problems/issues/230) underscores to dashes, PyCharm should treat them equally for requirements.txt entries

GitOrigin-RevId: 62149b9c64c67936f1405c7bf282a288e8d52764
2024-05-20 15:56:16 +00:00
Nikita.Ashihmin
c35feaee3e PY-72719 Jupyter(fix): no quickfix to install package
GitOrigin-RevId: b29330a381f7c103688a5a5874a182e4a72caaf9
2024-05-17 22:28:00 +00:00
Petr
01d14fab4e PY-40480 Lift literal type completion results higher in a lookup
GitOrigin-RevId: 51fcf9b611250104fdeff04284e908cce1164560
2024-05-16 20:36:19 +00:00
Vladimir Krivosheev
c783d08867 IJPL-149476 fix IAE due to PyFilterLexer protected ctor
GitOrigin-RevId: b65f7f5fc399476f04e036df94190b30bdf4f783
2024-05-15 21:10:39 +00:00