Commit Graph

396 Commits

Author SHA1 Message Date
Alexey Katsman
b30b281f5d PY-85634: Make PyInterpreterInspection async for PyCharm
PyInterpreterInspection uses SDK configurators to find existing
environments and find the most suitable SDK. This operation takes time
(especially with conda on Windows), and on top it's performed on every
file change, making UI freeze all the time.

This change makes inspection asynchronous by caching the result and
triggerring inspection again to show changes on the UI.

Follow-up to IJ-MR-178613

GitOrigin-RevId: 889bdaac6a0a34cfca4d29d6a43eb95824b32fe4
2025-11-25 19:48:52 +00:00
evgeny.bovykin
96a0d7da31 PY-84538 Report protocol instantiation as an error
(cherry picked from commit ad941a5d9a5fb852b0c28cbf259fdcc5ce3f3efb)

IJ-MR-173617

GitOrigin-RevId: 97c2b967b5a2c42d0f1c6c5f09a65beb64bd634c
2025-11-03 16:01:01 +00:00
Daniil Kalinin
1b197eb884 PY-85080 Add quick-fix to remove unused Type Parameters
(cherry picked from commit cbb9b8136d07350075a9af8b4bc5aaa8891edd73)

GitOrigin-RevId: 81c1ddc810da8ce9619fdb679a26938bdecdb38e
2025-11-03 10:33:56 +00:00
Morgan Bartholomew
00cdda225b [python] PY-83733 ruff support
(cherry picked from commit df443269c3a29cfe9b5f3b67663a1f998396e738)

GitOrigin-RevId: f7d5bf3905cbe4e9092ee3976509777005f3f3bb
2025-10-21 06:20:05 +00:00
Morgan Bartholomew
1514a1fc00 [python] python-lsp-core
(cherry picked from commit e07d457d959a1b589861180c1be06b995218aa2c)

GitOrigin-RevId: 032d78e90ff3263c494ceeafb2411aaceb29c643
2025-10-21 06:20:05 +00:00
Vitaly Legchilkin
84934e9e9e [python] (IJPL-205889) (BAZEL-2462) don't call getOrCreateAdditionalData for non-python sdks
+ add requirePythonSdk() verification for the Sdk extension functions, these methods are not designed to be called for non-python sdks and now will throw IllegalArgumentException.

also corrects dependency tree:
+ move PythonSdkUtil to the python.sdk module, remove dependency on psi.impl
+ create PySkeletonUtil for skeleton utils and leave it in the psi.impl

[python] (IJPL-205889) (BAZEL-2462) don't call getOrCreateAdditionalData for non-python sdks

+ add requirePythonSdk() verification for the Sdk extension functions, these methods are not designed to be called for non-python sdks and now will throw IllegalArgumentException

also corrects dependency tree:
+ move PythonSdkUtil to the python.sdk module, remove dependency on psi.impl
+ create PySkeletonUtil for skeleton utils and leave it in the psi.impl

GitOrigin-RevId: 20d958c5e15cc4e05545b2e61b126b5e015696ed
2025-10-10 18:17:28 +00:00
Nikolay Chashnikov
3a8344fcad [plugin model] use 'public' visibility for content modules which classes are used from external plugins (IJPL-207059)
153 modules which contain classes used from external plugins from the Marketplace are marked as public. This is needed to ensure that it'll be possible to use that API after converting code from these external plugins to content modules.

GitOrigin-RevId: dc48e8970041fddd3bf50d280711e95ce9e9ad9b
2025-10-08 18:39:06 +00:00
Vladimir.Koshelev
ba393efaa7 [python] PY-84398 get rid of embedded loading rules in PythonCore plugin, fix related issues
GitOrigin-RevId: 54f4bb333e0ca06a002a86c75f0bbc474863253e
2025-09-26 15:15:29 +00:00
Marcus Mews
eb3eeb0fca PY-57582 dataclasses: field with default value preceding KW_ONLY shows false-positive warning
- support marker field typed with KW_ONLY
- adjust other inspection message

GitOrigin-RevId: 28f30ffcc3400bc719c63eacd76e432a547a1a9c
2025-09-26 07:22:47 +00:00
Marcus Mews
9c2d77a961 PY-84322 Code compatibility inspection doesn't warn about absent parentheses in except clauses in Python <3.14
- add incompatibility inspections, quickfix, tests
- improve quickfix for adding parentheses
- add AST tests for PY-84077

