Commit Graph

2195 Commits

Author SHA1 Message Date
Mikhail Golubev
1d4d71234a PY-82979 PY-81028 PY-83699 PY-83583 PY-83700 PY-81439 Bump the stub index version
Otherwise, the newly recognized implicit type aliases are not stored in the indexes.

(cherry picked from commit de504d03d72c7bc856a10f8d0900e6ff62816112)

IJ-CR-176451

(cherry picked from commit 18f56c69cb467c1c518372c07216199bf63509a4)

GitOrigin-RevId: 9b31ba2c05b4776617e871301e7ab6ad2c84544e
2025-10-22 22:19:35 +00:00
Mikhail Golubev
89ba56683e PY-82133 Recognize Self as a special type form when resolving into typing_extensions.py
If a per-project ".venv" is not excluded, we consider
pythonX.Y/site-packages/typing_extensions.py a project source file,
giving it priority over the bundled typing_extensions.pyi in Typeshed.
In typing_extensions.py "Self" is defined as a function. Since we
special-cased PyTypingTypeProvider.OPAQUE_NAMES only for assignments,
we didn't recognize that it was a special form, and hence reported
it as referring to an illegal type hint.

Though it's more of an "incorrect project setup" type of problem,
I think it's still worth supporting functions as "opaque names"
just in case.

(cherry picked from commit 63f641cd8667fbb31ba1fb167a24ca825a8baf8b)

IJ-CR-176451

(cherry picked from commit 212368618d4d299048f0cee2ebaa1e35484eb86d)

GitOrigin-RevId: f4458625552d751b8a75a500eb85b7f858f9a406
2025-10-22 22:19:35 +00:00
Mikhail Golubev
dc29f4a9bc PY-81926 Don't report using classes overriding __or__ in the Class1 | Class2 notation for unions
It should only be special cases for classes which *metaclasses*
override `__or__` so that this notation is possible.

Other type checkers treat such union of classes overriding
__or__ in their metaclass as Unknown.

(cherry picked from commit c16edee2346582745aa5090c3d8f568a4513afc1)

IJ-CR-176451

(cherry picked from commit 4dfc125bcfc625d1fe5577695e9a75449f40594a)

GitOrigin-RevId: 9f066646863ec321bcace0d2d10efe44a3c12728
2025-10-22 22:19:35 +00:00
Mikhail Golubev
6ec2acfce8 PY-83700 Support implicit type aliases at class level
(cherry picked from commit efaf7fb9ae413370f18429859c05f114e6cf4677)

IJ-CR-176451

(cherry picked from commit 71bdaa9858d8092ad6201ce773c8b5d4117b86f5)

GitOrigin-RevId: be66d9701e23760f035a3f5f3db822cfcc8630bb
2025-10-22 22:19:35 +00:00
Mikhail Golubev
8ed93e704a PY-83699 PY-83583 Recognize non-top-level union types in implicit type aliases
(cherry picked from commit 72ad426ce1a613ef66d62557382e8ee7c17ed6de)

IJ-CR-176451

(cherry picked from commit 203ec86492ffeeee9199415e2d186453285d8bca)

GitOrigin-RevId: 2b990ffa586624a3463948546b8013ba6ab7c446
2025-10-22 22:19:35 +00:00
Mikhail Golubev
0ca8e9f740 PY-82979 PY-81028 Adjust the heuristic for implicit type aliases to recognize Annotated and Literal
Namely, that `Annotated` can contain arbitrary expressions and that `Literal` might
contain boolean and integer literals.

(cherry picked from commit 6b3d4212679d6556dfe1d4905f06a78e2769b4e2)

IJ-CR-176451

(cherry picked from commit 8d769a4319b1e9fec05e93226238b559a4132d65)

GitOrigin-RevId: 158a7f63318ef74b50ea6ad2101ec8990ed6ce51
2025-10-22 22:19:35 +00:00
Petr
f18ba33412 PY-81941 Make CallInstruction.isNoReturnCall non-recursive
(cherry picked from commit 4c9c1e2c6a42b6632d84667a31fb4f46936405b3)

GitOrigin-RevId: aa5d89a12fbb6f0bdda6c78b53123f6fcae5785d
2025-10-03 04:54:56 +00:00
Petr
b274df9909 PY-81941 Don't check NoReturn calls when inferring a function return type
(cherry picked from commit eef22498254ecee4e91c5dc3a29997a3d95e6ce1)

