- is not yet applied at call-sites
(cherry picked from commit ce966e6b5d9abe33d7e51f95e4e7083fcd76ecc7)
GitOrigin-RevId: 69bb2e09a9ab4fa447c8ec4b23d48cd4b807e419
The issue was highlighted by the following semantics:
`Enum`'s metaclass is `EnumMeta` and implements iterable protocol as
```
def __iter__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ...
```
Thus, we need to correctly bind the actual type of `Enum` implementation we're working with (say, `MyEnum`) to `_EnumMemberT` to be able to infer `Iterator[MyEnum]` and then get the correct type of e.g., `set(MyEnum)`
(cherry picked from commit 53b26f963bdf8746c1f8fde5ee41aa37c415d920)
(cherry picked from commit b0ce2298ae6a3e4706b55a56a6ba357ae9f6470d)
IJ-CR-196674
GitOrigin-RevId: 49990c2629af7a8674a8db52eee1cb6751b9343a
These changes provide correct handling of protocol methods defined in metaclasses.
Such methods have the highest priority when operating on class objects, even if the class inherits a direct implementation of the protocol, e.g., Iterable
(cherry picked from commit 1556c15d2b78dfe8f02797862d75e24462b637de)
(cherry picked from commit 89676de48b29d89219898b3d99f08f3e4f27863d)
IJ-CR-196674
GitOrigin-RevId: d75ebf09bd9676094c07d3ec1a2de6017675bce5
- Convert PyModuleService (abstract class) to Kotlin interface
- Convert PyModuleServiceImpl to Kotlin with project-level scope
- Change from application-level to project-level service
- Add findPythonSdkWaitingForProjectModel suspend method that awaits
JPS project model loading before resolving the SDK
- Mark old findPythonSdk as @ApiStatus.Obsolete
- Update all call sites to use getInstance(project)
(cherry picked from commit 4dc39a57dbc6063d37522fac8befe01329c10cde)
GitOrigin-RevId: 529405c76d8e2fa503ccc40e15dd0834dd59f469
Before, `PyAstFile.hasImportFromFuture` collected all `PyFromImportStatement`s using `PyFileImpl.collectChildren`. `PyFileImpl.collectChildren` evaluates static if-conditions (using `PyTypeCheckedElementVisitor.visitPyIfStatement`), which, in presense of a string literal inside if-condition, formed a cycle:
`PyAstFile.hasImportFromFuture()` -> `PyFileImpl.collectChildren()` -> `PyEvaluator.evaluateAsBooleanNoResolve()` -> `PyAstStringLiteralExpression.getStringValue()` -> `PyStringLiteralDecoder.isUnicodeByDefault` -> `PyAstFile.hasImportFromFuture()`
Now `PyAstFile.hasImportFromFuture()` does not collect all `PyFromImportStatement`s. According to spec, only imports at the beginning of a file can be future statements.
(cherry picked from commit bd6b7d73c173954e5cfa0203d9b01931267dea58)
GitOrigin-RevId: 6063a73df368863699388c318bf6bf4e6da00413
- document `PyAnyType`
- remove wildcards from `PyType` methods
- revert `PyTypeUtil.notNullToRef` to a function
GitOrigin-RevId: 4ba489184c466e57b28a149fb39c9858c5070f80
See IJPL-115436 for more info
(cherry picked from commit 6c300e982830c5cd70d501763daf6b2087b51c64)
GitOrigin-RevId: 5d47cdd2da551fbc44040418ff8613c4c4d4580a
Replace the LocalInspectionTool-based "no interpreter" warning with an
EditorNotificationProvider banner. This extends coverage to pyproject.toml
and README.md files (in addition to .py files) and simplifies the fix
architecture.
Key changes:
- Delete PyInterpreterInspection, replace with PyInterpreterNotificationProvider
- Add PyInterpreterNotificationFileOpenedListener for split-editor timing
- Replace LocalQuickFix with a simpler InterpreterFix interface (no ProblemDescriptor)
- Simplify PyAsyncFileInspectionRunner: use refreshAfterWrite for flicker-free
cache refresh, use EditorNotifications instead of DaemonCodeAnalyzer
- Remove PyInterpreterInspectionSuppressor (no longer needed without inspection)
- Add isPythonModule check for the module
- Move bundle keys from PyPsiBundle to PyBundle with python.sdk.* prefix
- Extract CONFIGURABLE_ID constant in PyActiveSdkModuleConfigurable
IJ-MR-192977
(cherry picked from commit 6b3584d6c6beac53f4b8f0abb9a34e698b4ad03f)
GitOrigin-RevId: 1df48bbfbade2f7f31ffae7b02a0cab2f1f68389
Support a mechanism for recommending a tool installation if we're
confident it should be used for SDK configuration. For now, it only
supports uv (with uv.lock check).
It also fixes PY-87744, since we dropped all usages of PyDetectedSdk in
our SDK configurators.
GitOrigin-RevId: f99a1089025079313db9aae09e3cfc0205e7e37f
Turns out there are still problems with handling explicit Any as a type argument.
Namely, after matching `Iterable[T@Iterable]` with `Iterable[Any]`, we don't retain
the mapping `T@Iterable -> Any` in PyTypeChecker.MatchContext#mySubstitutions.
It doesn't hit during handling of generic calls because in cases like the following
```python
from typing import Any
def first[T](xs: list[T]) -> T | None:
...
xs: list[Any]
expr = first(xs)
```
we forcibly replace unbound `T@first` in the result type with Any in
PyTypeChecker.getSubstitutionsWithUnresolvedReturnGenerics, hence masking
the underlying issue. I temporarily extended this approach to `convertToType`.
Specializing all type parameters through CSP should help with that.
(cherry picked from commit 111c6c0d0a15fd290de6df7388e9f6ada70cf998)
GitOrigin-RevId: 0777fdac0034d04dfec517f970aa91fa7d6eba6a