GitOrigin-RevId: 2d09a06d4d0b5ae106f556808900573c50f41800
2025-09-25 08:31:43 +00:00
Marcus Mews
3914253777 PY-76811 Conformance test failure: dataclasses_slots.py
- support @dataclass(slots=True)
- add inspection for conflict with explicit __slots__
- add quickfix for new inspection
- add/adjust tests

GitOrigin-RevId: 5ac6efeb6c1e209b641365e2f22bdca74ae6484a
2025-09-18 08:08:12 +00:00
Morgan Bartholomew
c2f7a647e3 [python] PyInvalidCastInspectionTest cleanup
- moved functions to `PyTypeUtil`
- improved naming and documentation
- improved hitbox for unnecessary
- added tests to suites


Merge-request: IJ-MR-174646
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

GitOrigin-RevId: 4cecc6eb9a22cd8cc4d4019e0ff6f22faebe8cae
2025-09-17 08:15:57 +00:00
Marcus Mews
63abd60ba4 PY-84077 - Support PEP 758 – Allow except and except* expressions without parentheses
- adjust parser to support comma separated list of error classes
- add problem annotation and quick fix for missing parentheses
- add new tests, adjust old tests

GitOrigin-RevId: a1b9bdf252ac874aa7bd1a6881c1784259bb35cc
2025-09-15 08:33:03 +00:00
Morgan Bartholomew
6072cf8ea5 [python] PY-80252 set correct default highlighting for PyUnnecessaryCast
Merge-request: IJ-MR-173805
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

GitOrigin-RevId: 2e745411d0c9c477172bf13670b0e073c206d9ae
2025-08-30 04:24:49 +00:00
Morgan Bartholomew
c669178c4a [python] PY-83710 PyUnreachableCodeInspection respect user highlighting
Merge-request: IJ-MR-173949
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

GitOrigin-RevId: ef0241888e12f4930e99b0d5e7c5461ee976e7ab
2025-08-30 03:06:09 +00:00
Morgan Bartholomew
51615780f9 [python] PY-79178/PY-80252 report invalid and unrequired casts
Merge-request: IJ-MR-171620
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

GitOrigin-RevId: d9b13a99bad56a112f04febfc939823397b55ddd
2025-08-26 01:51:36 +00:00
Aleksandr.Govenko
8dbb1d0361 [python] Disable strict narrowing, add registry flag to enable it
GitOrigin-RevId: ba403db011803b4aef1ea2b1582374559b70c32a
2025-08-20 14:23:21 +00:00
Petr
dd58eaacfc [python] Rm obsolete registry key python.use.better.control.flow.type.inference
GitOrigin-RevId: 47ca59e692de12376ca17604b8b9ab2439882a45
2025-08-19 17:37:04 +00:00
Mikhail Golubev
58a45497af PY-24834 Report specific strict union members missing an attribute
It also fixed problems with not reporting an error when a union
contained an incompatible class but didn't contain Any
(there was an unnecessary isWeak check) as well
as reporting false positives when a union contained special
members types for which we suppress attribute access warnings,
such as classes inheriting from Any or implicit protocols
(PyStructuralType).

Missing equals/hashCode needed to be added to PyStructuralType,
because otherwise PyUnresolvedReferencesInspectionTest.testUnionContainingUnknownType
started blinking due to unions sometimes containing duplicate structural types
(i.e. in some test runs `Union[{smth}, str]` was inferred and in others --
`Union[{smth}, str, {smth}]`).

GitOrigin-RevId: 63f720844c2892d2baa82be19b573221bd4f5d99
2025-08-12 17:19:34 +00:00
Mikhail Golubev
3e7b16f248 PY-24834 Implement the strict semantics of union types
Under the registry flag "python.typing.strict.unions", enabled by default.

"Strict" union is considered a subtype of another type only if *all* its
members are subtypes of this type. Similarly, accessing an attribute on
a union type considered safe only if *all* its members contain this attribute.
It holds even if one of the union members is Any, i.e. "str | Any" is still
incompatible with "int", and it's not safe to access a non-str attribute on
it.

This is how all other type checkers treat union types. Historically, we
use so called "weak unions", where the above rules were relaxed so that
it was enough to have at least one compatible member type. It was
necessary because back then there was no way to declare function overloads,
type narrowing was limited (no pattern matching, no TypeIs/TypeGuard),
so proper strict unions, as in the type theory, would cause too many false
positives.

Co-authored-by: Aleksandr.Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 8a676d810548bf71ac0ff3497e59d8694e03e4db
2025-08-12 17:19:34 +00:00
Nikita Ashihmin
78fc24c815 PY-82919 PyPackages: Refactor Stub inspection
Signed-off-by: Nikita.Ashihmin <nikita.ashihmin@jetbrains.com>


