Commit Graph

2022 Commits

Author SHA1 Message Date
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
Aleksandr.Govenko
23c42e1416 Rename .java to .kt
PY-80524

GitOrigin-RevId: 4693b9762d778b7816bab73a3e24a9b934954559
2025-05-07 15:42:10 +00:00
Aleksandr.Govenko
8230e4d19f Rename .java to .kt
PY-80524

GitOrigin-RevId: b9e0ea17589e9124d4004fa147fab345c77f6f15
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
98ec9cfd25 [python] Remove unused PyNamedParameter#getRepr
GitOrigin-RevId: 1d7eccf4fc0b5f20a571a8466ff4f4bc8d038826
2025-05-07 14:07:57 +00:00
Morgan Bartholomew
44f1cc490d Revert "[pycharm] PY-80681 don't infer Any from a default value of a tuple"
This reverts commit 3eeb355a499781320529fb8a2f527a638817db2c.

GitOrigin-RevId: 6257b6512450984521e7d8a1e73457c5049a6c8d
2025-05-07 08:50:23 +00:00
Morgan Bartholomew
742cd71098 [pycharm] PY-80704 substitute param specs when collecting generics
IJ-MR-161505

GitOrigin-RevId: a893a9557766e14d982468b3065f2ea72322d182
2025-05-07 02:42:43 +00:00
Morgan Bartholomew
de80275758 [pycharm] PY-80681 don't infer Any from a default value of a tuple
IJ-MR-161834

GitOrigin-RevId: b613a24ac40526c37a37d65bc30fb29d1de9c93e
2025-05-07 02:26:32 +00:00
evgeny.bovykin
d0f97bc677 PY-79480 Search type hints for class properties in parent constructors
(cherry picked from commit 5ec92d430623daf78aec1227527b3c9cdd34532e)

IJ-MR-159429

GitOrigin-RevId: 8df5662a179777289230ab7ad9febfb2363729a5
2025-05-06 15:34:30 +00:00
Mikhail Golubev
4ba9d71cce PY-80844 Disable the intention for converting f-strings into t-strings in Python < 3.14
GitOrigin-RevId: 97162fca82d36958d61641c56315295329018304
2025-05-02 16:01:53 +00:00
Mikhail Golubev
623f3c3482 PY-80850 Add support for Template strings as arguments of positional and keyword varargs
GitOrigin-RevId: a51c198623553ee9f0975c2b3bf7af0c86c88b7a
2025-05-02 16:01:53 +00:00
Mikhail Golubev
fdbf6c8883 PY-80850 Insert "t" prefix on completion after "{" in regular strings where Templates are expected
GitOrigin-RevId: 6cc25474c2392b6b5de9958e58bb87db86854c5f
2025-05-02 14:12:39 +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
Mikhail Golubev
b91099d758 [pycharm] PY-38169 In quick documentation display .py sources as the origin for .pyi declarations
In particular point that `collection.abc` symbols are defined in _collections_abc.py.


IJ-MR-159943

GitOrigin-RevId: 67e7f402f7bf266e6232aaa05947cb29eed4d9d7
2025-05-01 14:09:31 +00:00
Mikhail Golubev
d84eda6a48 [pycharm] PY-80432 Fix navigation on collections.abc in imports from Typeshed to _collections_abc.py
IJ-MR-159943

GitOrigin-RevId: 7543fc9505a7c9e3d9ed6bcd9d647d863a280b06
2025-05-01 14:09:31 +00:00
Morgan Bartholomew
d2792dd850 [pycharm] PY-38169 special case definition location for standard collections that are wrong in typeshed
IJ-MR-159943

GitOrigin-RevId: a5e2a58d9e8b0fe567e69fb992b7a4c811f502b9
2025-05-01 14:09:31 +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
Nikolay Chashnikov
f17fa8da08 [python] get rid of references to package-private members of intellij.python.psi.* modules from other modules (IJPL-149126)
GitOrigin-RevId: 8cc01d6fd600b59b8da814638d9da8df69975ad5
2025-04-30 09:01:10 +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
Ilya.Kazakevich
803e270d45 Python: refactor PyError hierarchy, migrate to PyResult.
DO:
For upper-level (public) API use `PyResult`.
(Optionally) for low-level APIs inside your modules use python `Result<S, E>`.
Represent errors as `PyError` whenever possible.
Report `PyError` to `ErrorSink` at the top of your code.

