Commit Graph
239 Commits
Author SHA1 Message Date
Alexey Katsmanandintellij-monorepo-bot 46011986a7 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: ed9e1aad89fb24ce70ba910ddd386a1adccd1baf
2025-11-25 18:47:50 +00:00
evgeny.bovykinandintellij-monorepo-bot 59df203089 PY-84469 Consider ClassVar when matching protocol and a concrete class
(cherry picked from commit 76af969cfe9318049f02dc7f6bdd03fe20a9504f)

IJ-MR-174248

GitOrigin-RevId: b34de32baf939e812169976761acd41eaa8aba38
2025-11-19 13:05:44 +00:00
evgeny.bovykinandintellij-monorepo-bot 1331c92868 PY-84464 Support @property decorator when matching a protocol and its implementation
(cherry picked from commit fcbeeb57323336c7d921edad373ea595ef687d6b)

IJ-MR-174248

GitOrigin-RevId: 6c44a1a7af026faaf4a5e9c1242ed29f3fb94e0e
2025-11-19 13:05:44 +00:00
evgeny.bovykinandintellij-monorepo-bot 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 Kalininandintellij-monorepo-bot 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
Marcus Mewsandintellij-monorepo-bot 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 Mewsandintellij-monorepo-bot 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 Mewsandintellij-monorepo-bot 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 Bartholomewandintellij-monorepo-bot 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 Mewsandintellij-monorepo-bot 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 Bartholomewandintellij-monorepo-bot 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
Mikhail Golubevandintellij-monorepo-bot 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
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 Ashihminandintellij-monorepo-bot 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.bovykinandintellij-monorepo-bot 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.bovykinandintellij-monorepo-bot 52e44e5541 PY-76851 Add checks for invalid type alias statements
GitOrigin-RevId: ecb4286cd44927c72f292480c39f6a1a9badef0b
2025-07-28 15:56:48 +00:00
Petrandintellij-monorepo-bot 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 Mewsandintellij-monorepo-bot 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 Berandintellij-monorepo-bot fda333cc4b PY-82724 UI Texts: Fix typos and grammar mistakes (July)
GitOrigin-RevId: 897383a66e4e826bd5014fdbd1bf5376a55460b6
2025-07-18 14:26:02 +00:00
Aleksandr.Govenkoandintellij-monorepo-bot 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
Petrandintellij-monorepo-bot 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
Ilia Zakoulovandintellij-monorepo-bot 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
Vitaly Legchilkinandintellij-monorepo-bot e255e8d0d0 [python] i18n strings (remove hardcoded literals)
GitOrigin-RevId: 14ad16249d0b030f4d3b88fc6b86dc7146dc3c72
2025-06-25 12:51:22 +00:00
Marcus Mewsandintellij-monorepo-bot 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
Nikita Ashihminandintellij-monorepo-bot 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
Daniil Kalininandintellij-monorepo-bot 44bff92759 PY-76862 Report circular references in string literal type annotations
GitOrigin-RevId: 793e8efe56d7e8f979cab0cdf53958383f6b60a4
2025-06-05 11:12:16 +00:00
Pavel Karateevandintellij-monorepo-bot 997750ddad PY-81679 reword inspection about too many unpacked tuples
(cherry picked from commit 4b13744dd7b9e7969f08042cf9eb662ad8899dd2)

IJ-MR-164905

GitOrigin-RevId: 31114c8ef89f7a058ba88da410eba8dbcb77db9d
2025-06-05 09:35:56 +00:00
Daniil Kalininandintellij-monorepo-bot acc7655878 PY-80166, PY-80167 Add warnings for covariant and contravariant types wrongly used in function type annotations
GitOrigin-RevId: 90faec6b5542659cec3aa53c2924f6837c73feda
2025-06-04 12:17:47 +00:00
evgeny.bovykinandintellij-monorepo-bot 72b4cd57c7 PY-76852 Report tuples with more than 1 unpacked unbound tuples as invalid
GitOrigin-RevId: 2bc31aa784572bbfdc5600e09aa027c149101846
2025-06-03 21:06:07 +00:00
4f61fa9fb0 PY-76870 PyTypeChecker - support compatibility checks for TypeVar defaults for both old and new generics syntax
Co-authored-by: Petr Golubev <petr.golubev@jetbrains.com>