GitOrigin-RevId: 56b3c7e9094d21099b0973f6a8cc7a2b993b81a0
2025-10-03 04:54:56 +00:00
Petr
831e591b43 PY-81941 Remove unused fields (PyDataFlow)
(cherry picked from commit 2aab9bbfd1ff126a04246ae940629a7f2735b67e)

GitOrigin-RevId: 33081646afbf90089a78e1300a0f3e6e6bdd4b58
2025-10-03 04:54:56 +00:00
Petr
d65f470b61 PY-81941 Remove an unused function (PyDataFlow.kt)
(cherry picked from commit 5bb5686062c77a040429c57dedc4757ef0c8e999)

GitOrigin-RevId: a9ac82a02c7f3e99efeded0470d272076dfdf0d8
2025-10-03 04:54:56 +00:00
evgeny.bovykin
b9a11311b5 PY-84289 Compute getStringBasedType with doPreventingRecursion to avoid repeating calculations
(cherry picked from commit a548f05bea971f6b3e3acdb1f1bc7898d3411d5e)

IJ-MR-176651

GitOrigin-RevId: 7fc85277f5dcd118095be9b84813a4180b2ae4b1
2025-10-02 17:22:45 +00:00
Mikhail Golubev
b8cf0c6e0f PY-80002 Remove excessive version checks in PyResolveUtil.allowForwardReferences
`from __future__ import annotations` is not available in Python < 3.7,
and in earlier versions such import itself should be highlighted,
and using type parameter lists in Python < 3.12 is already reported.


(cherry picked from commit 18075131473fb5cee8a47ab259cfdc753889892e)

IJ-CR-175817

GitOrigin-RevId: 3a54244d031a5b8cd42da9aa6a75ce5a84c96603
2025-09-23 10:23:03 +00:00
Mikhail Golubev
09f5341566 PY-80002 Don't report non-quoted forward references in Python 3.14+ (PEP 649)
(cherry picked from commit b16fffe886d350a54434adb57519eb9c1992e217)

IJ-CR-175817

GitOrigin-RevId: 4565df762b5b31d75d63d257107379aba459c0db
2025-09-23 10:23:03 +00:00
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
Aleksandr.Govenko
a1ea38b4b9 PY-83900 Inspect Code consumes 100% CPU and takes unusually long on specific simple file
(cherry picked from commit 81973d162072c94b4d7201dffc68d43669f449a3)

IJ-MR-174807

GitOrigin-RevId: 7d6563db8b59c05f6ecc20abe929ce6771ece825
2025-09-08 15:41:33 +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
Petr
5de7e2eca5 PY-83741 Support type narrowing based on containment check for list and set literals
GitOrigin-RevId: 8c834433ef64c1906314d681383bdc258f4628bc
2025-08-28 16:40:57 +00:00
Morgan Bartholomew
6b50ea074f [python] PY-59986 fix type annotation injection for union operator
Merge-request: IJ-MR-171625
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

(cherry picked from commit 5bd3401e4a98fc615694dacb1d7fe7a1ddb68d3e)

IJ-MR-171625

GitOrigin-RevId: e18ed0b36044c659eae1d73fd29e5ec28425ad18
2025-08-26 02:15:17 +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
Aleksandr.Govenko
cc3889bf3b PY-82963 PyCharm doesn't infer correct type when matching multiple values
Initial implementation


(cherry picked from commit 79cd937a9e7b8157775f1b777b9377fb338c25ae)

IJ-MR-170885

GitOrigin-RevId: edfbf09c14724d2d69b2f3cbbcb05ce8c464fcf4
2025-08-20 13:33:28 +00:00
Aleksandr.Govenko
c043ee587d PY-79834 Pattern Matching: matching positional arguments for NamedTuples
(cherry picked from commit 3f570872c6034c0b23b52d81d8780ac398646b05)

IJ-MR-170061

GitOrigin-RevId: cb89aa5ac255c1a44d0eb08adc8600cc0f79e77c
2025-08-19 21:56:43 +00:00
evgeny.bovykin
6861b49e37 PY-79816 Introduce PyType#getMemberTypes and use it to infer __hash__ type of dataclasses
`getMemberTypes` should be used for members which have no PSI which can be used to resolve to. For example, `__init__` method in dataclasses are sometimes not present in the source code. Yet its parameters are always useful for the code analysis. In this case, `getMemberTypes` should be used.

(cherry picked from commit 2455ed05099842fc50e1fa2a196c4952b6444795)