DON'T:
Use `kotlin.Result`
Use `PyExecutionException`
Use any exception to represent user errors.

GitOrigin-RevId: 4ecf69e1fae8be9192cd33b90e0147c725a98964
2025-04-29 00:43:56 +00:00
Daniil Kalinin
5e12117835 PY-79967 Simplify Template type inference for t-strings
GitOrigin-RevId: 2964402eac2061e0230e612badc790d0d289f469
2025-04-28 19:14:39 +00:00
Daniil Kalinin
9d86a1d671 PY-79967 Introduce a separate method in PyStringLiteralUtil for t-strings
GitOrigin-RevId: 47b1a84c4331aa127a17e4f934c4b1dc28396cf0
2025-04-28 19:14:39 +00:00
Koudai Aono
7239d2ef2c PY-79967 Support t-prefixed strings, Related PR: https://github.com/JetBrains/intellij-community/pull/302
* Add PYTHON314_PREFIXES to CompatibilityVisitor
* Patch typeshed, add t-string related stubs
* Infer `string.templatelib.Template` type for t-strings instead of plain `str`



GitOrigin-RevId: 0e913910ab9e0dca4052856b0585ce66265291c0
2025-04-28 19:14:39 +00:00
Mikhail Golubev
ecb85823a1 [python] Remove Python- and docstring type hint lexer duplicates
Lexers should be generated in modules where the corresponding grammar files belong.
Namely Python's own lexer in intellij.python.parser, and the legacy type hint lexer in
intellij.python.psi.impl.

GitOrigin-RevId: 602387221c84e92811608aac6730eeb5a7bf2f90
2025-04-28 15:53:14 +00:00
Petr
f4845ebf45 PY-79733 Incorrect type inferred for list and dict comprehensions of TypedDict values
GitOrigin-RevId: 35567939a66e7c9a58024034c2a42344bdce8097
2025-04-25 15:49:04 +00:00
Daniil Kalinin
6015533cb4 [python] PyTypeHintsInspection: cleanup
GitOrigin-RevId: 8d04a849774b870bf3f8e0bf9741e2fa58c5a672
2025-04-24 09:13:14 +00:00
Daniil Kalinin
96b4c88247 [python] PyTypeHintsInspection: Don't report unresolved references as invalid type arguments
GitOrigin-RevId: 1a8b92e5aad8f31c84fffbc90d69decef13f2831
2025-04-24 09:13:14 +00:00
Aleksandr.Govenko
df545f8047 PY-79910 Variable incorrectly marked as unused or redeclared without usage in nested try/if blocks
When there is no `finally` in try-except statement, use transparent exit instruction to tie all normal exits from try-, else- and except- parts to the next instruction


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

GitOrigin-RevId: 734581b732a1a558b72811fdda977c470d045cc9
2025-04-23 22:39:58 +00:00
Aleksandr.Govenko
99b2fc73cc PY-46592 Use of function parameter marked as possibly used before assignment
Create DELETE instructions only for unqualified names, as it seems we don't need other ones at the moment.


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

GitOrigin-RevId: e0d9c636c20facf587cb96d8117e6f5f804b847a
2025-04-23 22:31:19 +00:00
Petr
105c2d7374 PY-76885 Conformance test failure: constructors_call_metaclass.py
Replace the verbatim comment with a link to the spec.

GitOrigin-RevId: 2c5012babed584cab4f5d9f0bb68e960a76e6bc4
2025-04-23 19:39:34 +00:00
Aleksandr.Govenko
089e124ea1 PY-80493 Inconsistent return inspection adding "return None" after every line in context manager
Merge-request: IJ-MR-160763
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: b576e30d433d39e426c8854d3ad485594ac9e958
2025-04-22 14:01:06 +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
Alexandr Evstigneev
c293edb8c3 Extracted TokenSeparatorGenerator default implementation, added annotations
Some languages may need custom context-dependent space generation

Existing implementation requires `left` argument to be nullable, particularly in WebStorm code. Maybe this need to be revisited and fixed.

