Commit Graph

1171 Commits

Author SHA1 Message Date
Mikhail Golubev
d22b8b00b9 [python] Extract a common quick fix for unresolved package problems
GitOrigin-RevId: a1db8823a2fc83424431d975e1820b415895cc7a
2023-07-06 10:41:32 +00:00
Vladimir Koshelev
989f378988 PY-27708 support type inference of elements for set and dict type comprehensions
Merge-request: IJ-MR-109862
Merged-by: Vladimir Koshelev <Vladimir.Koshelev@jetbrains.com>

GitOrigin-RevId: 5be72a4bafbbe7dc942a8bb9afeaded45d0ec896
2023-07-04 23:18:10 +00:00
Mikhail Golubev
ef75347111 [python] Don't perform resolve while building PSI stubs for dataclasses
Leaving current file boundaries to find a boolean value of a @dataclass
decorator argument breaks index locality and might lead to reentrant indexing,
e.g. when we access PySetuptoolsNamespaceIndex to determine if a directory
should be considered a package.

GitOrigin-RevId: e13ee0aec956e89ba69c600c29cd513ac5774762
2023-07-04 22:43:47 +00:00
Nikolay Chashnikov
eefdfd0421 [python] fix ReadAccessAllowed assertion in PySignatureCacheManagerImpl (EA-811329)
GitOrigin-RevId: 350eeeb5ffcf6b9e97d6818f9f46bad0e6ea4c26
2023-07-03 17:11:21 +00:00
lada.gagina
fb8f166314 [python] fix IOOBE in PyDictLiteralCompletionContributor (DS-5159)
GitOrigin-RevId: 7943a0ef0c28b365898af9c10b1cd1da4f26c462
2023-06-30 20:08:13 +00:00
Mikhail Golubev
a9a8ab00ef PY-60738 Resolve to the bundled Typeshed and python-skeletons, ignore their copies
This is a followup for DS-4508. The issue was caused by the fact
that intellij.python.helpers content is copied using NIO, and to make
it visible for VFS we need to perform refresh of the latter.
Without it, PyTypeShed.directory property cannot find the Typeshed
root and is initialized to null. Then, PythonSdkUpdater.buildSdkPaths
is unable to locate SDK-specific Typeshed roots and set the corresponding
interpreter paths on SDK update. The problem is that VFS refresh requires
a write action and PyTypeShed.directory is accessed under a read action
(e.g. via PyTypeShed.INSTANCE.isInside in PythonLanguageLevelPusher), so
performing an explicit refresh would cause a deadlock (not to mention
that copying files under a read action is generally concerning).

The easiest way to address that is just to resolve to these stubs directly
inside the distribution, as before, not triggering copying them. Such stub
files are not executable by the interpreter and, thus, don't cause the problems
with .pyc files corrupting the IDE installation, so it's safe to leave them
there.

For the time being, Typeshed and python-skeletons are still copied together
with executable helpers, though, but these copies are effectively ignored by
code analysis, It's only not to break the implicit contract of
PythonHelpersLocator.getHelpersRoot, from which it's expected that the entire
content of intellij.python.helpers would reside in the returned directory.
A proper solution would be to move all type hinting stubs from
intellij.python.helpers to a dedicated module, excluded from copying,
but it needs to be further discussed and is risky right before the release.

GitOrigin-RevId: 2470cc110faa8286c44be2102aacc48893ea7ea9
2023-06-30 01:18:56 +00:00
Mikhail Golubev
58b27cca39 PY-61091 Select the most specific overload for binary operators
The rules for operators methods are the same as for regular
methods, exercised by other type checkers, i.e. it's assumed
that more specific overloads are defined earlier than less
specific. See e921654e47fe1fc5da047950b70775e342996757 for more
details.

