Commit Graph

1529 Commits

Author SHA1 Message Date
Vladimir Koshelev
660bdd70bb [pycharm] PY-73958 PyDefUseUtil: restrict resolve for large control flow graph to avoid recursion
GitOrigin-RevId: 777dd787f0b992be0775e8844026345b4722cdf0
2024-07-30 18:23:12 +00:00
lada.gagina
1605af64c4 [python] packaging: add an update button to the context menu (PY-72994)
GitOrigin-RevId: fbd6258369c199d3325166d9431467531c2b88ab
2024-07-30 09:29:01 +00:00
Petr
7f22ee443e [python] Fix nullability annotations (PyAstNumericLiteralExpression)
GitOrigin-RevId: d5db0add83ac134aab91198b1a931c026829d216
2024-07-28 15:43:22 +00:00
Petr
93b9066edf PY-34617 Support version check
GitOrigin-RevId: 3318ff79cdcc5ba0ce5e4feb65abad5ad0f4acfa
2024-07-28 00:24:15 +00:00
Petr
16a7fb4b3e PY-34617 Move getTopLevelAttributes(), findTopLevelAttribute() from PyAstFile
GitOrigin-RevId: 226a7e968851ab0c8730bb79ca90d0ed5dcec364
2024-07-28 00:24:15 +00:00
Petr
cfa28c0d2a PY-34617 Move getClassAttributes(), getOwnSlots() from PyAstClass
GitOrigin-RevId: 39ee4f79543a35fc696f9c754f5c5cf89b711f63
2024-07-28 00:24:15 +00:00
Petr
302dbfa84b PY-34617 Remove obsolete class (PyStatementPartImpl)
GitOrigin-RevId: 48d03f62afa160410ac59e3938dfd876a41f54b7
2024-07-28 00:24:15 +00:00
Petr
4317e0a1ed PY-34617 Restore PyIfPartIf, PyIfPartElif interfaces
GitOrigin-RevId: 3283be157d6f030840103fba5b8c7cfcee508e2b
2024-07-28 00:24:15 +00:00
Egor Eliseev
ba209d5e44 [python] Change WARN to INFO notification when can't find a resource name in PythonHelpersLocator#findPathInHelpers
Merge-request: IJ-MR-140807
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

GitOrigin-RevId: 9b570d824218117096d0ad97a01bbaa6ee71e53a
2024-07-25 16:07:35 +00:00
Mikhail Golubev
f392777e01 PY-44858 Create regular packages in refactorings initiated from top-level files in source/content roots
Otherwise, if someone wants to move a definition/extract a superclass from there to
a brand-new package, e.g. from main.py to pkg/mod.py, a namespace "pkg" package will
be created.

Restore the original behavior of PyExtractSuperclassTest.testMultifileNew: the origin
file was inside a regular project root without __init__.py alongside.

GitOrigin-RevId: 750414b18582740076c14bfcfd07fa38992b4428
2024-07-24 16:18:40 +00:00
maxle
90bbc21f3f PY-44858 Move and other refactorings don't introduce __init__.py inside namespace packages
Namely, Move Module Members, Extract Superclass and Make Local Function Top-Level were
all affected by this.
Now we check if the refactoring origin is inside a namespace package to decide whether
__init__.py should be generated for target directories.

Co-authored-by: Kamalia <alishevakamalia@gmail.com>
Co-authored-by: Maksim.Levitskii <maksim.levitskii@jetbrains.com>

GitOrigin-RevId: b0b3420c5ec8d1f7d3000d8834211631690a0c42
2024-07-24 16:18:40 +00:00
Vladimir Koshelev
ec8c3a8aa3 [pycharm] remdev: migrate PyCharm Frontend launcher to v2 modules
GitOrigin-RevId: e2c62c23bd0a22c742a46177c1a1ad4c4b5b95d0
2024-07-24 13:13:53 +00:00
Max Medvedev
9f930f7d18 @NotNull/Nullable for ASTDelegatePsiElement
GitOrigin-RevId: 48e11f869faf0565db1aeedfb8544fdb04876c61
2024-07-23 13:27:20 +00:00
Egor.Eliseev
0be08ded36 [python] Rewrite PythonHelpersLocator
1. `PythonHelpersLocator` is an API to get helpers. It is aware of PyCharm Community helpers but also aware of some EP that provides additional helper paths.
2. EP implementations for PyCharm Prof and Jupyter that provide additional (prof) helpers.
It will help avoid problems with which Locator to use from Professional, Community or Jupiter plugins.


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

GitOrigin-RevId: c7c34f323247002699866f12f6ff5a08cf6a18ff
2024-07-23 12:04:22 +00:00
Vladimir Koshelev
c559ffab2b [pycharm] change the order of extended completion contributors to last, so they cannot pollute other stages.
GitOrigin-RevId: 675ead60c308a41142cc0abc1015d2aa50178e02
2024-07-22 12:26:17 +00:00
Mikhail Golubev
44aefbe28d PY-73675 Restore non-recursive index access in PyClassNameCompletionContributor
GitOrigin-RevId: 18365f310a0315cd743fb732ffdf65e530528a15
2024-07-22 11:06:30 +00:00
Mikhail Golubev
54f528f334 [python] In completion of importable names, plot CDF of completion time with Sputnik
GitOrigin-RevId: 683631a9969b2e76e2058178aff9c3398ee0dd16
2024-07-22 11:06:30 +00:00
Andrey Vokin
e6c66dfd5e PY-74012 Deprecation decorator stub resolves during indexing
Avoid using resolve when calculating deprecation messages

GitOrigin-RevId: 813849bdaeb3819b445db600fc0efbcb014ed5c9
2024-07-19 19:18:54 +00:00
Vladimir Koshelev
d968d81f40 [pycharm] do not take unreachable into account when it's used for resolve, not type inference
GitOrigin-RevId: 3ef149fb3588d371619d34a1f95cce09b2b10974
2024-07-19 13:59:50 +00:00
Vladimir Koshelev
6a08992395 [pycharm] PY-71726 add initial support for TypeIs
GitOrigin-RevId: ae3d5d7c88450bf2851fa1dabbf264f7206d347a
2024-07-19 12:45:50 +00:00
Vladimir Koshelev
a40425e28a [pycharm] prevent propagation of PyNarrowedType
GitOrigin-RevId: fdfd8e7563f36768b050efbf5ed8f259db994afd
2024-07-19 12:45:50 +00:00
lada.gagina
0cd4aae5f5 [python] packaging: add a quickfix to install all missing packages in a file (PY-71152)
GitOrigin-RevId: 6d87758b7551df057160cfb12420064baae13b21
2024-07-18 20:53:48 +00:00
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