362 Commits

Author SHA1 Message Date
Marcus Mews
dcb6914323 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: 545f3597a488f85ba2ff17da0a389f2aed226406
2025-09-15 12:58:49 +00:00
Morgan Bartholomew
b4d6ff2556 [python] PY-80252 disable PyUnnecessaryCast by default
because unsafe unions cause false positives

GitOrigin-RevId: 3fd8a018c60cc743d2e31c1d306612c94179d43c
2025-08-31 12:26:25 +00:00
Morgan Bartholomew
b9c06cd3b5 [python] PY-80252 set correct default highlighting for PyUnnecessaryCast
GitOrigin-RevId: fb0767353a298f95af63beee4f9c2db729d777ee
2025-08-31 12:26:25 +00:00
Morgan Bartholomew
467785be0e [python] PY-79178/PY-80252 report invalid and unrequired casts
Merge-request: IJ-MR-171620
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

(cherry picked from commit d9b13a99bad56a112f04febfc939823397b55ddd)

GitOrigin-RevId: a03b56b8c3ea58455af5100e59eab310776e063d
2025-08-31 12:26:25 +00:00
Aleksandr.Govenko
5e5a46bb51 [python] Disable strict narrowing, add registry flag to enable it
(cherry picked from commit ba403db011803b4aef1ea2b1582374559b70c32a)

GitOrigin-RevId: 07a2f2fc25f28abfb1f7bca1a75ab86a20e16bc4
2025-08-21 20:48:53 +00:00
Petr
9095762730 [python] Rm obsolete registry key python.use.better.control.flow.type.inference
(cherry picked from commit 47ca59e692de12376ca17604b8b9ab2439882a45)

GitOrigin-RevId: 2413ed0354534c1e5cae67ca0cedc05b37ab8577
2025-08-21 20:48:53 +00:00
Ilia Zakoulov
a8675a61ac PY-82168: Implement inspection and quick fixes for dataframe and series in the conditions
(cherry picked from commit 658f2d5609852b00b7e1011c3841c7266c202686)

IJ-MR-168659

GitOrigin-RevId: 66806362570ef564b1495ba5a9afcd32a50859fb
2025-08-08 19:31:55 +00:00
Andrey Vokin
62f37bb800 PY-81269 Extremely High RAM Usage
(cherry picked from commit bb534d62931c176d2395e2cceb0afabc57464669)

GitOrigin-RevId: 5c542be02083a352890ccd61c4e2792b6b018fb7
2025-08-03 11:42:52 +00:00
Andrey Vokin
385d275011 PY-75831 Split cache(resolve/type) into library and user part
GitOrigin-RevId: 8dfd0120379c9a34051d66e147ffdc2c69f0db66
2025-08-03 10:57:11 +00:00
Marcus Mews
d7cc3e584e 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

(cherry picked from commit 0eb431ae1aa2c40fa9056f7032936bb05bf8c32b)

IJ-MR-165392

GitOrigin-RevId: 59e4df99bf6000c8775c566cc6cdc9e406496fda
2025-07-24 20:35:47 +00:00
Marcus Mews
1e1dc85113 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

(cherry picked from commit 8eec47ca4560ae0577e8c6157ef533952436b3b4)

IJ-MR-168288

GitOrigin-RevId: 5ae73b7b663e94996116706a775b9fed683f331e
2025-07-21 11:04:38 +00:00
Marcus Mews
7bfd231a33 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>

(cherry picked from commit 979f894e595d903c55f33c8bd4c5c3d06cb2fe6d)

IJ-MR-165647

GitOrigin-RevId: d668282db59d6a6fcea1d40bb36aa4ee48585dea
2025-07-15 06:09:10 +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
Daniil Kalinin
44bff92759 PY-76862 Report circular references in string literal type annotations
GitOrigin-RevId: 793e8efe56d7e8f979cab0cdf53958383f6b60a4
2025-06-05 11:12:16 +00:00
Pavel Karateev
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
Mikhail Golubev
f43edeeeb6 PY-80971 Remove now obsolete NumpyModuleMembersProvider
We've long enabled numpy's own pyi stubs by default.
Now, without always available numpy stubs in python-skeletons this extension
causes an SOE when there is a module called numpy
(see `SemanticPyUnresolvedReferencesTest.test unresolved import from well-known installed import are critical`).

