313 Commits

Author SHA1 Message Date
Petr
9fa1facd3d PY-84356 Fix TypeEvalContext.inOrigin()
(cherry picked from commit f7d40505057b883cf87d96a481129c4347060c0b)

GitOrigin-RevId: e94c1c3f7b06075a342b70133db10d316f1efdfe
2025-09-23 15:52:36 +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
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
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
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
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
Marcus Mews
90201cfde5 PY-83059 NullPointerException in PyCharm 2025.2
- add null check

(cherry picked from commit 25ea1637981dec0d5d4fae532bed9e6c0ce7ebe6)

IJ-MR-171476

GitOrigin-RevId: f37d1e2ecd97b5d3185dc547c8f20af2a3cd05ef
2025-08-06 11:16:38 +00:00
Vladimir.Koshelev
1b662631cf [PY-75831] library cache should work correctly for PsiFiles created specially for completion.
GitOrigin-RevId: 0633366b2caf18a11cb7fb9802351f5db24500fe
2025-08-03 21:40:01 +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
Morgan Bartholomew
855d0800ae conflicts from cherrypick
GitOrigin-RevId: 0c5ac8858db88c73c09979309462129171489bab
2025-08-01 01:31:11 +00:00
Petr
e33aae05fc PY-81471 Move PyStatementMover to python.syntax
GitOrigin-RevId: c9cb03c1bb97720c392ea482765790674f27b647
2025-06-13 20:21:11 +00:00
Daniil Kalinin
90473326ac PY-76814 Add variance field to PyTypeVarType
GitOrigin-RevId: 2e7fe0b149a7412c4fdae924a846f200e82786a0
2025-06-04 12:17:47 +00:00
Aleksandr.Govenko
97cf7227da PY-78119 Introduce PyNeverType
PyNeverType is no longer child of PyUnionType, it was confusing.
Fixed failing conformance tests

GitOrigin-RevId: d05a425fa02e1647b82017a74b669fa3e1518354
2025-06-03 15:07:07 +00:00
Aleksandr.Govenko
b54f5b4ae8 PY-53880 Incorrect exhaustive pattern matching of Enum or Union types
Add PyNeverType and integrate it in PyTypeAssertionEvaluator

GitOrigin-RevId: 3db5224bfbf559f6d1bb146fd72c6cc6a97c4598
2025-05-30 18:33:26 +00:00
Morgan Bartholomew
4b1d24562a [python] PY-80436 support ellipsis
GitOrigin-RevId: 82e38fcb502ed68d5676f2cc774ef2653d69febb
2025-05-29 01:00:27 +00:00
Morgan Bartholomew
1cfa311783 [python] Rename NoneLiteral .java to .kt
GitOrigin-RevId: cd696ce62a90c0205cee0dbbcccad54e87a85386
2025-05-29 01:00:27 +00:00
Nikolay Chashnikov
4242e9b5a4 [python] API cleanup: remove unused deprecated API scheduled for removal (IJPL-178044)
GitOrigin-RevId: e48671fd16adff0e9777b3ff6dc61bd9482a8018
2025-05-28 23:37:49 +00:00
Andrey Vokin
a589598718 PY-81030, PY-81269, PY-80690 Do not store millions of PyNoneLiteralExpression instances in the cache
GitOrigin-RevId: 8b38eaf581081896b2c17ad862fd3667431e2766
2025-05-28 14:09:01 +00:00
Mikhail Golubev
00c78ebb84 [python] Don't treat PyClassLikeType as PyCallableType in PyTypeVisitor by default
GitOrigin-RevId: 647848f03c4816fb96a6bfcfcad6d9c7258a57ea
2025-05-14 09:51:56 +00:00
Mikhail Golubev
1765651746 [python] Mark PyType.getName() as @NlsSafe
GitOrigin-RevId: e458d1609f94b16433a723f10c6036f4575f2aea
2025-05-14 09:51:56 +00:00
Petr
c8fb196d52 PY-76877 Conformance test failure: overloads_basic.py
PySliceExpression is replaced by PySubscriptionExpression in AST.
PySliceItem is returned by PySubscriptionExpression.getIndexExpression(). For that purpose PySliceItem is now a PyExpression of type `builtins.slice`.