GitOrigin-RevId: f2e299002119fa63c72e38eb898449d59a6c8397
2025-06-01 18:58:36 +00:00
Morgan Bartholomewandintellij-monorepo-bot e9bdb6af71 [python] PY-76810 handle private parameter names correctly
GitOrigin-RevId: f4b89d6a03146a50adc8c7de86f6ec03e5cf9af8
2025-05-30 09:41:02 +00:00
Morgan Bartholomewandintellij-monorepo-bot 2be8cd044b [python] PY-81424 update message for keyword unpack inspection
GitOrigin-RevId: 24234b4936031a19d08f58fbf871bc1749853745
2025-05-27 07:34:44 +00:00
Petrandintellij-monorepo-bot 2f533480a1 PY-78822 Type argument for "Protocol" must be a type parameter is not reported by PyCharm
GitOrigin-RevId: 8e02ca094674c75bed86e1feffeac5909828f38c
2025-05-20 18:48:27 +00:00
Petrandintellij-monorepo-bot f30dc5d254 PY-78828 No Protocol[] must include all type variables error is reported
GitOrigin-RevId: 5b8ed27b66cf78fa49009b39f9e70a14eae65d9d
2025-05-20 18:48:27 +00:00
Daniil Kalininandintellij-monorepo-bot 077f780a2b PY-76895 Refactor PyNewStyleGenericSyntaxInspection, add some missing checks
GitOrigin-RevId: 0264b9b5d90ae8c87988caee0730e41a447f1dd4
2025-05-20 15:35:38 +00:00
Petrandintellij-monorepo-bot 8fbb25d4ad [python] Slightly simplified code (PyOverloadsInspection.kt)
GitOrigin-RevId: 333affe1d43bf5c8995cd39993643f6c7d8198e6
2025-05-19 18:40:39 +00:00
Petrandintellij-monorepo-bot e69f69a10d [python] @final usage rules on overloaded methods are the same for .py and .pyi stubs
GitOrigin-RevId: 6ef9baffcca14f0c4dd35183ef211b4a365ddb9b
2025-05-17 18:32:24 +00:00
Petrandintellij-monorepo-bot f8ed1ff69b PY-80627 @override usage with overloaded methods
GitOrigin-RevId: d864bf51ce48a662d4aed696802c321561d27877
2025-05-17 13:45:32 +00:00
Petrandintellij-monorepo-bot 57c773ccb3 PY-80627 @staticmethod, @classmethod usage with overloaded methods
GitOrigin-RevId: 3712c0f4dfb70146e3127af02c4fc04de75dcd33
2025-05-17 13:45:32 +00:00
Petrandintellij-monorepo-bot 58cd6bb893 PY-80627 At least two @overload-decorated definitions must be present
GitOrigin-RevId: c40090f12631d61cfbb151f52cf709a8a2cd2383
2025-05-17 13:45:32 +00:00
Aleksandr.Govenkoandintellij-monorepo-bot 2894089e5a PY-54559 PY-80076 Display inlays hints with inferred types for reveal_type and function return types
Merge-request: IJ-MR-157270
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 1a504fb29b059243ee598672f6f666dbed367b34
2025-05-16 17:47:34 +00:00
Mikhail Golubevandintellij-monorepo-bot 5cabb0ae7d PY-4330 Group together messages for the new inspection in the bundle
GitOrigin-RevId: 97db4af96ce85133424f71d27d4afd42c5c000dd
2025-05-08 17:01:37 +00:00
Mikhail Golubevandintellij-monorepo-bot 2faeaa0da8 PY-4330 PY-77891 Extract PyUnusedImportInspection from PyUnresolvedReferencesInspection
Make the inspection for unused imports runForWholeFile=true to stop its blinking.

GitOrigin-RevId: 967e95edc229d021420b176f56a5d4b0fb44c3d4
2025-05-08 17:01:37 +00:00
Aleksandr.Govenkoandintellij-monorepo-bot a4b4cd8126 PY-80524 Explicit return statement expected false positive for an if inside try / except
GitOrigin-RevId: 6877fc7b34622d7ae884233af96e06ea92c918c1
2025-05-07 15:42:10 +00:00
Daniil Kalininandintellij-monorepo-bot 246fd7cd88 PY-76862 Report forward references in unions
GitOrigin-RevId: 120a79d42e21bb1bd63922cc1d81d3d70ae908c6
2025-05-07 15:14:42 +00:00
Mikhail Golubevandintellij-monorepo-bot f41aae4760 PY-80844 Add a new intention for converting between f-strings and t-strings
GitOrigin-RevId: be3ab4d72de05a92c986af31ac8e40309d9754b1
2025-05-02 12:08:57 +00:00
Petrandintellij-monorepo-bot 3060358b39 PY-12132 Support ABC classes (pep-3119)
Report error for abstract method in non-abstract class.

GitOrigin-RevId: 824d45a310b95ada628d6e607ae1ced6e351d849
2025-04-09 14:53:21 +00:00
Petrandintellij-monorepo-bot 22454fca8f PY-12132 Support ABC classes (pep-3119)
A class containing at least one method declared with `abstractmethod` decorator that hasn’t been overridden yet cannot be instantiated.

Also report instantiation of classes that directly inherit ABC or have metaclass set to ABCMeta.

GitOrigin-RevId: 55cb4dc90c55ddc63991a4c3f6b50b4e34a3b4bd
2025-04-09 14:53:21 +00:00
Petrandintellij-monorepo-bot a50efc954f PY-76829 Conformance test failure: generics_type_erasure.py
Using generic classes (parameterized or not) to access attributes will result in type check failure.

GitOrigin-RevId: a4c8c419dd46aaab9a66cf42391821d9035c5dba
2025-04-01 21:50:16 +00:00
Daniil Kalininandintellij-monorepo-bot 5ba41876dc PY-76894 Add an inspection for raw usage of 'Concatenate' in type hints
* Ensure 'Concatenate' is only allowed as the first argument to 'Callable' in type hints.
* Added a test
* Exclude 'generics_paramspec_basic.py' from ignored as it passes now

GitOrigin-RevId: f44af8fc1426ce7b6d7f725b4a72270bc8015d0f
2025-03-27 14:36:32 +00:00