IJ-CR-172940

GitOrigin-RevId: 1da7d966c9752b16afc6ec1c55e6606d8ff7b244
2025-08-19 19:06:44 +00:00
Aleksandr.Govenko
b27584c98b PY-83197 False positive This code is unreachable matching object field with other object fields
(cherry picked from commit b8a283f8227819d2777c0d0a561688e3f6a32c35)

IJ-MR-171819

GitOrigin-RevId: ec874b7af89305a139d8252abf3b81ce7d4e7a15
2025-08-19 17:47:25 +00:00
Aleksandr.Govenko
32153e86b0 PY-83237 False positive "This code is unreachable" after if check in a case
(cherry picked from commit 859b299589e217a827b7ea61d34e96e45eaf8dce)

IJ-MR-172390

GitOrigin-RevId: 60fa47fa0a13a040455ec4289e7be34fe2d48008
2025-08-19 16:11:36 +00:00
Mikhail Golubev
4aff3ed154 PY-83039 Don't trigger PyLiteralTypeCompletionContributor in cases like x = y.foo<caret>
It should be activated only for the simplest cases when the caret is either
inside an immediate string literal or its prefix is an unqualified reference
expression. It makes little sense trying to detect if something like
the literal string `"y.foobar"` is a possible value for `x`.

It's a relatively heavy completion contributor. It starts evaluating the type of
`x` flow-sensitively, analyzing all preceding function calls to take into
account `NoReturn`. It affects common workflows like typing out
`df = pd.` to create a new Pandas dataframe.


(cherry picked from commit f17fe2ce86ee100a3480a574c7f57a1bd67ec2d8)

IJ-CR-172165

GitOrigin-RevId: 4434488b1d2dae3ab7efd72e775b0c730268e51c
2025-08-18 11:48:31 +00:00
Marcus Mews
5aaa8992d3 PY-70265 Extract Method: signature preview also displays 'async' if necessary
(cherry picked from commit 159106ec2a31e5ad5992b1bca7cde1fb55e91a43)

IJ-MR-171062

GitOrigin-RevId: ef86284a03dd202460f681c5e6686132d03a7c1d
2025-08-18 11:16:40 +00:00
Aleksandr.Govenko
31dcf9f6d5 [python] Fix NPE in PyAstAsPattern
(cherry picked from commit d8f319769d8fd25c27e6ab75b05d94d56a9751b9)

IJ-CR-172556

GitOrigin-RevId: c0c921a2ef363c9e3b33a21869cc290896372ab6
2025-08-15 13:27:10 +00:00
Aleksandr.Govenko
adcc559e5c PY-81676 Don't report lines with assert_never as unreachable
(cherry picked from commit afdbf35915823de02a6b8551f57770113d0feb2f)

IJ-CR-172556

GitOrigin-RevId: 0f8526e2877736ac606db9ed4657a530a66d6f23
2025-08-15 13:27:10 +00:00
Mikhail Golubev
d5673dceef [python] Make overlooked PyElementVisitor methods for statements delegate to visitPyStatement
(cherry picked from commit f6853d0dfc5ddcc7b40bfccead0ad779328fc751)

IJ-CR-172556

GitOrigin-RevId: b7d424930b1f4752ea69041a4ab53229b0392f5d
2025-08-15 13:27:10 +00:00
Aleksandr.Govenko
05203527a4 [python] Convert PySequencePattern and PyMappingPattern to kotlin
(cherry picked from commit 074ed9f865556d561237fc894d202d76995ab562)

IJ-MR-168826

GitOrigin-RevId: 6776375e6566521744ccc1f6c54254b887a1574b
2025-08-14 20:56:06 +00:00
Aleksandr.Govenko
21e8b573a7 PY-81861 Pattern matching for dataclasses - allow matching a subset of attributes
(cherry picked from commit 30a865e64cee7be630567b7d23223fc79eac9dbf)

IJ-MR-168826

GitOrigin-RevId: 8383913015485a6b6e477131c47d502bb655dd30
2025-08-14 20:56:06 +00:00
Aleksandr.Govenko
0dfd1f65e4 [python] Refactor PyCapturePatternImpl. Introduce PyCaptureContext
(cherry picked from commit 2e3fbf4c7d79e6031c7c087e5c7e7e49046587fd)

IJ-MR-168826