Merge-request: IJ-MR-170639
Merged-by: Nikita Ashihmin <Nikita.Ashihmin@jetbrains.com>

GitOrigin-RevId: 9697165e74ea2e1c897de1f72312043d003796d5
2025-07-30 14:26:37 +00:00
evgeny.bovykin
24079c336d PY-76851 Introduce PyTypeAliasRedeclarationInspection
Similar to PyRedeclarationInspection but specifically for type aliases.
The difference is that for type aliases, we should report them as redelclarations even if they were used before

GitOrigin-RevId: 735c7be53bf7625cf0dccb83d8a3157665f65a96
2025-07-28 15:56:48 +00:00
evgeny.bovykin
52e44e5541 PY-76851 Add checks for invalid type alias statements
GitOrigin-RevId: ecb4286cd44927c72f292480c39f6a1a9badef0b
2025-07-28 15:56:48 +00:00
Mikhail Golubev
fd4360b032 PY-75831 tests for split cache(resolve/type) into library and user part
(cherry picked from commit ca5f003693960b25d78bda050b55fe39900be5a7)

IJ-MR-169158

GitOrigin-RevId: 759cb38f76124b5b0709757e8f73ddffbf4a8248
2025-07-28 08:06:50 +00:00
Andrey Vokin
31991b70bd PY-75831 Split cache(resolve/type) into library and user part
(cherry picked from commit 94456d3a1f0be2e747641b74ce8246857b1a3f77)

IJ-MR-169158

GitOrigin-RevId: 4cdf0b90f601ca37b0f11b4392dbcfcf856472c6
2025-07-28 08:06:50 +00:00
Petr
9dfc3fb473 PY-82835 Missing error: type parameter name is already in use by an outer scope
GitOrigin-RevId: 1bc0ae07c128a84a22a2c11ade182881cee12cab
2025-07-24 18:31:52 +00:00
Marcus Mews
643fbddc98 PY-78413 No warning for awaiting a normal function if target in other module
- special case for awaiting a call to an imported, untyped, non-async function

GitOrigin-RevId: 8eec47ca4560ae0577e8c6157ef533952436b3b4
2025-07-21 09:11:19 +00:00
Tatiana Ber
fda333cc4b PY-82724 UI Texts: Fix typos and grammar mistakes (July)
GitOrigin-RevId: 897383a66e4e826bd5014fdbd1bf5376a55460b6
2025-07-18 14:26:02 +00:00
Aleksandr.Govenko
abae4c8d05 PY-80237 Support PEP 765 – Disallow return/break/continue that exit a finally block
GitOrigin-RevId: 7c5e956759071ccf96ebb8d31628569633977801
2025-07-17 16:28:47 +00:00
Petr
6c3b0171c2 PY-71549 Rename various annotator classes
GitOrigin-RevId: f6ff60d69a708c4a540d69c0f69246afb9815c53
2025-07-16 04:51:32 +00:00
Petr
2e6c983cb2 PY-71549 Convert some syntax-related annotators to visitors and add them to PySyntaxAnnotator
GitOrigin-RevId: 46f4a0ccd8c2e7ef45ce5fa37ec5c48376924587
2025-07-16 04:51:32 +00:00
Petr
02caa4ea03 PY-71549 Rename few annotators
GitOrigin-RevId: 8efc73022d49f23ececc9e4c1c2671c2aabdf327
2025-07-15 11:17:13 +00:00
Petr
e4affd421f PY-71549 Extract visitors that rely on resolve from PyAnnotatingVisitor
GitOrigin-RevId: 302a8709562725556aab1ccf5b89759c82acc952
2025-07-15 11:17:13 +00:00
Petr
2402957c9d PY-71549 Move async-related check from PyKeywordHighlightingAnnotator to PyAsyncAwaitAnnotatorVisitor
It also caused double highlighting on the frontend as PyKeywordHighlightingAnnotator is currently registered in both frontend and backend.

GitOrigin-RevId: cdf111acfdb8a979613007e12abcf6c7dac9c9dd
2025-07-15 11:17:13 +00:00
Petr
065fb1cfd4 PY-71549 Rename files (added Py prefix to annotator classes)
GitOrigin-RevId: e854d37609e0dc82191fabc587014947c1f742aa
2025-07-15 11:17:13 +00:00
Petr
a51b604bd4 PY-71549 Eliminate global shared state inside annotators
Before, when entering an `annotate` method, a reference to `AnnotationHolder` was stored in the annotator field. And this required synchronization. Now this reference is stored into a temporary PyElementVisitor object actually used to perform highlighting.