Selecting compatible operator signatures also includes matching
"self" parameter against its expected type, which is necessary
for supporting typing.LiteralString, where some overloads of
"str" methods are made available only for literal strings.
Doing so, however, revealed a few issues with how we track
the direction of operator application, i.e. which operator
methods should be considered "reflected" and have swapped
receiver and argument. We rely on a method's name to decide
but the name is lost when a "reflected" method is defined through
an attribute assignment (PY-61093), and __eq__/__neq__ methods
are bidirectional so their names are not enough (PY-61090).

In PyUnresolvedReferencesInspectionTest.testStubAssignment we
matched C1.__mul__ and in PyTypeTest.testOperatorReturnsAny we
matched int.__eq__, despite the receiver and the argument being swapped,
because both of the methods are declared to accept Any value.
With more precise signature matching both of the tests now fail due to
the aforementioned issues. On the other hand, both of the cases seem rare,
so I disabled them for a while until there is a proper solution.

GitOrigin-RevId: 449a584ca258fe9210f5f2bda453caf9ab4faf7b
2023-06-21 16:32:22 +00:00
Lada Gagina
454b1287ae PY-58857 Infer typing.LiteralString for string literals
GitOrigin-RevId: 27507deabd61faedf7937415016f0f8334e5a418
2023-06-21 16:32:22 +00:00
Vladimir Lagunov
a277ed82d3 PY-60971 Create new API in PythonHelpersLocator that alerts about I/O
The deprecated `PythonHelpersLocator.getHelperPath` used to be cheap and had no I/O, but since bd5183320a43878de861fd11ae1f9bf79710290a it may start to copy many files to another directory. It becomes dangerous to call it from EDT.

GitOrigin-RevId: 98a913e68671b38299791fde7f267a396bd4faa0
2023-06-21 10:35:21 +00:00
Vladimir Lagunov
c67b9317a0 PY-60971 Don't cache Python helpers in system path for snapshot builds
GitOrigin-RevId: d1413d1224c727d67904ebe3abbd67ebdac21a5d
2023-06-21 10:35:21 +00:00
Vladimir Lagunov
4fba990118 PY-60971 Copy Python helpers within progress indicator
Previously, methods PythonHelpersLocator.getHelpersRoot and PythonHelpersLocator.getHelpersProRoot were trivial and had no I/O inside. The things changed in bd5183320a43878de861fd11ae1f9bf79710290a, and it became dangerous to call potentially long operations within locks.

The helpers are used by Code Inside inspections, so it's impossible to move all executions of these functions out of read locks. So, the functions now checks the global progress indicator in order to hold read actions as little as possible.

Also, a logging message is added when calling these functions from EDT. It's not a hard assertion: code that used to work keeps working, but errors about threading are reported now.

GitOrigin-RevId: ae39a6ba6e91a01d2410ede859a0accfb312d758
2023-06-21 10:35:21 +00:00
Vladimir Lagunov
cc0a4820ca PY-60971 Reduce size of copied Python helpers
Previously, PyCharm copied the parent of the helpers' directory. It contained python.jar which has size about 60 MiB and which is not used as a helper.

GitOrigin-RevId: d9cec6ddb93a36dc349af511fbb96221cdb5d951
2023-06-21 10:35:21 +00:00
Vladimir Lagunov
9560dba2ec PY-60971 Copy Python helpers not on every start
Python helpers take more than 50 MiB, and copying it lazily on every startup can bring unnecessary performance problems on slow machines.

There's a better approach: copying the helpers into idea.system.path once per installation.

GitOrigin-RevId: 33bcf4eb61463d03480c985014d9e503f94638db
2023-06-21 10:35:20 +00:00
Andrey.Matveev
070220ef3d [llm-pycharm] Impl isNameAlreadyUsed for python
GitOrigin-RevId: 280d59e11b6dcddccf1e806d5153a38ae1572e36
2023-06-20 10:44:50 +00:00
Mikhail Mazurkevich
61d59980f2 Revert "[Workspace Model] Migrate VersionedStorageChange to sequence instead of the list"
This reverts commit 0f6cdb7a.