GitOrigin-RevId: 9aa8de13ef7c51741e248317c5264b3a06ffb9bf
2025-05-12 18:15:13 +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
Mikhail Golubev
3902b51f1b [python] Mark deprecated PyNamedParameter#getArgumentType for removal
GitOrigin-RevId: b57df511bed2d5af2d3160d489094fea424c5885
2025-05-07 14:07:57 +00:00
Mikhail Golubev
98ec9cfd25 [python] Remove unused PyNamedParameter#getRepr
GitOrigin-RevId: 1d7eccf4fc0b5f20a571a8466ff4f4bc8d038826
2025-05-07 14:07:57 +00:00
Vladimir Krivosheev
e3d5d85a47 update bazel files
GitOrigin-RevId: 4a1f45312f93e76248b05a7c8cc27a2b2ac84036
2025-04-30 14:07:08 +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
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
Vladimir Krivosheev
a5132e5922 fix TypeEvalConstraints visibility
GitOrigin-RevId: 8f3d15b28a69854937e77e05e84b70e902671e77
2025-04-08 16:05:15 +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
Mikhail Golubev
b619e21989 [python] Remove TypeEvalContextBasedCache
GitOrigin-RevId: 74d87561c3cc857ede78e60f19a7edbad35f29ee
2025-04-07 17:07:46 +00:00
Aleksandr.Govenko
624cedaa60 PY-79675 Pattern matching for dataclass fields
Merge-request: IJ-MR-155072
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 3cf0c311a5e4a273d289d73f17c3d418e608df21
2025-04-06 01:17:47 +00:00
Daniil Kalinin
3f6d195e1f PY-79842 Remove the assertion which emits a user-visible exception
GitOrigin-RevId: 9a0ea6b8c961424dd5008658a1b1ca16067b9a67
2025-04-02 11:49:38 +00:00
Andrey Vokin
8c1f3b6efa PY-78304 Use SoftReference to store types in TypeEvalContext
cleanup

GitOrigin-RevId: e9b24b1b27c24b29a389d08ede0358cbb33bbe8b
2025-03-26 10:53:48 +00:00
Andrey Vokin
d55cd9563c PY-78304 Use SoftReference to store types in TypeEvalContext
Make PyNullType class private

GitOrigin-RevId: 39c4e6f581c48419c82404944a67de154abd3bf3
2025-03-26 10:53:48 +00:00
Andrey Vokin
6a5d65a5de PY-78304 Use SoftReference to store types in TypeEvalContext
GitOrigin-RevId: d0e2c405ff0bec6fd9b677a55255929f8100217a
2025-03-26 10:53:48 +00:00
evgeny.bovykin
bf6e4735b6 PY-46623 Refactor PyKnownDecorator and related classes to be extendable
PyKnownDecorator is now a class instead of an enum, allowing extension to create new instances

GitOrigin-RevId: 846617f68e559f7f77af15a999f837391ac3090e
2025-03-14 15:15:09 +00:00
Aleksandr.Govenko
0073c7a8bb PY-48011 Pattern Matching: Type inference
Merge-request: IJ-MR-154823
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 42cb07bee63f34127c85574fc9c09e6043bc7591
2025-03-07 22:56:00 +00:00
Petr
405b37ac93 [python] Minor code deduplication
GitOrigin-RevId: 9ffcd59ab6810970b0f595fe9e1a721f83997812
2025-02-21 13:48:33 +00:00
Mikhail Golubev
d5e40b4ad4 PY-78236 Rename PyTypeVisitor#visitPyType to just #visit, add javadoc
Similarly to PyRecursiveTypeVisitor#traverse and PyCloningTypeVisitor#clone.

GitOrigin-RevId: 285537e4b7f9326ded81dcd648fa510572c0aba3
2025-02-14 18:53:22 +00:00
Mikhail Golubev
7ae73ebeb6 PY-78236 Introduce PyTypeVisitor API
GitOrigin-RevId: b6aa236b364bc55840be0a148205abba9c22167b
2025-02-14 18:53:22 +00:00
Leonid Shalupov
e4e5753846 housekeeping: remove unused imports
GitOrigin-RevId: ccba6d05260f5eb551ffa87e0d8a38dc93148a3a
2025-02-04 11:00:15 +00:00
Petr
af57462aa7 PY-78653 Fix constrained type variable substitution
Subtypes of types constrained by a type variable should be treated as their respective explicitly listed base types in the context of the type variable.

GitOrigin-RevId: ecaac1614f66974b6e6c2217ac0a90321d049f76
2025-01-28 15:24:40 +00:00
Ilya.Kazakevich
29ec21d7bd Python: unused symbols removed
GitOrigin-RevId: ea7dc3c43777f2b33e3284f782620ae8cdef04a2
2025-01-26 00:20:34 +00:00
Mikhail Golubev
ffb28d92c9 [python] Add a comment explaining the meaning of TypeEvalContext.Key
GitOrigin-RevId: eddc81498f070efffb79c0698bb30e69f35b289b
2025-01-22 16:49:41 +00:00
Daniil Kalinin
f05119cead [python] Store default types of Type Parameters as Ref to avoid problems with an explicit Any
GitOrigin-RevId: 880e883d196dc48d9cf6400580e9b4981448c507
2025-01-08 14:05:26 +00:00