Commit Graph

1540 Commits

Author SHA1 Message Date
Ilia Zakoulov
a15b7f25b8 PY-1751: Introduce getMethodsInherited for PyClass.
This method collects all methods defined in the class and its parents.
Similar to `getPropertiesInherited` and `getClassAttributesInherited`.

GitOrigin-RevId: 8dcec5a002ffa105083ece6f4418d51e6d8c2879
2024-08-14 13:36:59 +00:00
Andrey Vokin
11bdced6c0 PY-73099 Support PEP 705 – TypedDict: Read-only items
GitOrigin-RevId: 50d2a1f6e1144f6a7c29ed5f2eb2ab6c1cb1ac64
2024-08-14 11:36:25 +00:00
Andrey Vokin
1be521e041 PY-73099 Support PEP 705 – TypedDict: Read-only items
GitOrigin-RevId: 24820bf7c9362d3b675ebfca16805744404ac2e9
2024-08-13 06:16:19 +00:00
Andrey Vokin
f4a04d15b6 PY-73099 Support PEP 705 – TypedDict: Read-only items
support for "ReadOnly" qualifier in chain with "Required" and "NotRequired"

GitOrigin-RevId: 4ee6d82f7153d4b65217acb34acc71c4b6c20dc6
2024-08-13 06:16:19 +00:00
Ilya.Kazakevich
b1a4c55771 Python: VirtualEnvReader refactoring: move the same module as PythonSdkUtil, and substitute a couple of methods.
`PythonSdkUtil` duplicates VER logic. One Jython-specific thing was also removed as we do not need Jython anymore

GitOrigin-RevId: 658fc42b485ac074a6d89fce3c7408e51cdc8f95
2024-08-12 20:54:06 +00:00
Vladimir Lezhnev
279d23bd2a PY-73911: Delete hardly used three-argument createStringLiteralFromString
GitOrigin-RevId: 0c796ca5ccf8be2c5ac42f2eda80acaf12b770db
2024-08-12 12:33:11 +00:00
Vladimir Lezhnev
3bcabcf4a0 PY-73911: fix "the inserted app is double-quoted" issue
GitOrigin-RevId: e22cadbea69abbfaf312b67bce3a82b9190912b7
2024-08-12 12:33:11 +00:00
Petr
a3608ebd22 PY-34617 Remove if stubs
GitOrigin-RevId: 13f49394e92daca80af9c82ac9ac1a439a6ae1f5
2024-08-12 09:37:32 +00:00
Ilya.Kazakevich
4bd20c2bf0 Remove unused code
GitOrigin-RevId: c44b72091241dcbb4458418c330958fbd1cc00f6
2024-08-10 02:13:54 +00:00
Ilya Kazakevich
6d1f3800dd PY-74425: Detect system pythons + pythons on .virtualenvs with NPW
`PythonSdkFlavor` detects pythons.

It uses `VirtualEnvReader` under the hood (see virtual env flavor) and system pythons (see other flavors).

We use it in `PythonLocalAddInterpreterModel` and cover it with tests

PY-74425 WIP, PY-74236: `VirtualEnvReader` shouldn't return `null` nor should it check for dir existence, use `getVEnvRootDir` as a default dir for venv.

The whole logic behind `VirtualEnvReader` is the following: we check for some env variable, and if it points to the correct path -- we use it. We fall back to the home directory otherwise.

Directory doesn't need to exist (hence, no need to check `isDirectory`) because a client might always create it.

Even worse: directory would probably not exist on a fresh OS, but a user still wants to create virtual envs there.

PY-74425 WIP: Encapsulate python names and patterns inside `VirtualEnvReader`.

`VirtualEnvReader` seems to be the main entry point to look for virtual envs on the local file system.

Historically, flavors did that, so they had a set of names and patterns to filter python by name, however:

1. `UnixPythonSdkFlavor` had named for **nix only, and `VirtualEnvSdkFlavor` had names both for Windows and **nix. It is unlikely to see a `.exe ` file on **nix or file, without an extension on Windows, so this check is useless and broken (`VirtualEnvSdkFlavor` checks for both names on both OSes)

2. `UnixPythonSdkFlavor` had regex to filter Python2, but this python was removed 4 years ago and could hardly be met on any new OS; hence this check is useless.

3. New Project Wizard needs to find pythons, but knows nothing about names and patterns.


Merge-request: IJ-MR-142040
Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com>

GitOrigin-RevId: ce649b4f12f7c7b60a25d8e1fb1222e075337844
2024-08-09 19:46:31 +00:00
Andrey Vokin
80934bca38 PY-73263 Python 3.13 Support - Code Insight - Typeshed
update class enumerate

GitOrigin-RevId: 95fc30b01c3c99144fec4f36188dc28875b3dc42
2024-08-08 21:53:20 +00:00
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