GitOrigin-RevId: 2b3744fa84470c6373bef70f7289fc2124183ead
2025-04-19 14:47:21 +00:00
Petr
0d842e477a [python] Inline oneliner method (PyAbstractClassInspection)
GitOrigin-RevId: 67821b8b8d8f643b5d93282fe9f6aebda33d3e28
2025-04-17 14:24:06 +00:00
Petr
b5c5126374 PY-76885 Conformance test failure: constructors_call_metaclass.py
Assignability of metaclass's `__call__` return type to a type being constructed should be used instead of class equivalence.

GitOrigin-RevId: 94ae5d5870ca7deedc42f381456d13cb08d97ffc
2025-04-17 14:24:06 +00:00
Petr
ea1c639108 PY-76885 Conformance test failure: constructors_call_metaclass.py
GitOrigin-RevId: d4ae8eb0303ec141c9766599ede8be1d3bb538fb
2025-04-16 17:38:23 +00:00
Morgan Bartholomew
7a7a9cb995 [pycharm] PY-80290 build empty tuple correctly
IJ-MR-160209

GitOrigin-RevId: b418d44ca00335d643e782b46a654b28b0527eb8
2025-04-16 05:42:42 +00:00
Morgan Bartholomew
d412ed3e87 [pycharm] PY-79331 render type as "type", not "Type"
IJ-MR-159663

GitOrigin-RevId: ef585e7409bc1d92f54d3fdac6beae8dca58cb1f
2025-04-16 04:59:39 +00:00
Andrey Vokin
4258a66920 PY-77171 Fails to render quick documentation
GitOrigin-RevId: 02ff0d9d9b08ffc4cac1344cf50b98d57aef920b
2025-04-14 20:59:29 +00:00
Daniil Kalinin
f977a01dfa PY-76865 Fix Conformance test failure: generics_typevartuple_args.py
Fix the situations when two tuples passed as function arguments were not matched correctly

GitOrigin-RevId: fae271e16ed0933343e9e00a77f9f316c6f99798
2025-04-13 14:34:58 +00:00
Petr
0175466dc6 PY-80195 Literals of Enums broken after import (2025.1 EAP)
Consider enum attribute of an unknown type an enum member.

GitOrigin-RevId: 72c2fd37f18e4dde65d735f1032495df5aeda791
2025-04-12 15:48:21 +00:00
Mikhail Golubev
981d0a5f68 [python] Mark PyDescriptorTypeUtil and PySyntheticCallHelper as Internal API
These were ad-hoc APIs for supporting descriptors, so they are still subject to change.

GitOrigin-RevId: 939c9a5e38d829926c560b5489d7e4d1b39ac108
2025-04-12 07:39:08 +00:00
Daniil Kalinin
56d5eeb351 PY-80248 Fix reference to collections.namedtuple was incorrectly reported as invalid type hint add a test
Consider references to all elements which type is `PyClassLikeType` or its inheritor as valid type hints, it will help to get rid of other false-positives as well

GitOrigin-RevId: eb27f96c39bd4f616a149a966132b4a9b3d84f04
2025-04-10 14:12:36 +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
Daniil Kalinin
aa84f6f92d PY-80248 Fix: Reference to type alias statement reported as invalid type hint
GitOrigin-RevId: 72c3631559622e278a23fa9d827ceef1667001cb
2025-04-08 21:51:54 +00:00
Morgan Bartholomew
5467ea94de [pycharm] PY-41827 check for union types in PySimplifyBooleanCheckInspection
to avoid ambiguous conditions


IJ-MR-159379

GitOrigin-RevId: 4de5b135442b69b0667712066446cf035a23ecea
2025-04-08 16:50:11 +00:00
Daniil Kalinin
0f458d1b5d PY-53711 Simplify PSI tree traversal
GitOrigin-RevId: a2d0dfde1e126319115a0ea058ced905a46430ac
2025-04-07 20:51:34 +00:00
chbndrhnns
7da7493efe PY-53711 Fix: Cannot extract a method if arguments are on separate line
GitOrigin-RevId: d48d96ba69345ec949272b56635c2efc8b3b433c
2025-04-07 20:51:34 +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