mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
_T_co in itertools.product declaration in Typeshed used to be imported from _typeshed/__init__.pyi stub and was not resolved as a name starting with an underscore. Nonetheless, its method __next__ was still recognized as generic because _T_co used in typing.Iterable.__next__ was used instead thanks to PyAncestorsTypeProvider. In other words, we inferred a TypeVar as a return type of a method of a non-generic class. It led to retaining this TypeVar as-is (not replaced) after substitution and SOE further down the road. Ideally, the same should be done for other places where type hints can be used, e.g. if a local variable has an explicit annotation, even an unresolved one, no other type sources should be examined. Unfortunately, it's not as straightforward for variables and parameters since their annotations sometimes don't contain a type, e.g. x: Literal = 5, or x: Final = 5. It means that we need to distinguish somehow between the cases "incorrect annotation, use Any" and "this annotation requires further inference for the assigned value", and our API doesn't allow to express that at the moment. GitOrigin-RevId: 1bba57bb38718bcab7778049a91d5cbffb5e87c2
6 lines
79 B
Python
6 lines
79 B
Python
class A():
|
|
def some_method(self) -> int:
|
|
pass
|
|
|
|
class B(A):
|
|
pass |