Commit Graph

298 Commits

Author SHA1 Message Date
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
Vladimir Krivosheev
0bc1cf1557 update bazel files
GitOrigin-RevId: 7320d3eff3aba093692ce66839c720ece6d7c4db
2024-12-30 11:28:24 +00:00
Vladimir Krivosheev
7b9ec58009 do not export intellij.database.connectivity.tests
GitOrigin-RevId: a1ef44dfa34cde110c9e6cad19d11b5e3019ab72
2024-12-28 21:45:55 +00:00
Vladimir Krivosheev
68d99c6550 cleanup
GitOrigin-RevId: 9cb238c220249088bfc75a448eb310b93c7fc45c
2024-12-26 14:56:01 +00:00
Petr
49b3258737 PY-76812 Conformance test failure: typeddicts_alt_syntax.py
Infer typed dict type from TypedDict() call even in case of an unexpected arguments list.

Also changed incorrect TypedDict() signature:
from (name: str, fields: dict[str, Any], total: bool = True) -> Any
to (typename: str, fields: dict[str, type], *, /, total: bool = True) -> Any

GitOrigin-RevId: 94c1ebb4fe3026744cb9771eab9e5ba507d049fa
2024-12-19 18:50:44 +00:00
Ilia Zakoulov
e044f9e441 PY-39384: Introduce PyTypeHintProvider
`PyTypeHintProvider` allows providing type hints for resolved elements before the main logic of `PyTypingTypeProvider`.
See an example of `django-stubs`: https://github.com/typeddjango/django-stubs/pull/2335.
`_UserModel` type might be replaced with a custom user model, provided in `settings.py` (`AUTH_USER_MODEL`).

GitOrigin-RevId: 986fb91c800be3ccfbc002c73c673896efec8a1a
2024-12-17 14:12:23 +00:00
Vladimir Krivosheev
98799639aa do not use _test as lib - test targets do not support this
GitOrigin-RevId: f2f49db4294b6a64040dbbd5f1d95e972cbd70a3
2024-12-15 18:32:30 +00:00
Aleksandr.Govenko
80ea4e852c PY-20710 Support 'Generator' typing class
Check YieldType of yield expressions in PyTypeCheckerInspection
Check that (Async)Generator is used in (async) function
Check that in 'yield from' sync Generator is used
Convert PyMakeFunctionReturnTypeQuickFix into PsiUpdateModCommandAction
Infer Generator type for lambdas
When getting function type from annotation, do not convert Generator to AsyncGenerator
Introduce GeneratorTypeDescriptor to simplify working with generator annotations


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

GitOrigin-RevId: b3b8182168c5224f0e03f54d443171ccf6ca7b89
2024-12-04 15:22:15 +00:00
Vladimir Krivosheev
17916c90f8 libraries -> lib, resources, opt-in, test deps
GitOrigin-RevId: db66ee95dcb0f0553b40c9cc56cd6afed8634cdd
2024-11-27 13:53:42 +00:00
Aleksandr.Govenko
31dd92576e PY-20611 Missing warning about functions implicitly returning None when return type is not Optional
Updated PyFunction to account for implicit 'return None' statements when inferring return statement types.

It affected return type inference of PyFunction.

Fixed a failing test related to formatted strings.

Added a quick fix to make all return statements explicit.

Updated the CFG to include PyPassStatements, enabling detection of exit points in empty functions.

Simplified PyMakeFunctionReturnTypeQuickFix to independently infer function types and handle required imports. Currently, it does not support specifying custom suggested types.



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

GitOrigin-RevId: 9f58961f9eb70e4f9dbba7359f5aafdfd392b7e2
2024-11-26 17:02:37 +00:00
Mikhail Golubev
b0bb5138f7 PY-77538 Introduce PyCallableParameterListType and PyCallableParameterVariadicType interface
PyCallableParameterListType type represents a concrete list of PyCallableParameters that
a PyParamSpecType can be specialized with.

Now PyParamSpecType and PyCallableParameterListType are similar to PyTypeVarTupleType and
PyUnpackedTupleType (a type parameter and its concrete specialization).

PyCallableParameterVariadicType indicates types that PyParamSpecType can be specialized with.
Namely, another PyParamSpecType, PyCallableParameterListType and PyConcatenateType.

GitOrigin-RevId: cc254b64884e637c1200f6334b6680ea3444bb8a
2024-11-21 11:26:23 +00:00
Mikhail Golubev
816845add5 PY-77538 Extract PyPositionalVariadicType marker interface
that indicates types compatible with PyTypeVarTupleType: PyTypeVarTupleType and
PyUnpackedTupleType. It will allow introducing a counterpart interface for types
compatible with PyParamSpecType.

GitOrigin-RevId: 0d5c77dd21d2bc7a21b246cfbd951cdd096918e9
2024-11-21 11:26:23 +00:00
Petr
16d40e9c5d PY-76830 PY-76833 PY-76843 PY-76879 Enums support
GitOrigin-RevId: 9021c003cde70c39f8a5635b42761c08049490e2
2024-11-13 18:30:03 +00:00
Mikhail Golubev
414397c7ea PY-77167 Simplify resolve logic for overloads, get rid of RatedResolveResult#RATE_LIFTED_PY_FILE_OVERLOAD
If there is an overload not followed by an implementation, which is
already an error, always resolve to the first overload, regardless
of whether it's a .py file, or a .pyi stub. It allows us to eliminate
the special RatedResolveResult#RATE_LIFTED_PY_FILE_OVERLOAD rate in .py
files, because we no longer need to duplicate the last, closest reachable
overload (normally an implementation should be reachable) with a higher
priority, and then filter it out during overload resolution.

Meanwhile, this filtering out didn't work right before
because some type inference logic, e.g., PyCallExpressionHelper.getCalleeType
used in PyReferenceExpressionImpl.getCallableType bypassed it. It should have
been done at the level of
PyCallExpressionHelper.forEveryScopeTakeOverloadsOtherwiseImplementations.

GitOrigin-RevId: 99a624ab85957d7a2d3c2c0ced596e472f9d615b
2024-11-05 12:33:52 +00:00
Artem Ivanov
1f08f46354 PY-74176 Allow PyTargetExpression along with PyReferenceExpression to hold Constance references
GitOrigin-RevId: 1b4a1c2c24f0aedbb6782aedfca02e119aabcd59
2024-10-25 16:27:08 +00:00
Ilya.Kazakevich
be826ca3b4 PY-75549: Simple (aka scratch) project first implementation.
Enable `pycharm.scratchProject`, and go to welcome screen.

GitOrigin-RevId: 9190344e3e8c1e7eb40834ad30c3e8f75dd599fe
2024-10-24 19:44:26 +00:00