GitOrigin-RevId: cfdc2a5bd56d291bf7f99256e9bcf279b1251c8c
2023-06-20 09:50:03 +00:00
Daniil Kalinin
157b23ce53 PY-33261 Inlay parameter hints for Python method and function calls
Merge-request: IJ-MR-108471
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: 1d9451020a755c0aaf57c12b16829f8b31291e5d
2023-06-20 05:27:45 +00:00
Daniil Kalinin
eb2a834e65 PY-30190 Report unresolved class attributes in decorated classes
Previously, unresolved class attributes were not reported for the decorated classes because of potential dynamical attributes (see PY-7173). This commit enables this warning again because false-negative unresolved reference warning is much more common and distracting than the case with dynamic attributes

Merge-request: IJ-MR-105254
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: 67d1ab3fe1d5a140836d49f8ef6a65cf01873456
2023-06-20 04:39:38 +00:00
Alex Plate
15d01811d0 [Workspace Model] [IDEA-320676] Move several WorkspaceListener to the new module
GitOrigin-RevId: 11b538f3488b1fa1fd5501bc228c0516c4e384d3
2023-06-19 09:35:24 +00:00
Alex Plate
0ea27da5c6 [Workspace Model] [IDEA-320676] Move all packages from workspaceModel to workspace folder
GitOrigin-RevId: b70062397efd6347c34431c24aacd2ec2e216897
2023-06-19 09:35:12 +00:00
Alex Plate
acde44da72 [Workspace Model] [IDEA-320676] Rename jps module of workspace model
GitOrigin-RevId: 146fda1ce8b8e436eb48070e8cf96f2c654ea6a2
2023-06-19 09:35:11 +00:00
Alex Plate
e18c7d8a5f [Workspace Model] Move sources of the storage under workspace package
GitOrigin-RevId: 013ce64337fe7b3637d731c1093a2337bbe71f22
2023-06-19 09:35:08 +00:00
Alex Plate
bfd595ae86 [Workspace Model] [IDEA-320676] Rename package of jps model (ModuleEntity and other related entities)
GitOrigin-RevId: 102135a4f66c4a12c9b1f95035b1607cb933825d
2023-06-19 09:35:04 +00:00
Alex Plate
ae72bfb1d9 [Workspace Model] [IDEA-320676] Move ModuleEntity and friends to other module without changing the package
GitOrigin-RevId: 2f92e16012b84d5c4505c55a887df3623b460a0b
2023-06-19 09:35:02 +00:00
Alex Plate
37c54118b9 [Workspace Model] [IDEA-320676] Rename base packages of the workspace model: com.intellij.workspaceModel
The rename of the packages is needed to follow the naming convention. See the attached ticket for the details.

GitOrigin-RevId: 24b2328e572efa23d67133fc495855cf662ea795
2023-06-19 09:34:30 +00:00
lada.gagina
e768aa3785 PY-40996 Add ability to collapse and expand python type annotations
"Collapse/Expand Python Type Annotations" actions, an intention and a setting

GitOrigin-RevId: e055538b29b07c1836399f52754b786a15351050
2023-06-16 19:08:16 +00:00
Trinh Anh Ngoc
c9f0c216a0 [PY-56210] Add id for PyModuleNameCompletionContributor
Allow other contributors to take priority over it if needed

closes https://github.com/JetBrains/intellij-community/pull/2197

GitOrigin-RevId: 06e7378ddb47a57dc8e934afcadd7f0d1b88bbb7
2023-06-15 20:21:10 +00:00
Daniil Kalinin
d5de282edd PY-17193, PY-10709 Don't use \ for line continuation by default
Adds a new option which allows to parenthesise call chains, import statements, string literals and binary expressions instead of using backslashes when splitting them to multiline by pressing Enter

Tests for PY-17193, PY-10709

