Commit Graph
4883 Commits
Author SHA1 Message Date
Mikhail Golubevandintellij-monorepo-bot 0bdf5b4c7d fixup! PY-86002 Disable "python.typing.strict.unions" and revert the tests updated for PY-24834 in 253
Revert the revert of test changes that are not directly related to strict unions.


(cherry picked from commit 8a76bd91e040ad97e8ed680161f28370c84920f8)

IJ-MR-184619

GitOrigin-RevId: 4c293de3ecc3c8cb16869532fccc639e8c5a17ae
2025-12-03 20:58:50 +00:00
Mikhail Golubevandintellij-monorepo-bot 3c1d2da94f fixup! PY-86002 Disable "python.typing.strict.unions" and revert the tests updated for PY-24834 in 253
(cherry picked from commit 484b24ce81fe1364bc826f0a7aac9ea002bd148e)

IJ-MR-184619

GitOrigin-RevId: ee3d8595146bd960def96bd6130d8de765f86a78
2025-12-03 20:58:50 +00:00
Mikhail Golubevandintellij-monorepo-bot de837fb378 PY-86002 Fix more new tests that were expected to generate type hints with weak unions
Because UnsafeUnion is not denotable, we used to generate Any in such cases.


(cherry picked from commit 2c43848c86ccbab416bd321aee2f999f61eda756)

IJ-MR-184619

GitOrigin-RevId: 1f086ddc0e83b26e371cc3a3b64407e1508d57e2
2025-12-03 20:58:50 +00:00
Mikhail Golubevandintellij-monorepo-bot 060b900cf9 PY-86002 Revert also PY-25989 PY-84544 to fix new test failures after the revert to weak unions
Namely, `generics_basic.py` in the conformance test suite and
Py3TypeCheckerInspectionTest.testTypeVarWidening.

Revert 07803c6243370d55df0d870e2e32b38170c1fb49


(cherry picked from commit 9c334ef32597be1d1e8fbc3251ac267be46555c8)

IJ-MR-184619

GitOrigin-RevId: 4b2440c973d9c7a7a42590665bd473c4e7a4c9cf
2025-12-03 20:58:50 +00:00
Mikhail Golubevandintellij-monorepo-bot fd524cbe67 PY-86002 Disable "python.typing.strict.unions" and revert the tests updated for PY-24834 in 253
(cherry picked from commit 3df7847e2f94e8368e15e331f16a2254154e63fa)

IJ-MR-184619

GitOrigin-RevId: 213aedec5242143c1456450c214deb6f6e0fd60e
2025-12-03 20:58:50 +00:00
Pavel Karateevandintellij-monorepo-bot 9285fded89 [python] PY-83029 fix compatibility inspection tests
`testBreakInFinallyBlock` and `testReturnInFinallyBlock`
were testing vs. latest language level, so apart from
the compatibility warning (for which these tests are
intended) - a corresponding syntax error was captured

I made these tests to use a specific language level
so they only verify the correctness of the compatibility
inspection and introduced four tests in `PythonHighlightingTest`
to capture the syntax error


(cherry picked from commit 254570dc4d5022176590377eaf8ea6a08917937a)

IJ-MR-182362

GitOrigin-RevId: fb9c92923820b370672451c5753ee24bdd5a4570
2025-12-02 11:21:12 +00:00
Pavel Karateevandintellij-monorepo-bot b257c225d2 [python] PY-83029 fix tests
(cherry picked from commit 64d9931ee762c8ac801114e22952f3086235467a)

IJ-MR-182362

GitOrigin-RevId: bcf515ae4f73cd3d44dc81a54c1acd1fbfb33c18
2025-12-02 11:21:12 +00:00
Morgan Bartholomewandintellij-monorepo-bot 723fb8c8d6 fixup! [PY-6591] use PyCodeInsightSettings.PREFER_FROM_IMPORT when moving module reference
(cherry picked from commit e194ea47c00647d67067377a63ff257609399c38)

IJ-MR-183300

GitOrigin-RevId: afc726fa9f2e556833f09d41e5d5f77469ca7fa6
2025-11-27 11:52:20 +00:00
Morgan Bartholomewandintellij-monorepo-bot 6d2db28b86 [PY-6591] use PyCodeInsightSettings.PREFER_FROM_IMPORT when moving module reference
(cherry picked from commit 2458902032ff1078689a2a641dfaa29e522148a5)

IJ-MR-183300