Also, register all python annotators using a regular 'annotator' EP. There is no point in using 'Pythonid.pyAnnotator'.

GitOrigin-RevId: ad1df8ce743bc62d3f43e6bf9b1a8ea370ff7de7
2025-07-15 11:17:12 +00:00
Petr
6db8559cd4 PY-71549 Move HighlightingAnnotator, PyAnnotatingVisitor to python.psi.impl
GitOrigin-RevId: 049a21f31101e4c90ebcb1f335825d759ae50663
2025-07-15 11:17:12 +00:00
Nikita.Ashihmin
7de11fa9dc PY-82516 Can no longer quick-fix to install missing setuptools - irrelevant package is suggested
Signed-off-by: Nikita.Ashihmin <nikita.ashihmin@jetbrains.com>

GitOrigin-RevId: 51f022a0d51de20a4bd60f389f275e83bf1bda30
2025-07-10 00:03:06 +00:00
Ilia Zakoulov
1c307c7934 PY-82168: Implement inspection and quick fixes for dataframe and series in the conditions
GitOrigin-RevId: 658f2d5609852b00b7e1011c3841c7266c202686
2025-07-09 17:45:22 +00:00
Andrey Vokin
95529a9325 PY-79510 remove unused index
GitOrigin-RevId: 8f7e5a8db920d9fa68fc1cbc840c97b68668b728
2025-07-04 13:49:25 +00:00
Petr
fa98ce5640 PY-81471 Sync PyCodeStyleSettings
GitOrigin-RevId: dd0263865288cc86dc2df0912edfd15ea2fbe3df
2025-06-30 15:46:23 +00:00
Vitaly Legchilkin
e255e8d0d0 [python] i18n strings (remove hardcoded literals)
GitOrigin-RevId: 14ad16249d0b030f4d3b88fc6b86dc7146dc3c72
2025-06-25 12:51:22 +00:00
Andrey Vokin
8b387672f2 PY-79510 PyCharm: Code entry points for AI playground
Add an index to the names imported from Python. This will allow you to check if the project has AI libraries in its dependencies.

GitOrigin-RevId: d16f3163a602194ef0f3254402dd4061ff8d2f7f
2025-06-23 15:07:44 +00:00
Marcus Mews
f35ff1b00a PY-34368: False warning "This decorator will not receive a callable it may expect" when @classmethod is not the last applied
- improve inspection to respect unaffected decorators wrt. classmethod/staticmethod
- improve inspection message
- add tests

GitOrigin-RevId: 0eb431ae1aa2c40fa9056f7032936bb05bf8c32b
2025-06-21 11:11:50 +00:00
Marcus Mews
cb63214bc9 marcus.mews/PY-55691
PY-55691: `Expected type 'Type[AttrsInstance]'` warning passing `attrs` class to `attrs.fields()`

- add member __attrs_attrs__ to classes decorated with attrs.define or similar

Merge-request: IJ-MR-165647
Merged-by: Marcus Mews <marcus.mews@jetbrains.com>

GitOrigin-RevId: 979f894e595d903c55f33c8bd4c5c3d06cb2fe6d
2025-06-18 21:08:01 +00:00
Andrey Vokin
dc83319152 PY-81269 Extremely High RAM Usage
GitOrigin-RevId: bb534d62931c176d2395e2cceb0afabc57464669
2025-06-18 13:17:14 +00:00
Nikita Ashihmin
05e32e764d PY-19974 Packages: Add conda envinroment.yml support, refactor sync methods
Signed-off-by: Nikita.Ashihmin <nikita.ashihmin@jetbrains.com>


Merge-request: IJ-MR-164824
Merged-by: Nikita Ashihmin <Nikita.Ashihmin@jetbrains.com>

GitOrigin-RevId: 85cbf7b873742ded72029af1f4ff3e34af9bae22
2025-06-17 00:18:33 +00:00
Petr
31c71642fd PY-81471 Move PyLineWrapPositionStrategy to python.syntax.core
GitOrigin-RevId: 998a62f09ee1e2fed512c5ae8c8cfed8808c947f
2025-06-13 20:21:12 +00:00
Petr
e7a8716848 PY-81471 Move PythonCommenter to python.syntax.core
GitOrigin-RevId: a4d6c426f104f67c0bf95b15b321c101590c5142
2025-06-13 20:21:12 +00:00
Ilya.Kazakevich
80f248d842 Python: Move helpers locator out of PSI module
GitOrigin-RevId: 55fb4b41c56fdd41b6d9523cd7a148c002ffb8be
2025-06-07 21:59:42 +00:00