diff --git a/mypy/semanal_namedtuple.py b/mypy/semanal_namedtuple.py index b67747d16887..48dd2b868a54 100644 --- a/mypy/semanal_namedtuple.py +++ b/mypy/semanal_namedtuple.py @@ -552,7 +552,10 @@ def add_field( var._fullname = f"{info.fullname}.{var.name}" info.names[var.name] = SymbolTableNode(MDEF, var) - fields = [Var(item, typ) for item, typ in zip(items, types)] + fields = [ + Var(item, self.api.named_type("collections._tuplegetter", [typ])) + for item, typ in zip(items, types) + ] for var in fields: add_field(var, is_property=True) # We can't share Vars between fields and method arguments, since they diff --git a/mypy/test/teststubtest.py b/mypy/test/teststubtest.py index 7925f2a6bd3e..ed5058540fdb 100644 --- a/mypy/test/teststubtest.py +++ b/mypy/test/teststubtest.py @@ -39,6 +39,7 @@ def use_tmp_dir(mod_name: str) -> Iterator[str]: stubtest_typing_stub = """ +import collections Any = object() class _SpecialForm: diff --git a/mypy/typeshed/stdlib/collections/__init__.pyi b/mypy/typeshed/stdlib/collections/__init__.pyi index bc33d91caa1d..28f1a208c766 100644 --- a/mypy/typeshed/stdlib/collections/__init__.pyi +++ b/mypy/typeshed/stdlib/collections/__init__.pyi @@ -32,6 +32,22 @@ _VT = TypeVar("_VT") _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) +# at runtime this class is implemented in _collections, but it considers itself to live in collections since Python 3.12 +@final +class _tuplegetter(Generic[_T]): # undocumented + def __init__(self, index: SupportsIndex, doc: str, /) -> None: ... + def __reduce__(self) -> tuple[type[Self], tuple[int, str]]: ... + if sys.version_info >= (3, 10): + @overload + def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... + @overload + def __get__(self, instance: object, owner: type[Any] | None = None, /) -> _T: ... + else: + @overload + def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ... + @overload + def __get__(self, instance: object, owner: type[Any] | None, /) -> _T: ... + # namedtuple is special-cased in the type checker; the initializer is ignored. def namedtuple( typename: str, diff --git a/mypyc/test-data/annotate-basic.test b/mypyc/test-data/annotate-basic.test index c9e1c4b64a32..b4c89caaa920 100644 --- a/mypyc/test-data/annotate-basic.test +++ b/mypyc/test-data/annotate-basic.test @@ -389,6 +389,7 @@ def good1() -> int: [file nonnative.py] class C: def foo(self) -> None: pass +[typing fixtures/typing-full.pyi] [case testAnnotateGetAttrAndSetAttrBuiltins] def f1(x, s: str): diff --git a/mypyc/test-data/fixtures/typing-full.pyi b/mypyc/test-data/fixtures/typing-full.pyi index d37129bc2e0b..f5ba188e168f 100644 --- a/mypyc/test-data/fixtures/typing-full.pyi +++ b/mypyc/test-data/fixtures/typing-full.pyi @@ -6,6 +6,7 @@ # Many of the definitions have special handling in the type checker, so they # can just be initialized to anything. +import collections from abc import abstractmethod, ABCMeta class GenericMeta(type): pass @@ -175,3 +176,5 @@ class _TypedDict(Mapping[str, object]): class TypeAliasType: pass + +def final(f: T) -> T: pass diff --git a/mypyc/test-data/irbuild-basic.test b/mypyc/test-data/irbuild-basic.test index 4a7d315ec836..69525f6bc92b 100644 --- a/mypyc/test-data/irbuild-basic.test +++ b/mypyc/test-data/irbuild-basic.test @@ -2315,6 +2315,7 @@ L2: r73 = CPyDict_SetItem(r71, r72, r66) r74 = r73 >= 0 :: signed return 1 +[typing fixtures/typing-full.pyi] [case testChainedConditional] def g(x: int) -> int: diff --git a/mypyc/test-data/irbuild-tuple.test b/mypyc/test-data/irbuild-tuple.test index 5c5ec27b1882..7da3761390d6 100644 --- a/mypyc/test-data/irbuild-tuple.test +++ b/mypyc/test-data/irbuild-tuple.test @@ -176,6 +176,7 @@ L2: r2 = CPySequenceTuple_GetItem(nt, 2) r3 = unbox(int, r2) return r3 +[typing fixtures/typing-full.pyi] [case testTupleOperatorIn] diff --git a/mypyc/test-data/run-misc.test b/mypyc/test-data/run-misc.test index 129946a4c330..7b138d1e277d 100644 --- a/mypyc/test-data/run-misc.test +++ b/mypyc/test-data/run-misc.test @@ -728,6 +728,7 @@ def test_named_tuple() -> None: assert type(t) is NT assert isinstance(t, tuple) assert not isinstance(tuple([1]), NT) +[typing fixtures/typing-full.pyi] [case testUnion] from typing import Union diff --git a/mypyc/test-data/run-tuples.test b/mypyc/test-data/run-tuples.test index ea0a1cb8d852..ce1d1a04785d 100644 --- a/mypyc/test-data/run-tuples.test +++ b/mypyc/test-data/run-tuples.test @@ -94,6 +94,7 @@ assert f(NT(3, 2)) == 3 class Sub(NT): pass assert f(Sub(3, 2)) == 3 +[typing fixtures/typing-full.pyi] -- Ref: https://github.com/mypyc/mypyc/issues/924 [case testNamedTupleClassSyntax] @@ -152,6 +153,7 @@ assert Record.__annotations__ == { 'ordering': type, 'extra_int_constants': list, }, Record.__annotations__ +[typing fixtures/typing-full.pyi] [case testTupleOps] from typing import Tuple, Final, List, Any, Optional, cast diff --git a/test-data/unit/check-class-namedtuple.test b/test-data/unit/check-class-namedtuple.test index fe8a1551f81b..727ebaaf3d58 100644 --- a/test-data/unit/check-class-namedtuple.test +++ b/test-data/unit/check-class-namedtuple.test @@ -683,3 +683,52 @@ reveal_type(y) # N: Revealed type is "builtins.int" point.y = 6 # E: Property "y" defined in "Point" is read-only [builtins fixtures/tuple.pyi] + +[case testNamedTupleClassAttributeAccess] +from typing import NamedTuple + +class A(NamedTuple): + x: str + +reveal_type(A.x) # N: Revealed type is "collections._tuplegetter[builtins.str]" +A.x + 3 # E: Unsupported left operand type for + ("_tuplegetter[str]") +A.y # E: "type[A]" has no attribute "y" + +[builtins fixtures/tuple.pyi] + +[case testNamedTupleTupleGetterIsCompatibleWithObject] +from typing import NamedTuple + +class A(NamedTuple): + x: str = "x" + +a: object = A.x +b: int = A.x # E: Incompatible types in assignment (expression has type "_tuplegetter[str]", variable has type "int") +[builtins fixtures/tuple.pyi] + +[case testNamedTupleTupleGetterNested] +from typing import NamedTuple + +class Inner(NamedTuple): + x: int + +class Outer(NamedTuple): + y: Inner + +reveal_type(Inner.x) # N: Revealed type is "collections._tuplegetter[builtins.int]" +reveal_type(Outer.y) # N: Revealed type is "collections._tuplegetter[tuple[builtins.int, fallback=__main__.Inner]]" +[builtins fixtures/tuple.pyi] + +[case testNamedTupleTupleGetterGeneric] +from typing import Generic +from typing import NamedTuple +from typing import TypeVar + +T = TypeVar("T") + +class GenericTuple(NamedTuple, Generic[T]): + x: T + +reveal_type(GenericTuple.x) # E: Access to generic instance variables via class is ambiguous \ + # N: Revealed type is "collections._tuplegetter[Any]" +[builtins fixtures/tuple.pyi] diff --git a/test-data/unit/check-expressions.test b/test-data/unit/check-expressions.test index 33271a3cc04c..536133096868 100644 --- a/test-data/unit/check-expressions.test +++ b/test-data/unit/check-expressions.test @@ -2159,7 +2159,7 @@ class Custom(Base): Base(int()) == int() # E: Non-overlapping equality check (left operand type: "Base", right operand type: "int") Base(int()) == tuple() Custom(int()) == int() -[builtins fixtures/bool.pyi] +[builtins fixtures/tuple.pyi] [case testCustomEqCheckStrictEqualityMeta] # flags: --strict-equality diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index 4c170ec4753f..92bce39a3d32 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -3715,8 +3715,8 @@ cache_fine_grained = False [file mypy.ini.2] \[mypy] cache_fine_grained = True -[rechecked _typeshed, a, builtins, typing] -[stale _typeshed, a, builtins, typing] +[rechecked _typeshed, a, builtins, collections, typing] +[stale _typeshed, a, builtins, collections, typing] [builtins fixtures/tuple.pyi] [case testIncrementalPackageNameOverload] @@ -3767,8 +3767,8 @@ Signature: 8a477f597d28d172789f06886806bc55 [file b.py.2] # uh -- Every file should get reloaded, since the cache was invalidated -[stale _typeshed, a, b, builtins, typing] -[rechecked _typeshed, a, b, builtins, typing] +[stale _typeshed, a, b, builtins, collections, typing] +[rechecked _typeshed, a, b, builtins, collections, typing] [builtins fixtures/tuple.pyi] [case testIncrementalBustedFineGrainedCache2] @@ -3780,8 +3780,8 @@ import b [file b.py.2] # uh -- Every file should get reloaded, since the settings changed -[stale _typeshed, a, b, builtins, typing] -[rechecked _typeshed, a, b, builtins, typing] +[stale _typeshed, a, b, builtins, collections, typing] +[rechecked _typeshed, a, b, builtins, collections, typing] [builtins fixtures/tuple.pyi] [case testIncrementalBustedFineGrainedCache3] @@ -3796,8 +3796,8 @@ import b [file b.py.2] # uh -- Every file should get reloaded, since the cache was invalidated -[stale _typeshed, a, b, builtins, typing] -[rechecked _typeshed, a, b, builtins, typing] +[stale _typeshed, a, b, builtins, collections, typing] +[rechecked _typeshed, a, b, builtins, collections, typing] [builtins fixtures/tuple.pyi] [case testIncrementalWorkingFineGrainedCache] diff --git a/test-data/unit/check-narrowing.test b/test-data/unit/check-narrowing.test index 7fffd3ce94e5..1fa6de7cca02 100644 --- a/test-data/unit/check-narrowing.test +++ b/test-data/unit/check-narrowing.test @@ -78,7 +78,7 @@ if x5["key"] == "A": reveal_type(x5) # N: Revealed type is "TypedDict('__main__.TypedDict1', {'key': Literal['A'], 'foo': builtins.int})" else: reveal_type(x5) # N: Revealed type is "TypedDict('__main__.TypedDict2', {'key': Literal['B'], 'foo': builtins.str})" -[builtins fixtures/primitives.pyi] +[builtins fixtures/tuple.pyi] [typing fixtures/typing-typeddict.pyi] [case testNarrowingParentWithEnumsBasic] diff --git a/test-data/unit/deps-classes.test b/test-data/unit/deps-classes.test index a8fc5d629491..e10923a76b96 100644 --- a/test-data/unit/deps-classes.test +++ b/test-data/unit/deps-classes.test @@ -24,6 +24,7 @@ class A: pass -> m.f -> , , m -> m + -> , , m [case testNamedTuple2] from typing import NamedTuple, Any, Tuple @@ -45,6 +46,7 @@ class B: pass -> , , m -> , , m -> m + -> , , m [case testNamedTuple3] from typing import NamedTuple @@ -62,6 +64,7 @@ y = M(x) -> , , , , m -> m -> m + -> , , , , m [case testNamedTuple4] from typing import NamedTuple, Any diff --git a/test-data/unit/deps-types.test b/test-data/unit/deps-types.test index 7642e6d7a14c..d95fa5a44386 100644 --- a/test-data/unit/deps-types.test +++ b/test-data/unit/deps-types.test @@ -812,6 +812,7 @@ class I: pass [out] -> m -> m + -> , , m -> a -> a -> , , m, a, mod.I diff --git a/test-data/unit/fine-grained.test b/test-data/unit/fine-grained.test index 503135d901f8..ced43f577d77 100644 --- a/test-data/unit/fine-grained.test +++ b/test-data/unit/fine-grained.test @@ -8685,7 +8685,7 @@ m.py:4: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#varia == m.py:4: error: Variable "a.A" is not valid as a type m.py:4: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases -m.py:5: note: Revealed type is "Any" +m.py:5: note: Revealed type is "collections._tuplegetter[Any]" m.py:7: note: Revealed type is "Any" [case testAliasForwardFunctionDirect] @@ -9345,7 +9345,7 @@ def bar(self): def f() -> int: pass [file b.py.2] def f() -> str: pass -[builtins fixtures/classmethod.pyi] +[builtins fixtures/tuple.pyi] [out] == diff --git a/test-data/unit/fixtures/callable.pyi b/test-data/unit/fixtures/callable.pyi index 44abf0691ceb..63e21c3149fe 100644 --- a/test-data/unit/fixtures/callable.pyi +++ b/test-data/unit/fixtures/callable.pyi @@ -1,3 +1,4 @@ +import collections from typing import Generic, Tuple, TypeVar, Union T = TypeVar('T') diff --git a/test-data/unit/fixtures/classmethod.pyi b/test-data/unit/fixtures/classmethod.pyi index 97e018b1dc1c..7efc8fe8460f 100644 --- a/test-data/unit/fixtures/classmethod.pyi +++ b/test-data/unit/fixtures/classmethod.pyi @@ -1,3 +1,4 @@ +import collections import typing _T = typing.TypeVar('_T') diff --git a/test-data/unit/fixtures/dict-full.pyi b/test-data/unit/fixtures/dict-full.pyi index f20369ce9332..9f46d20e0c90 100644 --- a/test-data/unit/fixtures/dict-full.pyi +++ b/test-data/unit/fixtures/dict-full.pyi @@ -1,5 +1,6 @@ # Builtins stub used in dictionary-related test cases (more complete). +import collections from _typeshed import SupportsKeysAndGetItem import _typeshed from typing import ( diff --git a/test-data/unit/fixtures/dict.pyi b/test-data/unit/fixtures/dict.pyi index ed2287511161..1e66f6996f9b 100644 --- a/test-data/unit/fixtures/dict.pyi +++ b/test-data/unit/fixtures/dict.pyi @@ -3,6 +3,7 @@ # NOTE: Use dict-full.pyi if you need more builtins instead of adding here, # if feasible. +import collections from _typeshed import SupportsKeysAndGetItem import _typeshed from typing import ( diff --git a/test-data/unit/fixtures/for.pyi b/test-data/unit/fixtures/for.pyi index 80c8242c2a5e..1bcc50a24093 100644 --- a/test-data/unit/fixtures/for.pyi +++ b/test-data/unit/fixtures/for.pyi @@ -1,5 +1,6 @@ # builtins stub used in for statement test cases +import collections from typing import TypeVar, Generic, Iterable, Iterator, Generator from abc import abstractmethod, ABCMeta diff --git a/test-data/unit/fixtures/isinstance.pyi b/test-data/unit/fixtures/isinstance.pyi index 12cef2035c2b..10716040ce7b 100644 --- a/test-data/unit/fixtures/isinstance.pyi +++ b/test-data/unit/fixtures/isinstance.pyi @@ -1,3 +1,4 @@ +import collections from typing import Tuple, TypeVar, Generic, Union, cast, Any, Type T = TypeVar('T') diff --git a/test-data/unit/fixtures/isinstancelist.pyi b/test-data/unit/fixtures/isinstancelist.pyi index 0ee5258ff74b..5b90b8c9766a 100644 --- a/test-data/unit/fixtures/isinstancelist.pyi +++ b/test-data/unit/fixtures/isinstancelist.pyi @@ -1,3 +1,4 @@ +import collections from typing import ( Iterable, Iterator, TypeVar, List, Mapping, overload, Tuple, Set, Union, Generic, Sequence ) diff --git a/test-data/unit/fixtures/len.pyi b/test-data/unit/fixtures/len.pyi index ee39d952701f..28e990df820a 100644 --- a/test-data/unit/fixtures/len.pyi +++ b/test-data/unit/fixtures/len.pyi @@ -1,3 +1,4 @@ +import collections from typing import Tuple, TypeVar, Generic, Union, Type, Sequence, Mapping from typing_extensions import Protocol diff --git a/test-data/unit/fixtures/list-simple.pyi b/test-data/unit/fixtures/list-simple.pyi new file mode 100644 index 000000000000..e6da7d6d9cd1 --- /dev/null +++ b/test-data/unit/fixtures/list-simple.pyi @@ -0,0 +1,16 @@ +# Builtins stub used in list-related test cases. +# +# This is a simpler version of list.pyi + +from typing import Sequence, TypeVar + +T = TypeVar('T') + +class object: + def __init__(self) -> None: pass + +class list(Sequence[T]): pass +class type: pass +class int: pass +class str: pass +class dict: pass diff --git a/test-data/unit/fixtures/list.pyi b/test-data/unit/fixtures/list.pyi index 3dcdf18b2faa..07d72b93141c 100644 --- a/test-data/unit/fixtures/list.pyi +++ b/test-data/unit/fixtures/list.pyi @@ -1,5 +1,6 @@ # Builtins stub used in list-related test cases. +import collections from typing import TypeVar, Generic, Iterable, Iterator, Sequence, overload T = TypeVar('T') diff --git a/test-data/unit/fixtures/property.pyi b/test-data/unit/fixtures/property.pyi index 933868ac9907..3920d5a91d68 100644 --- a/test-data/unit/fixtures/property.pyi +++ b/test-data/unit/fixtures/property.pyi @@ -1,3 +1,4 @@ +import collections import typing _T = typing.TypeVar('_T') diff --git a/test-data/unit/fixtures/slice.pyi b/test-data/unit/fixtures/slice.pyi index b22a12b5213f..0c1136289f31 100644 --- a/test-data/unit/fixtures/slice.pyi +++ b/test-data/unit/fixtures/slice.pyi @@ -1,4 +1,5 @@ # Builtins stub used in slicing test cases. +import collections from typing import Generic, TypeVar T = TypeVar('T') diff --git a/test-data/unit/fixtures/tuple.pyi b/test-data/unit/fixtures/tuple.pyi index d01cd0034d26..09ae0309e53a 100644 --- a/test-data/unit/fixtures/tuple.pyi +++ b/test-data/unit/fixtures/tuple.pyi @@ -1,7 +1,8 @@ # Builtins stub used in tuple-related test cases. +import collections import _typeshed -from typing import Iterable, Iterator, TypeVar, Generic, Sequence, Optional, overload, Tuple, Type, Self +from typing import Iterable, Iterator, TypeVar, Generic, Sequence, Optional, overload, Tuple, Self _T = TypeVar("_T") _Tco = TypeVar('_Tco', covariant=True) @@ -9,12 +10,13 @@ _Tco = TypeVar('_Tco', covariant=True) class object: def __init__(self) -> None: pass def __new__(cls) -> Self: ... + def __eq__(self, other: object) -> bool: pass class type: def __init__(self, *a: object) -> None: pass def __call__(self, *a: object) -> object: pass class tuple(Sequence[_Tco], Generic[_Tco]): - def __new__(cls: Type[_T], iterable: Iterable[_Tco] = ...) -> _T: ... + def __new__(cls: type[_T], iterable: Iterable[_Tco] = ...) -> _T: ... def __iter__(self) -> Iterator[_Tco]: pass def __contains__(self, item: object) -> bool: pass @overload diff --git a/test-data/unit/lib-stub/collections.pyi b/test-data/unit/lib-stub/collections.pyi index 7ea264f764ee..52cc5435714c 100644 --- a/test-data/unit/lib-stub/collections.pyi +++ b/test-data/unit/lib-stub/collections.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Union, Dict, TypeVar, Optional, Callable, Generic, Sequence, MutableMapping +from typing import Any, Iterable, Union, Dict, TypeVar, Optional, Callable, Generic, Sequence, MutableMapping, overload def namedtuple( typename: str, @@ -23,3 +23,9 @@ class Counter(Dict[KT, int], Generic[KT]): ... class deque(Sequence[KT], Generic[KT]): ... class ChainMap(MutableMapping[KT, VT], Generic[KT, VT]): ... + +class _tuplegetter(Generic[KT]): + @overload + def __get__(self, instance: None, owner: type[Any]) -> _tuplegetter[KT]: ... + @overload + def __get__(self, instance: object, owner: type[Any]) -> KT: ... diff --git a/test-data/unit/merge.test b/test-data/unit/merge.test index 7463571b76b4..d58ddf649c4b 100644 --- a/test-data/unit/merge.test +++ b/test-data/unit/merge.test @@ -680,7 +680,7 @@ TypeInfo<2>( _make<17> _replace<18> _source<19> (builtins.str<8>) - x<20> (target.A<0>))) + x<20> (collections._tuplegetter[target.A<0>]<21>))) ==> TypeInfo<0>( Name(target.A) @@ -704,8 +704,8 @@ TypeInfo<2>( _make<17> _replace<18> _source<19> (builtins.str<8>) - x<20> (target.A<0>) - y<21> (target.A<0>))) + x<20> (collections._tuplegetter[target.A<0>]<21>) + y<22> (collections._tuplegetter[target.A<0>]<21>))) [case testNamedTupleOldVersion_typeinfo] import target @@ -740,7 +740,7 @@ TypeInfo<2>( _make<16> _replace<17> _source<18> (builtins.str<8>) - x<19> (target.A<0>))) + x<19> (collections._tuplegetter[target.A<0>]<20>))) ==> TypeInfo<0>( Name(target.A) @@ -763,8 +763,8 @@ TypeInfo<2>( _make<16> _replace<17> _source<18> (builtins.str<8>) - x<19> (target.A<0>) - y<20> (target.A<0>))) + x<19> (collections._tuplegetter[target.A<0>]<20>) + y<21> (collections._tuplegetter[target.A<0>]<20>))) [case testUnionType_types] import target diff --git a/test-data/unit/typexport-basic.test b/test-data/unit/typexport-basic.test index 77e7763824d6..706d1632d396 100644 --- a/test-data/unit/typexport-basic.test +++ b/test-data/unit/typexport-basic.test @@ -684,14 +684,14 @@ NameExpr(5) : def (a: A[C]) -> B[A[C]] from typing import List a = [] # type: List[A] class A: pass -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] ListExpr(2) : builtins.list[A] [case testInferGenericTypeInTypeAnyContext] from typing import Any a = [] # type: Any -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] ListExpr(2) : builtins.list[Any] @@ -706,7 +706,7 @@ def f(a: A) -> B: pass map( f, [A()]) -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] CallExpr(8) : builtins.list[B] NameExpr(8) : def (f: def (A) -> B, a: builtins.list[A]) -> builtins.list[B] @@ -754,7 +754,7 @@ f = lambda x: [] # type: Callable[[B], List[A]] class A: pass class B: a = None # type: A -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] LambdaExpr(2) : def (x: B) -> builtins.list[A] ListExpr(2) : builtins.list[A] @@ -770,7 +770,7 @@ def f(a: A) -> B: pass l = None # type: List[A] map( lambda x: f(x), l) -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] CallExpr(9) : builtins.list[B] NameExpr(9) : def (f: def (A) -> B, a: builtins.list[A]) -> builtins.list[B] @@ -792,7 +792,7 @@ def f(a: A) -> B: pass l = None # type: List[A] map( lambda x: [f(x)], l) -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] NameExpr(10) : def (f: def (A) -> builtins.list[B], a: builtins.list[A]) -> builtins.list[B] LambdaExpr(11) : def (x: A) -> builtins.list[B] @@ -811,7 +811,7 @@ l = None # type: List[A] map( [lambda x: x], l) -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] -- TODO We probably should not silently infer 'Any' types in statically typed -- context. Perhaps just fail instead? @@ -834,7 +834,7 @@ l = None # type: List[A] map( lambda x: x.b, l) -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] CallExpr(9) : builtins.list[B] NameExpr(9) : def (f: def (A) -> B, a: builtins.list[A]) -> builtins.list[B] @@ -855,7 +855,7 @@ l = None # type: List[A] map( a=l, f=lambda x: x.b) -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] CallExpr(9) : builtins.list[B] NameExpr(9) : def (f: def (A) -> B, a: builtins.list[A]) -> builtins.list[B] @@ -877,7 +877,7 @@ a = a or [] if int(): a = [] or a class A: pass -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] ListExpr(3) : builtins.list[A] NameExpr(3) : builtins.list[A] @@ -1154,7 +1154,7 @@ def m(fun: Callable[[T], V], iter: List[T]) -> None: pass nums = [1] # type: List[int] m(fun, nums) -[builtins fixtures/list.pyi] +[builtins fixtures/list-simple.pyi] [out] IntExpr(13) : Literal[1]? ListExpr(13) : builtins.list[builtins.int]