GitOrigin-RevId: f101d8aac2ad92af83ad6716a15865238856abb7
2025-11-27 11:52:20 +00:00
Mikhail Golubevandintellij-monorepo-bot 24990ca39b [python] PY-85031 Use PyAstNamedParameter.isSelf when reporting legacy positional-only parameters
It correctly takes into account the first argument of `__new__` that is also implicit,
and thus should be excluded when reporting positional-only parameters following
non-positional-only ones.


(cherry picked from commit abf09c6be5e49c21c12264d22bf63a51018fdcd6)

IJ-MR-180323

GitOrigin-RevId: 85fb7ea284a237252e8634344b968981eda56dc3
2025-11-26 19:08:59 +00:00
Petrandintellij-monorepo-bot 241ba26253 PY-25989 PY-84544 Widen types during type parameters substitution
(cherry picked from commit 627673fc7ed27621df839a5c1d4d31e677ce7f8c)

GitOrigin-RevId: 07803c6243370d55df0d870e2e32b38170c1fb49
2025-11-26 18:52:04 +00:00
chbndrhnnsandintellij-monorepo-bot 861247150d [PY-84659] Moving a symbol respects PyCodeInsightSettings.PREFER_FROM_IMPORT for qualified usages
(cherry picked from commit 00c7867db4fa463c6a2eabb32bfa181bb25311d6)

GitOrigin-RevId: 83c0b47a97bbbd8f74279766eecefc05b3381784
2025-11-24 04:18:16 +00:00
evgeny.bovykinandintellij-monorepo-bot d1cb10773b PY-76822 Fix dataclass default values in conformance test suite protocols_definition.py
Both mypy and pyright don't show an error for the following case

@dataclass(frozen=False)
class Concrete4_Good7:
    val1: Sequence[float] = [0]

However, according to spec, such mutable defaults are not allowed. It will also fail at runtime


(cherry picked from commit ee569653a8f5cf91d6cb87321d63bf8e208d172d)

IJ-MR-174248

GitOrigin-RevId: 275e527ac36ac727dfc23f17bd0b539cff9df8c2
2025-11-19 13:05:44 +00:00
Petrandintellij-monorepo-bot c1c6c8c945 PY-83529 Make type name reasonable (PyModuleType, PyImportedModuleType)
(cherry picked from commit a5f8641bcae3cd01eb7ff174e289cbf3ca5e3b2b)

GitOrigin-RevId: 41050e03a015e79c74ff54a390090e5e5f70d783
2025-11-12 17:28:36 +00:00
Petrandintellij-monorepo-bot 3a58a09cbe PY-83529 Do not resolve to empty skeleton package modules
(cherry picked from commit 699b50ea5e2be24852fc1c07acb4d372e760a251)

GitOrigin-RevId: 7270c13b1973eb00d88c4f7f6c71ac1a54291428
2025-11-12 17:28:36 +00:00
Petrandintellij-monorepo-bot c6222fa129 PY-83529 Add tests for binary skeletons resolution
(cherry picked from commit 419975ed4ccbc4690cabe4f57307b0d6ad4fbc1e)

GitOrigin-RevId: cff0c0137a2f0b51ded1da567baf6fa9ed7c5e6f
2025-11-12 17:28:35 +00:00
Petrandintellij-monorepo-bot dc664f0c32 PY-83529 Rename test for clarity
(cherry picked from commit c6191d6c7d9863686731b2f9d9841e732a69c7d1)

GitOrigin-RevId: f1b71cb5edcab323458c2beb5e4eacd885cbcd8d
2025-11-12 17:28:35 +00:00
Petrandintellij-monorepo-bot a2ed943443 PY-83529 Remove unused test files
(cherry picked from commit f42b1a2ecd951ccfc75944ad7c237f3c790a318f)

GitOrigin-RevId: f5f527d99198c91a6f4ff5f351d356d1e2a4a384
2025-11-12 17:28:35 +00:00
Marcus Mewsandintellij-monorepo-bot 8ccd3203c2 PY-84484 Pycharm hangs when trying to call specific constructor
(cherry picked from commit b15a3bab218f72c1e9c717facfbff3e91eeea13f)

IJ-MR-180106

GitOrigin-RevId: 88614fddf666e170b71ef38fa4adffa9fa75da0a
2025-11-11 08:44:56 +00:00
chbndrhnnsandintellij-monorepo-bot 50fa4b90d2 [python] PY-63483, PY-83912, PY-70815 False positive warning Fixture '...' is not requested by test functions for attributes
Merge-request: IJ-MR-181099
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

(cherry picked from commit 7299d76d38ae5a823a3b0cae7ba5e2a0cc693d13)

IJ-MR-181099