GitOrigin-RevId: b87eda39543460451311fc875d6ae3722d671db0
2025-08-14 20:56:06 +00:00
Aleksandr.Govenko
8cc52b8cf3 Rename .java to .kt
(cherry picked from commit de4536d7ce72661c150a019631734c7489af6a84)

IJ-MR-168826

GitOrigin-RevId: a42be1d1bde11865cb7076e7a4703a1c8bab1471
2025-08-14 20:56:06 +00:00
Andrey Vokin
b3a70daa05 PY-83118 Forward Reference Causes Import to Be Incorrectly Removed in PyCharm 2025.2
(cherry picked from commit fcf27e5c97e12498bc1c630f43e0a0876faba408)

IJ-CR-172300

GitOrigin-RevId: 7f3fcc83890a4ae0b0e7e6dd4ba363790f318eaa
2025-08-13 13:13:42 +00:00
Aleksandr.Govenko
4c890f2d47 PY-82707 Pycharm July 2025 EAP showing unreachable when using a subtype of Any
(cherry picked from commit c8a61ecc43754144679e5afc9f4623c02f558597)

IJ-MR-170092

GitOrigin-RevId: 612862aa2ce338a8f18e13197f483b936c9d0cdb
2025-08-11 09:57:17 +00:00
Aleksandr.Govenko
c3e7d5a7b7 PY-76896 Conformance test failure: classes_override.py
(cherry picked from commit 6603d072bd324493af12130ebec1ef0004873255)

IJ-MR-167674

GitOrigin-RevId: bd25b117b426bce0c364aaabbc9e961295421fb4
2025-08-08 21:06:50 +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
Aleksandr.Govenko
6deddd7ee2 PY-81608 False positive "This code is unreachable" after try / finally if try has a while loop
(cherry picked from commit fbdefd71c5c9356c82d3c873426dd565dd95c613)

IJ-MR-169577

GitOrigin-RevId: b428a790336656088c9b3343a2f6772873cafca8
2025-08-08 18:19:44 +00:00
Aleksandr.Govenko
7e0924c394 PY-82712 False positive unreachable code after try / finally block if try has an if
(cherry picked from commit 53c13421523d780995fa83cc0625f6e99d5fe51f)

IJ-MR-169577

GitOrigin-RevId: f5254435a0512ba55db7fca9016a387740ac9b8b
2025-08-08 18:19:44 +00:00
Marcus Mews
2c3ae70ddd PY-83001 Extract method with type hints lacks return type sometimes
- fix missing return type when last statement is a return statement
- add/adjust tests
- add missing null annotations

GitOrigin-RevId: 8fed189d0130c3b41a5f17a3324684a29b39c0ef
2025-08-07 20:11:13 +00:00
Marcus Mews
4e83c0cd74 PY-22720 Extract Method does Not Preserve Existing Line Breaks
- keep empty lines between statements
- add test

(cherry picked from commit 276000bdce7ffee22ecd2e03d2ec4831dd8f6725)

IJ-MR-171066

GitOrigin-RevId: 15660649de5c799be2dee8c5c80e616827ef41db
2025-08-05 12:33:06 +00:00
Vladimir.Koshelev
57b05ad202 [PY-82607] introduce a caching for all computations in PyTypingTypeProvider
GitOrigin-RevId: fb694274af15e64738054c03b0360f5aff4c513a
2025-08-03 21:40:01 +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
3d25b26d0f PY-35287 Extract method with typehints
- customize extract method refactoring for Python using prefix Py
- option to enable/disable type annotations
- persist value of checkbox.isSelected
- run all extract method tests using types
- add specific typed test
- adjust api-dump.txt since some members of AbstractExtractMethodDialog were raised from private to protected
- small adjustment in test expectation of the inferred type

GitOrigin-RevId: be6e70dcb61c451debb98c10c0a001234188cb7d
2025-07-31 14:08:38 +00:00
Andrey Vokin
1f55555bbb PY-82783 Reset type-cache after low memory notification
(cherry picked from commit 2c50752bdc25b75f756a1a8166e72e8e3abd2710)

IJ-MR-169930

GitOrigin-RevId: d9bda4e6dbeb6efdd82b3ec83c542857695fb86f
2025-07-31 06:28:05 +00:00
Vladimir.Koshelev
4dcf05fc6d PY-82905 PyCharm extremely slowing down (almost blocked) with message: 'IDE running on low memory'
GitOrigin-RevId: 5e6e5ba64a12d4c1cc826f0b783877494747433f
2025-07-30 12:26:17 +00:00