Commit Graph

280 Commits

Author SHA1 Message Date
Andrey Vokin
a906361c54 PY-81269 Extremely High RAM Usage
(cherry picked from commit bb534d62931c176d2395e2cceb0afabc57464669)

GitOrigin-RevId: a5abecbe752fee6f11880376ab587f10a02c3674
2025-06-22 19:42:43 +00:00
Andrey Vokin
411974742e PY-78304: Revert
We already have SoftReference in TypeEvalContextCacheImpl

GitOrigin-RevId: 32bc48fdad57c74ee8593ab37222a70b81e3f634
2025-06-16 16:46:45 +00:00
Andrey Vokin
33f63527f9 PY-81030, PY-81269, PY-80690 Do not store millions of PyNoneLiteralExpression instances in the cache
IJ-CR-164285

GitOrigin-RevId: 4dd0833b7d71228dc8fd092adf41e7de23e1d315
2025-05-29 16:15:17 +00:00
Aleksandr.Govenko
d8f57b77c6 PY-80524 Explicit return statement expected false positive for an if inside try / except
(cherry picked from commit 6877fc7b34622d7ae884233af96e06ea92c918c1)

IJ-MR-161824

GitOrigin-RevId: 8c3219ea8bb8f547f7c314af8cb0d432c042cd7c
2025-05-11 22:28:24 +00:00
Daniil Kalinin
6278084be4 PY-79842 Remove the assertion which emits a user-visible exception
(cherry picked from commit 9a0ea6b8c961424dd5008658a1b1ca16067b9a67)

IJ-CR-159269

GitOrigin-RevId: 984a99fae579ce11c44dc5b80d81deddb5b623c9
2025-04-07 21:06:19 +00:00
Andrey Vokin
9c50bed95a PY-78304 Use SoftReference to store types in TypeEvalContext
cleanup


(cherry picked from commit e9b24b1b27c24b29a389d08ede0358cbb33bbe8b)

IJ-MR-158097

GitOrigin-RevId: d6fb90f146e6659f00e37e5c3f9ba000ca3131bd
2025-03-26 15:03:54 +00:00
Andrey Vokin
a25b66ef67 PY-78304 Use SoftReference to store types in TypeEvalContext
Make PyNullType class private


(cherry picked from commit 39c4e6f581c48419c82404944a67de154abd3bf3)

IJ-MR-158097

GitOrigin-RevId: d3f0a4333f0be6ffcd1b4a21c07b3f2a1191feb5
2025-03-26 15:03:54 +00:00
Andrey Vokin
61f2569f6e PY-78304 Use SoftReference to store types in TypeEvalContext
(cherry picked from commit d0e2c405ff0bec6fd9b677a55255929f8100217a)

IJ-MR-158097

GitOrigin-RevId: f6cc0cc6d11e58b6ca897751a0f3f6236e7aae3e
2025-03-26 15:03:54 +00:00
evgeny.bovykin
8a9854b80e 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

(cherry picked from commit 846617f68e559f7f77af15a999f837391ac3090e)

GitOrigin-RevId: f3a8d9ac39955c888647e7186ad4315305a380bb
2025-03-19 18:57:08 +00:00
Aleksandr.Govenko
abe414ffc5 PY-48011 Pattern Matching: Type inference
Merge-request: IJ-MR-154823
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

(cherry picked from commit 42cb07bee63f34127c85574fc9c09e6043bc7591)

IJ-MR-154823

GitOrigin-RevId: 2ad321e755a0efd262c077b2ea2571143ec72600
2025-03-08 03:26:16 +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
Petr
9034b13880 PY-75537 Implement PyAstNamedParameter.getRepr()(PyFrontendElementTypesFacadeImpl.kt)
GitOrigin-RevId: ef38af29fd176324f4c1bec503a116a5b4f351b4
2024-10-16 10:54:46 +00:00
Petr
a1c0baf9c5 PY-75537 Implement PyAstStringLiteralExpression.getStringValue(), PyAstStringLiteralExpression.getStringValueTextRange() (PyFrontendElementTypesFacadeImpl.kt)
GitOrigin-RevId: 372f147a61e07c6cb21aaeb8a7d0f3d14d49417d
2024-10-16 10:54:46 +00:00
Petr
5befce7fb9 PY-75537 Implement PyAstAssignmentStatement.getTargetsToValuesMapping() (PyFrontendElementTypesFacadeImpl.kt)
GitOrigin-RevId: 8c4926689e42f117275986c2e1246d7e04bde489
2024-10-16 10:54:46 +00:00
Mikhail Golubev
33919a56d0 [python] Introduce PyArgumentsMapping.isComplete
GitOrigin-RevId: 64dca74e18a2ae8c4a64f6730093e59dbef6b671
2024-10-15 22:19:26 +00:00
Nikolay Chashnikov
b03b560520 [python] API cleanup: mark deprecated unused API for removal (IJPL-156972)
Deprecated APIs which still have internal usage are marked as internal to ensure that new external usages won't appear.