GitOrigin-RevId: 82be14096cccf01de85fcf7f7abb4af2fd838193
2025-11-05 16:53:26 +00:00
Daniil Kalininandintellij-monorepo-bot 489b9b90aa [inspections] PY-85120 Do not consider expressions like a: list[int] | None = None a type alias
Target expression should have either explicit `TypeAlias` annotation or valid type expression in assignment without type annotation (to be considered implicit type alias)

(cherry picked from commit 1059a8df2d221bd068eee706139be20c256df549)

GitOrigin-RevId: 8c952138fbc4124f02f717ce8a1784c1f0dc86b2
2025-11-03 10:33:56 +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
Daniil Kalininandintellij-monorepo-bot 7d46075b5f PY-84107 Fix Type Parameters mistakenly reported as unused in PyUnusedLocalInspection
(cherry picked from commit 0593c2290aa1c84dde96673297374efef2b27fc3)

GitOrigin-RevId: 56de9b7a6b305eb9e88dc2bf8281c93f788eae80
2025-11-03 10:33:56 +00:00
Daniil Kalininandintellij-monorepo-bot fcf1abdbb7 PY-84570 Do not consider bare list literal as a valid type alias
(cherry picked from commit f0bcd2445735caa7917944351140a2877d0b4ffe)

GitOrigin-RevId: 5f0a0bff41ee01b4e8b4f7e73c1062d523854c2c
2025-11-03 10:33:56 +00:00
Aleksandr.Govenkoandintellij-monorepo-bot 8c745a5c22 PY-83339 Narrow X | None type to X after assert x
(cherry picked from commit a49863065bf26f615100b21f423a650cbebbcab3)

IJ-MR-178978

GitOrigin-RevId: 4bf02cab1e94a2ab1aaa70cb0b4578688cea88b9
2025-10-31 06:18:26 +00:00
Aleksandr.Govenkoandintellij-monorepo-bot 663b57857e PY-83597 False positive type narrowing in expressions with "and"
GitOrigin-RevId: e39cae3490ef0f0f151842f428a45d14d2c4d9ed
2025-09-30 10:30:37 +00:00
evgeny.bovykinandintellij-monorepo-bot 61b55f5a71 PY-84289 Compute getStringBasedType with doPreventingRecursion to avoid repeating calculations
GitOrigin-RevId: a548f05bea971f6b3e3acdb1f1bc7898d3411d5e
2025-09-29 13:38:19 +00:00
Ilia Permiashkinandintellij-monorepo-bot 0fa80a1ff0 [grazie] Print global rule id in tests
Merge-request: IJ-MR-176781
Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com>

GitOrigin-RevId: d403c6e47bd5acefe1bbbf94c85add7792c1bbe2
2025-09-26 12:21:16 +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
Petrandintellij-monorepo-bot 51ad67e9f7 PY-54512 Handle line breaks when extracting a method
GitOrigin-RevId: 95f6c067e613172913f3bbdc60eafb8623e32457
2025-09-18 15:42:03 +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
Mikhail Golubevandintellij-monorepo-bot d4922e2faa [python] Add missing tests on resolving forward references from new-style type alias
GitOrigin-RevId: ab9b688a7463b61ca262ec679781fb314ed74e8e
2025-09-16 17:00:01 +00:00
Mikhail Golubevandintellij-monorepo-bot 172d60f843 PY-80002 Add more tests on forward references in annotations from various scopes and in different versions
GitOrigin-RevId: cfe4d2ebbc7ff83f5d206ecc2569b3ba4b70a483
2025-09-16 17:00:01 +00:00
Mikhail Golubevandintellij-monorepo-bot 761c8be02a PY-80002 Don't report non-quoted forward references in Python 3.14+ (PEP 649)
GitOrigin-RevId: b16fffe886d350a54434adb57519eb9c1992e217
2025-09-16 17:00:01 +00:00
Mikhail Golubevandintellij-monorepo-bot 27d5a3e1f5 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.

GitOrigin-RevId: 63f641cd8667fbb31ba1fb167a24ca825a8baf8b
2025-09-16 11:17:45 +00:00
Mikhail Golubevandintellij-monorepo-bot 60cafd2f61 PY-83700 Support implicit type aliases at class level
GitOrigin-RevId: efaf7fb9ae413370f18429859c05f114e6cf4677
2025-09-16 11:17:44 +00:00
Mikhail Golubevandintellij-monorepo-bot 5e6b043e8c 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.