Merge-request: IJ-MR-98747
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: 964f6c997e1e106a3d1b82d24e46947cc83fb2c6
2023-06-14 19:11:31 +00:00
Daniil Kalinin
45bb1fffb8 PY-24273, PY-53703 Support for functions annotated with typing.NoReturn and typing.Never
Functions annotated with `NoReturn` and `Never` now taken into account in the Control Flow Graph building process, and the code after calling such functions is treated as unreachable.

Merge-request: IJ-MR-105973
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: ef5840ae6e593498fc334dc9bd2daadccebf2b13
2023-06-13 22:08:30 +00:00
Egor.Eliseev
ca7085e665 PY-54839 Add _pytest.fixtures.fixture field to enum KnownDecorator
It is needed for `pytest` fixture function is not marked as one that can change the return type.
Now `pytest` fixture function returns `realType` instead of `Any | realType`.
See `PyKnownDecoratorUtil#asKnownDecorators`.

GitOrigin-RevId: c65334f2b15546f46ce5063be4c3952032bdb7c0
2023-06-13 13:59:31 +00:00
Alexey Belkov
55f582d5d3 Apply Kotlin inspection "Redundant 'if' statement"
GitOrigin-RevId: 2f93c77e56d8519431e8cc94f4ca2354003806b6
2023-06-12 14:45:50 +00:00
Andrey.Matveev
a3405094f3 [llm-python] Impl simple chat context provider and doc gen
GitOrigin-RevId: 569626162e4a24eb29c2c7d25b6c84aade847330
2023-06-08 19:36:49 +00:00
Daniil Kalinin
0be3de2af6 PY-36317 fix collection subscription statements wrongly reported as parameterised generics used in instance checks
Merge-request: IJ-MR-107037
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: 16c3c61525d50dcaa99c56418bd64621d70e4e5f
2023-06-08 11:00:00 +00:00
Vladimir Lagunov
89649ae06b Revert "[fleet] Restored reactive loading of SDKs from settings.json after smart-mode activation (related to FL-19248)"
This reverts commit 08f87af551374373e8fd6b5e5133d4158c1e31de.

The commit 08f87af55 was de-facto a reversion of bab46cfcb44b86f2b6191b5c369f5170811eb98a.
During a private conversation it turned out that 08f87af55 was created mistakenly and unintentionally.

GitOrigin-RevId: ac8af8a3ee614f6afef2c10ab34bfc76b60edb7c
2023-06-07 09:06:16 +00:00
Andrei.Kuznetsov
897f449714 IDEA-320457: Move class to top level BaseFileTypeInputFilter.FileTypeStrategy > FileTypeSubstitutionStrategy
GitOrigin-RevId: 2f77cf9428129d5edd82a1e73d1afc8d661ff1f6
2023-06-02 15:17:41 +00:00
Alexander Kuklev
a30a8dbb5e [fleet] Restored reactive loading of SDKs from settings.json after smart-mode activation (related to FL-19248)
GitOrigin-RevId: 08f87af551374373e8fd6b5e5133d4158c1e31de
2023-06-02 10:20:08 +00:00
Egor.Eliseev
547fafc199 PY-30033 Support resolving for pytest.mark.usefixtures
Add 'PyTestReferenceAsStringProvider' for fixtures from pytest.mark.usefixtures attributes.
Add new field 'myTextRange' to 'BaseReference' class.
It's needed for specify the text range for proper highlighting.
For example, to highlight text in a string without quotes.

GitOrigin-RevId: 5b9094169b71dd57d9091d6907346ca69f631ef3
2023-06-01 09:35:11 +00:00
Andrei.Kuznetsov
78290856b2 IDEA-320457: migrate some indexes to IndexingHint (PyModuleNameIndex,PySetuptoolsNamespaceIndex)
to speed up indexing of java `.class` files. See IDEA-320457 for full explanation

