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
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
PyKnownDecorator is now a class instead of an enum, allowing extension to create new instances
GitOrigin-RevId: 846617f68e559f7f77af15a999f837391ac3090e
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
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
`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
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
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
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
that indicates types compatible with PyTypeVarTupleType: PyTypeVarTupleType and
PyUnpackedTupleType. It will allow introducing a counterpart interface for types
compatible with PyParamSpecType.
GitOrigin-RevId: 0d5c77dd21d2bc7a21b246cfbd951cdd096918e9
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
Deprecated APIs which still have internal usage are marked as internal to ensure that new external usages won't appear.
GitOrigin-RevId: 09818b884851d7b768f8ee0f356f982e79b46ed9
This allows using Symbol API to create references in PyKeywordArgument or PyReferenceExpression elements.
GitOrigin-RevId: 19545edec1499de66fb7744e7f8e3cb7f4ea85d3
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
- 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
Added new PyCodeFragmentWithHiddenImports that allows adding imports for unresolved names into a hidden file
GitOrigin-RevId: fb3fa4e491164bdd376d3b25204202034994afa5
This method collects all methods defined in the class and its parents.
Similar to `getPropertiesInherited` and `getClassAttributesInherited`.
GitOrigin-RevId: 8dcec5a002ffa105083ece6f4418d51e6d8c2879