GitOrigin-RevId: 6b3d4212679d6556dfe1d4905f06a78e2769b4e2
2025-09-16 11:17:44 +00:00
chbndrhnnsandintellij-monorepo-bot 0f631663ba Suggest argument names for parametrized classes
GitOrigin-RevId: df1a269bea4e5b92e4f30e294b544b084fdba5a1
2025-09-16 09:07:23 +00:00
chbndrhnnsandintellij-monorepo-bot 3070792a57 Allow asyncio.create_task() to be called without await
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Depending how the `Task` type actually resolves, Pycharm might see different qualified names.

In CPython, the concrete implementation of Task lives in the C accelerator module _asyncio (a binary module). The pure-Python asyncio.tasks.Task is effectively an alias to that implementation.
PyCharm builds “binary skeletons” for extension modules. When type inference resolves the class coming from your interpreter’s standard library, it often prefers those skeletons. As a result, the qualified name for Task is taken from the binary module where it’s actually defined: _asyncio.Task.
Typeshed stubs reflect this too (depending on Python version). They define/alias Task so that asyncio.tasks.Task, asyncio.Task, and _asyncio.Task can all refer to the same runtime class. Which one PyCharm reports as typeQName depends on how resolution landed: through the binary skeleton (_asyncio) vs the re-exported names in the asyncio package.

GitOrigin-RevId: ce6c27e33748a2b1a1b1ba725bccf3c44eaad782
2025-09-15 15:42:13 +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
Artem Ivanovandintellij-monorepo-bot a5cfc253c1 PY-63306 Add test for target expression stubs referencing annotated parameters
GitOrigin-RevId: 472215f1cea6ab542729bad6e4e21633fe458a1c
2025-09-09 23:21:44 +00:00
chbndrhnnsandintellij-monorepo-bot c5c65112cc [python] PY-54771 Suggest fixtures in @pytest.mark.usefixtures("")
Merge-request: IJ-MR-173095
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

GitOrigin-RevId: f4a8479b755d71cd2932176acce98f4d2f8aaba5
2025-09-09 05:01:55 +00:00
chbndrhnnsandintellij-monorepo-bot 880f53d07f PY-53643 Missing "async" statement when pulling method up as abstract
GitOrigin-RevId: fa2b7329d462abaf71eb61d33f6b30c931a26a2f
2025-09-08 13:06:06 +00:00
Petrandintellij-monorepo-bot 3affb20872 PY-61591 The scope of a class' variable does not extend to contained blocks
GitOrigin-RevId: 871bb3584f9c72f91aced9e86909feccf0a901d7
2025-09-05 18:12:43 +00:00
Petrandintellij-monorepo-bot 059a568ad0 PY-61591 Delete MethodNameCanShadowModuleFunction.after.withTypes.py
GitOrigin-RevId: bb6cb1a686f0dd364fe4e192a35b7be5225eb06f
2025-09-05 18:12:43 +00:00
Petrandintellij-monorepo-bot bbd7d8a991 PY-61591 Move test files
GitOrigin-RevId: 87bbf31ca7e21c0f72e551b6415f60b214bd255c
2025-09-05 18:12:43 +00:00
Mikhail Golubevandintellij-monorepo-bot b2ef103d50 PY-83665 Stop excluding too short names from completion for importable names
Originally, when PY-62208 was first implemented, importable variants were always suggested
together with everything else, polluting the completion lookup with irrelevant "leaked"
top-level elements, such as loop variables, temporary variables, etc.

We first tried to exclude them by introducing this artificial threshold on "too short"
names that presumably could be typed manually and then imported with a quick fix.
It was possible to still complete them with a second invocation of the hotkey.
Eventually, we stopped offering importable variants at all if there are variants from
other completion contributors in PY-75580. In other words, they are suggested only when
a sufficiently long prefix has been typed to distinguish it from built-in symbols and
other names already available in scope.
Now it seems that this filtering on name length is redundant and often gets in the way,
preventing some common names, such as `Any`, `Enum` or `cast`, from being suggested.

GitOrigin-RevId: e10444d5bbbdde365f89aca38bb6f8f85940dd78
2025-09-05 13:12:34 +00:00
Morgan Bartholomewandintellij-monorepo-bot a13764a6b7 [python] PY-81651 respect explicit Any on binary operators
Merge-request: IJ-MR-174645
Merged-by: Morgan Bartholomew <morgan.bartholomew@jetbrains.com>

GitOrigin-RevId: 9062f58b163d99f526f2bb0c3ebfa29039508f54
2025-09-05 11:56:19 +00:00
Petrandintellij-monorepo-bot 1af1e8f6b1 [python] Added test for name conflict during "Extract Method..."
GitOrigin-RevId: 47ddbc14fbacbb93c8a2d12dcd382e57dd2d77d0
2025-09-04 17:11:22 +00:00