Support | syntax for python unions.
Also support type | None as a new style for Optional.
Fix highlighting unresolved reference issues with | syntax.
Type inference from isinstance and issubclass.
Add quick fix to switch to old-style syntax in earlier python versions (<3.10)
Fix quick documentation to render new syntax.
(cherry picked from commit 6a64ee12c2d8503a0ef102e8b67cb0b95ce77999)
IJ-MR-8400
GitOrigin-RevId: c26b868fc61f26936a3316ec06f78b66d75f6857
Previously, we looked only for __init__.py to detect re-exported names,
ignoring __init__.pyi that could be used for the same purpose in stub
packages.
GitOrigin-RevId: 48bc58789e47d5b9fb814b99722371fdd670ee2d
It will fix PyTypeTest.testListTypeByModificationsConstructor and PyTypeTest.testDictTypeByModificationConstructor.
Callee has been resolved to overloads for a long time, it's better to filter out unmatched ones instead of calculating the same call type for every overload. Implemented in PyCallExpressionHelper.
Unify inferring call type for subscriptions and calls.
Union types order in test data has been changed since named elements are collected in reversed order in py files.
Repeat PyTypeTest.testCallableInUnion behaviour in PyTypeTest.testSubscriptionOnWeakType.
PyCallExpressionHelper.forEveryScopeTakeOverloadsOtherwiseImplementations has been updated to preserve elements order.
GitOrigin-RevId: f88eacd0a36dd5fbc59447db9dd4484d5a000bc8
Forward references resolution implemented for annotations according to
PEP 563. Inspections fixed to respect forward references for both
annotations and pyi stubs.
PyiReferenceResolveProvider removed since its functionality is now
implemented by PyForwardReferenceResolveProvider.
We used to exclude all the Any types from matched overloads even though
the match was successful. Now we stop analyzing an overload immediately
when the actual arguments don't match against its parameters.
Update registering type checking problems for binary expressions:
* prefer left operators over right ones
* in case of one operator register problem in the old way
* in case of some operators register problem on the left or right argument
Update multi-callee problem registration in PyTypeCheckerInspection:
* drop callees with unmapped arguments or unfilled parameters
* in case of one callee show message in old way
* in case of some callees show message with actual types and possible sets of them
It's their responsibility to provide the final return type for a function.
Only inferred (i.e. when there's no additional type hints) return value
types should be postprocessed like that in order to get not the
immediate type of values in return statements but the properly
parametrized special type from typing for genetators and coroutines.
Otherwise, we might end up returning something like
Coroutine[Coroutine[int]] for coroutines annotated using .pyi stubs,
because we don't take into account that PyiTypeProvider already
wraps the return type from the stub's annotation in typing.Coroutine.
In particular, show unresolved refernces in generic bounds as Any.
We used to ignore these unresolved types which resulted in
incomprehensible warning messages.
This is necessary for @typing.overload.
Removed specialized code to check the default values of parameters
for NumPy as bad for performance (stubs->AST for every function with
default values). We'll replace it with another workaround.
The test of overloads in Python stubs still fails since this union
type isn't used when analyzing function calls and matching arguments
against formal parameters.
The provider is similar to PyUserSkeletonsTypeProvider. Currently it
searches for stubs only next to the original Python files. It provides
types of function parameters, function return types, function types,
target expression types.