GitOrigin-RevId: 09818b884851d7b768f8ee0f356f982e79b46ed9
2024-10-10 23:55:42 +00:00
Artem Ivanov
66fb06fcd9 PY-74171 Inherit PyKeywordArgument and PyReferenceExpression from PsiExternalReferenceHost
This allows using Symbol API to create references in PyKeywordArgument or PyReferenceExpression elements.

GitOrigin-RevId: 19545edec1499de66fb7744e7f8e3cb7f4ea85d3
2024-09-13 14:13:53 +00:00
Daniil Kalinin
dd328f3a60 PY-71002 PEP-696: Adapt the interfaces and implementations of Type Parameter types for the support of defaults
In particular:
- Add getters and setters for default types of Type Parameters
- Change the type of declaration elements for Type Parameters from hardcoded PyTargetExpression to PyQualifiedNameOwner to make it possible to set new-style Type Parameters as declaration elements
- Correctly calculate the qualified names of the new-style type alias statements as now they will be used in declaration elements of Type Parameters

GitOrigin-RevId: 5185d85c1a75052dfcb3f97c0eee17b52540d24b
2024-09-07 11:11:12 +00:00
Daniil Kalinin
7751fceaed PY-71002 PEP-696: Support new syntax for default types of Type Parameters in new-style declarations
- PEP-696 adds a new syntax for declaring the default types of Type Parameters in new-new style generic classes, functions and type alias statements. Support these grammar changes.
- Store info about default types in stubs for Type Parameters
- Increment the stub version counter in PyFileElementType

GitOrigin-RevId: b6b22e3eaa86ce06132885781e5775a89bf4b840
2024-09-07 11:11:12 +00:00
Petr
143b893f2c PY-34617 Take into account sys.version_info checks when analyzing Python files
Don't use PyAst* interfaces in PyVersionCheck.kt

GitOrigin-RevId: 6179220a0821a5e93a90938867e842d68ed9f2b0
2024-09-05 11:17:16 +00:00
Petr
db52d4ec3d PY-34617 Take into account sys.version_info checks when analyzing Python files
Support version checks for import statements.

GitOrigin-RevId: df52f60574962e1bc222121aadc082683de0a869
2024-09-05 11:17:15 +00:00
Petr
79dc479c63 PY-34617 Take into account sys.version_info checks when analyzing Python files
Support and, or, <=, > operators in version checks.

GitOrigin-RevId: 5006e88b0f7935d0bf0841dfd5fad5c371e8ff12
2024-09-05 11:17:15 +00:00
somethingnew179
467ea6dd47 PY-34626 Fix isMethodContext to exclude inner functions as methods
closes https://github.com/JetBrains/intellij-community/pull/2811

GitOrigin-RevId: 9268c21cf03158738ca059f8b19c803cb9c368f3
2024-08-26 10:38:00 +00:00
Vladimir Koshelev
8f1f5d99a4 [pycharm] create PyNarrowedType explicitly for TypeGuard and TypeIs PY-74277
GitOrigin-RevId: fe01878d76473c3c149ca520bf7978be49bfd097
2024-08-23 17:26:21 +00:00
Aleksandr.Govenko
9b5b413d45 PY-24044 Evaluate expression and conditional breakpoints should allow adding imports for unresolved names
Added new PyCodeFragmentWithHiddenImports that allows adding imports for unresolved names into a hidden file

GitOrigin-RevId: fb3fa4e491164bdd376d3b25204202034994afa5
2024-08-23 13:37:42 +00:00
Ilia Zakoulov
a15b7f25b8 PY-1751: Introduce getMethodsInherited for PyClass.
This method collects all methods defined in the class and its parents.
Similar to `getPropertiesInherited` and `getClassAttributesInherited`.

GitOrigin-RevId: 8dcec5a002ffa105083ece6f4418d51e6d8c2879
2024-08-14 13:36:59 +00:00
Petr
0020fdc7e9 PY-34617 Take into account sys.version_info checks when analyzing Python files
Added test for version-specific stub elements

GitOrigin-RevId: fde82213359e577cb45006d8a795ec8e44129328
2024-08-13 20:39:16 +00:00
Vladimir Lezhnev
279d23bd2a PY-73911: Delete hardly used three-argument createStringLiteralFromString
GitOrigin-RevId: 0c796ca5ccf8be2c5ac42f2eda80acaf12b770db
2024-08-12 12:33:11 +00:00
Vladimir Lezhnev
3bcabcf4a0 PY-73911: fix "the inserted app is double-quoted" issue
GitOrigin-RevId: e22cadbea69abbfaf312b67bce3a82b9190912b7
2024-08-12 12:33:11 +00:00