GitOrigin-RevId: c53f7064e28155fea4121b56078948c571a4318c
2023-05-31 20:48:41 +00:00
Alexey Belkov
4467dc883b Apply Kotlin inspection "Unnecessary type argument" on whole project
GitOrigin-RevId: 70a38b512309685d57bb5eddf2fc5068f14fe481
2023-05-27 14:22:18 +00:00
Alexey Belkov
1d790f1992 Apply "Java methods should be replaced with Kotlin analog" inspection on whole project
GitOrigin-RevId: 35d07247cdf7742957dde59bbb8d6408754a9c4e
2023-05-26 09:44:56 +00:00
Alexey Belkov
a6521777bf Revert "Apply "Java methods should be replaced with Kotlin analog" inspection on whole project"
This reverts commit 9863c1e3

GitOrigin-RevId: 7fe730efd4ffe4fef76fe6f36c3e53b496067855
2023-05-25 07:09:00 +00:00
Alexey Belkov
b6d93b8569 Apply Kotlin "Cascade if can be replaced with when" inspection on whole project
GitOrigin-RevId: ada0c39387c508fde4bf361a0f5b17765d9c0240
2023-05-24 16:04:41 +00:00
Alexey Belkov
ebe914e465 Apply "Java methods should be replaced with Kotlin analog" inspection on whole project
GitOrigin-RevId: 9863c1e384067b97b5015147589e409facd37549
2023-05-24 16:04:31 +00:00
Vladimir Lagunov
c1bbf8fc74 DS-4508 PythonHelpersLocator: copy all helpers to the temporary directory
It turns out that there are parts of code that suppose existence of all helpers without requesting them in advance via API of PythonHelpersLocator. These parts broke down when helpers became copied to a temporary directory.

Merge-request: IJ-MR-107692
Merged-by: Vladimir Lagunov <vladimir.lagunov@jetbrains.com>

GitOrigin-RevId: bab46cfcb44b86f2b6191b5c369f5170811eb98a
2023-05-19 19:40:54 +00:00
Olga.Lavrichenko
b221598456 DS-4113 Columns are duplicated in completion suggestions in python console
GitOrigin-RevId: 527cfd230c94b229ccf2f5d5263ba1171614cabb
2023-05-19 17:53:17 +00:00
Daniil Kalinin
8df7dd2f21 PY-32302 Provide custom syntax highlighting for Python local variables
GitOrigin-RevId: af7099a6ba948c740c8183674b24eeeddf164e70
2023-05-18 19:12:18 +00:00
Alex Plate
c23aea3909 [Workspace Model] Migrate VersionedStorageChange to sequence instead of the list
GitOrigin-RevId: 0f6cdb7a1e9cdd3025b00f94cb1978c750199636
2023-05-16 18:07:09 +00:00
Nikolay Chashnikov
263508fe4b [python] API cleanup: remove unused deprecated API (IDEA-312594)
GitOrigin-RevId: 83ecfec5f4317ea0ab52089c4c6c8060f1cc5fc7
2023-05-15 13:56:53 +00:00
Natalia.Murycheva
0d53aa47df DS-4878 Pandas-specific-quick-fix-replace-listdf.col.values-to-df.col.tolist
Add new intention and a corresponding quick fix for the usage pd.Series.values property from pandas library.

^DS-4878 Fixed

Merge-request: IJ-MR-106089
Merged-by: Natalia Murycheva <natalia.murycheva@jetbrains.com>

GitOrigin-RevId: 0c8dc40b09ee2d95ecd8ded532f31f5ef4a7740f
2023-05-13 20:44:29 +00:00
Vladimir Lagunov
d5f8028bfa DS-4508 Prevent importing python helpers from installation directory
Merge-request: IJ-MR-107279
Merged-by: Vladimir Lagunov <vladimir.lagunov@jetbrains.com>

GitOrigin-RevId: bd5183320a43878de861fd11ae1f9bf79710290a
2023-05-11 09:54:15 +00:00
Mikhail Mazurkevich
246ec159cf Revert "[Workspace Model] Use set for changelog in WorkspaceModelChangeListener"
This reverts commit 2a3800e2

GitOrigin-RevId: a13574ba0b51c3eac11703febd59f7adea222d03
2023-05-10 18:31:41 +00:00