GitOrigin-RevId: 3cb4ff5ca3404cb4f20dd584da5928c78b73ea91
2025-06-04 18:33:47 +00:00
Mikhail Golubev
c48402b4cb PY-80971 Drop the legacy python-skeletons stubs
GitOrigin-RevId: bdd71af6a628d1b9fc03680a33088cc26857b2d0
2025-06-04 18:33:47 +00:00
Daniil Kalinin
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.bovykin
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
Daniil Kalinin
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 Bartholomew
e9bdb6af71 [python] PY-76810 handle private parameter names correctly
GitOrigin-RevId: f4b89d6a03146a50adc8c7de86f6ec03e5cf9af8
2025-05-30 09:41:02 +00:00
Morgan Bartholomew
2be8cd044b [python] PY-81424 update message for keyword unpack inspection
GitOrigin-RevId: 24234b4936031a19d08f58fbf871bc1749853745
2025-05-27 07:34:44 +00:00
Andrey Vokin
058c8ad641 PY-62670 Invalid "await outside async function" in Jupyter notebooks
GitOrigin-RevId: 26681302f28da968e0525a908d5b31f7451a9627
2025-05-22 07:10:41 +00:00
Petr
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
Petr
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 Kalinin
077f780a2b PY-76895 Refactor PyNewStyleGenericSyntaxInspection, add some missing checks
GitOrigin-RevId: 0264b9b5d90ae8c87988caee0730e41a447f1dd4
2025-05-20 15:35:38 +00:00
Petr
8fbb25d4ad [python] Slightly simplified code (PyOverloadsInspection.kt)
GitOrigin-RevId: 333affe1d43bf5c8995cd39993643f6c7d8198e6
2025-05-19 18:40:39 +00:00
Petr
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
Petr
f8ed1ff69b PY-80627 @override usage with overloaded methods
GitOrigin-RevId: d864bf51ce48a662d4aed696802c321561d27877
2025-05-17 13:45:32 +00:00
Petr
57c773ccb3 PY-80627 @staticmethod, @classmethod usage with overloaded methods
GitOrigin-RevId: 3712c0f4dfb70146e3127af02c4fc04de75dcd33
2025-05-17 13:45:32 +00:00
Petr
58cd6bb893 PY-80627 At least two @overload-decorated definitions must be present
GitOrigin-RevId: c40090f12631d61cfbb151f52cf709a8a2cd2383
2025-05-17 13:45:32 +00:00
Aleksandr.Govenko
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
Alexander Kuklev
a87c6df75c [PY-80878] Fix tornado package mapping
GitOrigin-RevId: 8df81d58c3da1fe4a0d8e486aca98263e5b50dec
2025-05-15 18:39:28 +00:00
Mikhail Golubev
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 Golubev
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.Govenko
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 Kalinin
246fd7cd88 PY-76862 Report forward references in unions
GitOrigin-RevId: 120a79d42e21bb1bd63922cc1d81d3d70ae908c6
2025-05-07 15:14:42 +00:00
Mikhail Golubev
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
Vladimir.Koshelev
67594cdaad [pycharm] finish community migration to v2
# Conflicts:
#	community/python/pluginCore/resources/META-INF/plugin.xml

GitOrigin-RevId: e4d6969fd15a3fddc4d6a03491fb9f9634285edf
2025-04-30 10:08:56 +00:00
Aleksandr.Govenko
4a5de0cccc PY-80729 "Inspect Project" gets stuck analyzing the project
Disable python.use.better.control.flow.type.inference for now


Merge-request: IJ-MR-161520
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 98ceafd932e6382847e49dc550c7e9b76c6626b9
2025-04-29 10:30:12 +00:00
Aleksandr.Govenko
a757828b06 PY-76659 Make CFG traversal iterative for name resolution and type inference
Swap back to ConcurrentMap and add more Registry checks

softValueMap doesn't play well with assumeType. Imagine this: you compute type A and store it, then compute type B that depends on A. But since softValueMap uses soft references, A might get garbage-collected. If that happens, you can override A with assumeType, and now B is out of sync — it's still based on the old version of A.

This kind of issue is unlikely to show up in small, artificial examples, but it could easily become a problem in real-world projects, especially large ones. It breaks the assumption that if a type is in the map, then everything it depends on should still be there too.

fix after rebase

Added nullability annotations to the AssumptionContext constructor parameters to improve type safety.

dm-checkpoint-id: 1VH4Od1GtvAo

Squash for easier rebase


Co-authored-by: Space Team <noreply@jetbrains.team>

Merge-request: IJ-MR-146970
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: cf2fc232c2c5b35a037396b5f85be3129a5efd3a
2025-04-20 16:03:28 +00:00
Petr
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
Petr
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
Mikhail Golubev
fb6554a342 [python] Move TypeEvalContextCacheImpl to intellij.python.psi.impl, leaving TypeEvalContextCache in intellij.python.psi
It will allow moving the implementation of TypeEvalContext to intellij.python.psi.impl
as well, making more platform and Python plugin APIs available in it.

GitOrigin-RevId: c04a2dc4d892d213f5407bcce35aeb5a3aba42dc
2025-04-07 17:07:46 +00:00
Petr
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
evgeny.bovykin
93efb0ac16 PY-78250 Call PyDataclassTypeProvider before PyTypingTypeProvider so that it has a chance to infer the dataclass type first
GitOrigin-RevId: 18230af949275e3f585ce806fec25144731e347b
2025-04-01 12:50:46 +00:00
Daniil Kalinin
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