From 43d34139975516d3cb85f2fd56a80f5f02c000c2 Mon Sep 17 00:00:00 2001 From: Ali Hamdan Date: Sat, 29 Aug 2026 10:56:49 +0200 Subject: [PATCH] Replace `builtins.ellipsis` with `types.EllipsisType` Part of #8240 --- mypy/checkexpr.py | 6 +++- mypy/test/testexportjson.py | 1 + mypy/test/teststubtest.py | 2 +- mypy/test/visitors.py | 16 ++++++++- mypyc/test-data/fixtures/ir.py | 3 +- test-data/unit/check-basic.test | 4 +-- test-data/unit/check-classes.test | 2 +- test-data/unit/check-enum.test | 12 +++---- test-data/unit/check-expressions.test | 4 +-- test-data/unit/check-flags.test | 8 ++--- test-data/unit/check-incomplete-fixture.test | 2 +- test-data/unit/check-incremental.test | 12 +++---- test-data/unit/check-modules-fast.test | 2 +- test-data/unit/check-modules.test | 24 +++++++------- test-data/unit/check-redefine.test | 2 +- test-data/unit/check-typeform.test | 1 - test-data/unit/check-unions.test | 3 +- test-data/unit/check-unreachable-code.test | 2 +- test-data/unit/check-vec.test | 3 +- test-data/unit/exportjson.test | 33 ------------------- test-data/unit/fine-grained-modules.test | 9 ++--- test-data/unit/fine-grained.test | 10 +++--- test-data/unit/fixtures/args.pyi | 2 +- test-data/unit/fixtures/async_await.pyi | 2 +- test-data/unit/fixtures/bool.pyi | 2 +- test-data/unit/fixtures/callable.pyi | 2 +- test-data/unit/fixtures/classmethod.pyi | 2 +- test-data/unit/fixtures/complex_tuple.pyi | 2 +- test-data/unit/fixtures/dataclasses.pyi | 2 +- test-data/unit/fixtures/dict-full.pyi | 2 +- test-data/unit/fixtures/dict.pyi | 2 +- test-data/unit/fixtures/divmod.pyi | 2 +- test-data/unit/fixtures/enum.pyi | 2 +- test-data/unit/fixtures/exception.pyi | 2 +- test-data/unit/fixtures/f_string.pyi | 2 +- test-data/unit/fixtures/fine_grained.pyi | 1 - test-data/unit/fixtures/float.pyi | 4 +-- test-data/unit/fixtures/floatdict.pyi | 2 +- test-data/unit/fixtures/for.pyi | 2 +- .../unit/fixtures/for_else_exception.pyi | 2 +- test-data/unit/fixtures/isinstance.pyi | 2 +- .../unit/fixtures/isinstance_python3_10.pyi | 1 - test-data/unit/fixtures/isinstancelist.pyi | 4 +-- test-data/unit/fixtures/len.pyi | 2 +- test-data/unit/fixtures/list.pyi | 2 +- test-data/unit/fixtures/module.pyi | 3 +- test-data/unit/fixtures/module_all.pyi | 1 - test-data/unit/fixtures/narrowing.pyi | 2 +- test-data/unit/fixtures/notimplemented.pyi | 1 - test-data/unit/fixtures/object_hashable.pyi | 3 +- .../fixtures/object_with_init_subclass.pyi | 2 +- test-data/unit/fixtures/ops.pyi | 2 +- test-data/unit/fixtures/paramspec.pyi | 2 +- test-data/unit/fixtures/plugin_attrs.pyi | 2 +- test-data/unit/fixtures/primitives.pyi | 2 +- test-data/unit/fixtures/property.pyi | 2 +- test-data/unit/fixtures/sentinel.pyi | 2 +- test-data/unit/fixtures/set.pyi | 2 +- test-data/unit/fixtures/slice.pyi | 2 +- test-data/unit/fixtures/staticmethod.pyi | 2 +- test-data/unit/fixtures/tuple-typeshed.pyi | 1 - test-data/unit/fixtures/tuple.pyi | 1 - test-data/unit/fixtures/type.pyi | 1 - test-data/unit/lib-stub/builtins.pyi | 2 +- test-data/unit/lib-stub/types.pyi | 2 ++ test-data/unit/typexport-basic.test | 2 +- 66 files changed, 113 insertions(+), 135 deletions(-) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 172d44555b946..14650b1b5242c 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -3595,7 +3595,11 @@ def visit_complex_expr(self, e: ComplexExpr) -> Type: def visit_ellipsis(self, e: EllipsisExpr) -> Type: """Type check '...'.""" - return self.named_type("builtins.ellipsis") + try: + return self.named_type("types.EllipsisType") + except KeyError: + # In test cases 'types' may not be available or may be shadowed. + return AnyType(TypeOfAny.special_form) def visit_op_expr(self, e: OpExpr) -> Type: """Type check a binary operator expression.""" diff --git a/mypy/test/testexportjson.py b/mypy/test/testexportjson.py index 294befcb3731c..f8cac6e51cf95 100644 --- a/mypy/test/testexportjson.py +++ b/mypy/test/testexportjson.py @@ -59,6 +59,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None: "typing_extensions", "sys", "collections", + "types", ): continue fnam = os.path.join(cache_dir, f"{module}.data.ff") diff --git a/mypy/test/teststubtest.py b/mypy/test/teststubtest.py index 2db149ce65c97..2b54a150892b2 100644 --- a/mypy/test/teststubtest.py +++ b/mypy/test/teststubtest.py @@ -100,6 +100,7 @@ def final(func: _T) -> _T: ... """ stubtest_builtins_stub = """ +import types from typing import Generic, Mapping, Sequence, TypeVar, overload T = TypeVar('T') @@ -121,7 +122,6 @@ class dict(Mapping[KT, VT]): ... class frozenset(Generic[T]): ... class function: pass -class ellipsis: pass class int: ... class float: ... diff --git a/mypy/test/visitors.py b/mypy/test/visitors.py index 2b748ec1bdc4a..4d1761b617323 100644 --- a/mypy/test/visitors.py +++ b/mypy/test/visitors.py @@ -8,7 +8,16 @@ from __future__ import annotations -from mypy.nodes import AssignmentStmt, CallExpr, Expression, IntExpr, NameExpr, Node, TypeVarExpr +from mypy.nodes import ( + AssignmentStmt, + CallExpr, + EllipsisExpr, + Expression, + IntExpr, + NameExpr, + Node, + TypeVarExpr, +) from mypy.traverser import TraverserVisitor from mypy.treetransform import TransformVisitor from mypy.types import Type @@ -37,6 +46,11 @@ def visit_int_expr(self, n: IntExpr) -> None: self.nodes.add(n) super().visit_int_expr(n) + def visit_ellipsis(self, n: EllipsisExpr) -> None: + if self.ignore_file: + self.nodes.add(n) + super().visit_ellipsis(n) + def ignore_node(node: Expression) -> bool: """Return True if node is to be omitted from test case output.""" diff --git a/mypyc/test-data/fixtures/ir.py b/mypyc/test-data/fixtures/ir.py index 101c54ad7eff0..928f6b9ac4151 100644 --- a/mypyc/test-data/fixtures/ir.py +++ b/mypyc/test-data/fixtures/ir.py @@ -2,6 +2,7 @@ # test cases. import _typeshed +import types from typing import ( Self, TypeVar, Generic, List, Iterator, Iterable, Dict, Optional, Tuple, Any, Set, overload, Mapping, Union, Callable, Sequence, FrozenSet, Protocol @@ -57,8 +58,6 @@ def __new__(cls, *args: object) -> Any: ... __name__ : str __annotations__: Dict[str, Any] -class ellipsis: pass - # Primitive types are special in generated code. class int: diff --git a/test-data/unit/check-basic.test b/test-data/unit/check-basic.test index cfaff2d636e25..8bd8779def713 100644 --- a/test-data/unit/check-basic.test +++ b/test-data/unit/check-basic.test @@ -461,8 +461,8 @@ def typeddict() -> Sequence[D]: x = [{'x': 0}] # type: List[a.D] return x # E: Incompatible return value type (got "list[a.D]", expected "Sequence[b.D]") -a = (a.A(), A()) -a.x # E: "tuple[a.A, b.A]" has no attribute "x" +a = (a.A(), A()) # E: Incompatible types in assignment (expression has type "tuple[a.A, b.A]", variable has type Module) +a.x # E: Module has no attribute "x" [builtins fixtures/dict.pyi] [typing fixtures/typing-full.pyi] diff --git a/test-data/unit/check-classes.test b/test-data/unit/check-classes.test index 2cd43c74ebb5b..dc5d74abc07df 100644 --- a/test-data/unit/check-classes.test +++ b/test-data/unit/check-classes.test @@ -8593,7 +8593,7 @@ plain_var: int class Foo: import mod -reveal_type(Foo.mod) # N: Revealed type is "builtins.object" +reveal_type(Foo.mod) # N: Revealed type is "types.ModuleType" reveal_type(Foo.mod.foo) # N: Revealed type is "builtins.int" [file mod.py] foo: int diff --git a/test-data/unit/check-enum.test b/test-data/unit/check-enum.test index 20cf3b5aebfbc..7c24f995f4425 100644 --- a/test-data/unit/check-enum.test +++ b/test-data/unit/check-enum.test @@ -2558,7 +2558,7 @@ class Pet(Enum): CAT = ... DOG: str = ... # E: Enum members must be left unannotated \ # N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members \ - # E: Incompatible types in assignment (expression has type "ellipsis", variable has type "str") + # E: Incompatible types in assignment (expression has type "EllipsisType", variable has type "str") [builtins fixtures/enum.pyi] [case testEnumValueWithPlaceholderNodeType] @@ -2736,23 +2736,23 @@ class FromStub(Enum): FOO = ... reveal_type(FromStub.FOO) # N: Revealed type is "Literal[__main__.FromStub.FOO]?" -reveal_type(FromStub.FOO.value) # N: Revealed type is "builtins.ellipsis" +reveal_type(FromStub.FOO.value) # N: Revealed type is "types.EllipsisType" reveal_type(FromStub.FOO._value_) # N: Revealed type is "builtins.int" class InheritedStr(StrEnum): FOO = ... reveal_type(InheritedStr.FOO) # N: Revealed type is "Literal[__main__.InheritedStr.FOO]?" -reveal_type(InheritedStr.FOO.value) # N: Revealed type is "builtins.ellipsis" -reveal_type(InheritedStr.FOO._value_) # N: Revealed type is "builtins.ellipsis" +reveal_type(InheritedStr.FOO.value) # N: Revealed type is "types.EllipsisType" +reveal_type(InheritedStr.FOO._value_) # N: Revealed type is "types.EllipsisType" class Wrapper: class Nested(StrEnum): FOO = ... reveal_type(Wrapper.Nested.FOO) # N: Revealed type is "Literal[__main__.Wrapper.Nested.FOO]?" -reveal_type(Wrapper.Nested.FOO.value) # N: Revealed type is "builtins.ellipsis" -reveal_type(Wrapper.Nested.FOO._value_) # N: Revealed type is "builtins.ellipsis" +reveal_type(Wrapper.Nested.FOO.value) # N: Revealed type is "types.EllipsisType" +reveal_type(Wrapper.Nested.FOO._value_) # N: Revealed type is "types.EllipsisType" [builtins fixtures/enum.pyi] [case testStrEnumEqualityReachability] diff --git a/test-data/unit/check-expressions.test b/test-data/unit/check-expressions.test index 0605c2d8a6fe4..227a471b34c88 100644 --- a/test-data/unit/check-expressions.test +++ b/test-data/unit/check-expressions.test @@ -1660,13 +1660,13 @@ class C(B): a: A if str(): - a = ... # E: Incompatible types in assignment (expression has type "ellipsis", variable has type "A") + a = ... # E: Incompatible types in assignment (expression has type "EllipsisType", variable has type "A") b = ... c = ... if str(): b = c ....__class__ -....a # E: "ellipsis" has no attribute "a" +....a # E: "EllipsisType" has no attribute "a" class A: pass [builtins fixtures/dict-full.pyi] diff --git a/test-data/unit/check-flags.test b/test-data/unit/check-flags.test index acdee2a10430a..831497f4b24a6 100644 --- a/test-data/unit/check-flags.test +++ b/test-data/unit/check-flags.test @@ -552,8 +552,8 @@ x + "" # E: Unsupported operand types for + ("int" and "str") import mod mod.x + 0 mod.x + "" # E: Unsupported operand types for + ("int" and "str") -mod.y # E: "object" has no attribute "y" -mod + 0 # E: Unsupported left operand type for + ("object") +mod.y # E: Module has no attribute "y" +mod + 0 # E: Unsupported left operand type for + (Module) [file mod.py] 1 + "" # E: Unsupported operand types for + ("int" and "str") x = 0 @@ -565,8 +565,8 @@ from mod import x x + "" # E: Unsupported operand types for + ("int" and "str") import mod mod.x + "" # E: Unsupported operand types for + ("int" and "str") -mod.y # E: "object" has no attribute "y" -mod + 0 # E: Unsupported left operand type for + ("object") +mod.y # E: Module has no attribute "y" +mod + 0 # E: Unsupported left operand type for + (Module) [file mod.py] 1 + "" x = 0 diff --git a/test-data/unit/check-incomplete-fixture.test b/test-data/unit/check-incomplete-fixture.test index 146494df1bd6c..cd8f067d06a4f 100644 --- a/test-data/unit/check-incomplete-fixture.test +++ b/test-data/unit/check-incomplete-fixture.test @@ -9,7 +9,7 @@ import m # This used to cause a crash since types.ModuleType is not available # by default. We fall back to 'object' now. -m.x # E: "object" has no attribute "x" +m.x # E: Module has no attribute "x" [file m.py] [case testSetMissingFromStubs] diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index 18931dd9f152f..a3dc8b80d9a2d 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -5546,7 +5546,7 @@ import p.util class N(p.util.Test): ... [out2] -tmp/a.py:2: error: "object" has no attribute "N" +tmp/a.py:2: error: Module has no attribute "N" [case testIncrementalIndirectSkipWarnUnused] # flags: --follow-imports=skip --warn-unused-ignores @@ -5801,7 +5801,7 @@ class C: [builtins fixtures/dict.pyi] [typing fixtures/typing-typeddict.pyi] [out2] -tmp/a.py:2: error: "object" has no attribute "xyz" +tmp/a.py:2: error: Module has no attribute "xyz" [case testIncrementalInvalidNamedTupleInUnannotatedFunction] # flags: --disable-error-code=annotation-unchecked @@ -7553,9 +7553,9 @@ from pkg import submod [file pkg/submod.pyi] def foo() -> None: pass [out] -tmp/a.py:3: error: "object" has no attribute "submod" +tmp/a.py:3: error: Module has no attribute "submod" [out2] -tmp/a.py:3: error: "object" has no attribute "submod" +tmp/a.py:3: error: Module has no attribute "submod" [case testIncrementalAccessSubmoduleWithoutExplicitImportNested] import a @@ -7608,9 +7608,9 @@ from pandas.core.dtypes.dtypes import X [file pandas/core/dtypes/dtypes.py] X = 0 [out] -tmp/a.py:6: error: "object" has no attribute "dtypes" +tmp/a.py:6: error: Module has no attribute "dtypes" [out2] -tmp/a.py:2: error: "object" has no attribute "dtypes" +tmp/a.py:2: error: Module has no attribute "dtypes" [case testStarImportCycleRedefinition] import m diff --git a/test-data/unit/check-modules-fast.test b/test-data/unit/check-modules-fast.test index 875125c6532b3..ab7b767fdd429 100644 --- a/test-data/unit/check-modules-fast.test +++ b/test-data/unit/check-modules-fast.test @@ -41,7 +41,7 @@ a = A() [case testModuleLookupWeird] # flags: --fast-module-lookup from m import a -reveal_type(a) # N: Revealed type is "builtins.object" +reveal_type(a) # N: Revealed type is "types.ModuleType" reveal_type(a.b) # N: Revealed type is "m.a.B" [file m.py] diff --git a/test-data/unit/check-modules.test b/test-data/unit/check-modules.test index e54dea6b31e71..5fba65f276a43 100644 --- a/test-data/unit/check-modules.test +++ b/test-data/unit/check-modules.test @@ -474,13 +474,13 @@ x = ... # type: int [case testEllipsisInitializerInStubFileWithoutType] import m -m.x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "ellipsis") +m.x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "EllipsisType") [file m.pyi] # Ellipsis is only special with a # type: comment (not sure though if this is great) x = ... [case testEllipsisInitializerInModule] -x = ... # type: int # E: Incompatible types in assignment (expression has type "ellipsis", variable has type "int") +x = ... # type: int # E: Incompatible types in assignment (expression has type "EllipsisType", variable has type "int") [case testEllipsisDefaultArgValueInStub] import m @@ -491,7 +491,7 @@ def f(x: int = ...) -> None: pass [case testEllipsisDefaultParamValueInStub2] import m -def f1(x: int = ...) -> int: return 1 # E: Incompatible default for parameter "x" (default has type "ellipsis", parameter has type "int") +def f1(x: int = ...) -> int: return 1 # E: Incompatible default for parameter "x" (default has type "EllipsisType", parameter has type "int") def f2(x: int = '') -> int: return 1 # E: Incompatible default for parameter "x" (default has type "str", parameter has type "int") [file m.pyi] def g1(x: int = ...) -> int: pass @@ -506,11 +506,11 @@ def ok_5(x: int = ...) -> None: """Docstring here""" pass -def bad_1(x: int = ...) -> None: 1 # E: Incompatible default for parameter "x" (default has type "ellipsis", parameter has type "int") -def bad_2(x: int = ...) -> None: # E: Incompatible default for parameter "x" (default has type "ellipsis", parameter has type "int") +def bad_1(x: int = ...) -> None: 1 # E: Incompatible default for parameter "x" (default has type "EllipsisType", parameter has type "int") +def bad_2(x: int = ...) -> None: # E: Incompatible default for parameter "x" (default has type "EllipsisType", parameter has type "int") """Docstring here""" ok_1() -def bad_3(x: int = ...) -> None: # E: Incompatible default for parameter "x" (default has type "ellipsis", parameter has type "int") +def bad_3(x: int = ...) -> None: # E: Incompatible default for parameter "x" (default has type "EllipsisType", parameter has type "int") raise Exception("Some other exception") [builtins fixtures/exception.pyi] @@ -523,7 +523,7 @@ Both = Union[int, str] def foo(x: int, y: int = ...) -> int: ... @overload def foo(x: str, y: str = ...) -> str: ... -def foo(x: Both, y: Both = ...) -> Both: # E: Incompatible default for parameter "y" (default has type "ellipsis", parameter has type "int | str") +def foo(x: Both, y: Both = ...) -> Both: # E: Incompatible default for parameter "y" (default has type "EllipsisType", parameter has type "int | str") return x @overload @@ -543,14 +543,14 @@ class Wrap(Generic[T]): ... class MyProtocol(Protocol): def no_impl(self, x: Wrap[int] = ...) -> int: ... - def default_impl(self, x: Wrap[int] = ...) -> int: return 3 # E: Incompatible default for parameter "x" (default has type "ellipsis", parameter has type "Wrap[int]") + def default_impl(self, x: Wrap[int] = ...) -> int: return 3 # E: Incompatible default for parameter "x" (default has type "EllipsisType", parameter has type "Wrap[int]") class MyAbstractClass: @abstractmethod def no_impl(self, x: Wrap[int] = ...) -> int: raise NotImplementedError @abstractmethod - def default_impl(self, x: Wrap[int] = ...) -> int: return 3 # E: Incompatible default for parameter "x" (default has type "ellipsis", parameter has type "Wrap[int]") + def default_impl(self, x: Wrap[int] = ...) -> int: return 3 # E: Incompatible default for parameter "x" (default has type "EllipsisType", parameter has type "Wrap[int]") [builtins fixtures/exception.pyi] [case testStarImportOverlapping] @@ -687,7 +687,7 @@ try: except: pass -import m as f # E: Incompatible import of "f" (imported name has type "object", local name has type "Callable[[Any], Any]") +import m as f # E: Incompatible import of "f" (imported name has type Module, local name has type "Callable[[Any], Any]") [file m.py] def f(x): pass @@ -702,7 +702,7 @@ Y: Type[mod.B] from mod import B as X from mod import A as Y # E: Incompatible import of "Y" (imported name has type "type[A]", local name has type "type[B]") -import mod as X # E: Incompatible import of "X" (imported name has type "object", local name has type "type[A]") +import mod as X # E: Incompatible import of "X" (imported name has type Module, local name has type "type[A]") [file mod.py] class A: ... @@ -2904,7 +2904,7 @@ from mystery import a, b as b, c as d # E: Cannot find implementation or librar [case testPackagePath] import p reveal_type(p.__path__) # N: Revealed type is "builtins.list[builtins.str]" -p.m.__path__ # E: "object" has no attribute "__path__" +p.m.__path__ # E: Module has no attribute "__path__" [file p/__init__.py] from . import m as m diff --git a/test-data/unit/check-redefine.test b/test-data/unit/check-redefine.test index f21ab805e17f3..9dffd90609543 100644 --- a/test-data/unit/check-redefine.test +++ b/test-data/unit/check-redefine.test @@ -535,7 +535,7 @@ with B() as x: import typing try: pass -except Exception as typing: +except Exception as typing: # E: Incompatible types in assignment (expression has type "Exception", variable has type Module) pass [builtins fixtures/exception.pyi] [typing fixtures/typing-full.pyi] diff --git a/test-data/unit/check-typeform.test b/test-data/unit/check-typeform.test index 220f31b45b512..d16c54a06b66d 100644 --- a/test-data/unit/check-typeform.test +++ b/test-data/unit/check-typeform.test @@ -751,7 +751,6 @@ class dict: pass class str: pass class type: pass class tuple: pass -class ellipsis: pass class BaseException: pass class float: pass [typing fixtures/typing-full.pyi] diff --git a/test-data/unit/check-unions.test b/test-data/unit/check-unions.test index c6db8fea99add..e7a3ccc1c5123 100644 --- a/test-data/unit/check-unions.test +++ b/test-data/unit/check-unions.test @@ -139,10 +139,11 @@ x = 1 x = f() [case testUnionWithEllipsis] +from types import EllipsisType from typing import Union def f(x: Union[int, EllipsisType]) -> int: if x is Ellipsis: - reveal_type(x) # N: Revealed type is "builtins.ellipsis" + reveal_type(x) # N: Revealed type is "types.EllipsisType" x = 1 reveal_type(x) # N: Revealed type is "builtins.int" return x diff --git a/test-data/unit/check-unreachable-code.test b/test-data/unit/check-unreachable-code.test index 330983dab6203..42aa76b4ba951 100644 --- a/test-data/unit/check-unreachable-code.test +++ b/test-data/unit/check-unreachable-code.test @@ -759,7 +759,7 @@ reveal_type('') # No error here :-) [case testUnreachableAfterToplevelAssertImport] import foo -foo.bar() # E: "object" has no attribute "bar" +foo.bar() # E: Module has no attribute "bar" [file foo.py] import sys assert sys.platform == 'lol' diff --git a/test-data/unit/check-vec.test b/test-data/unit/check-vec.test index 03860ee203d78..e087a8b823be9 100644 --- a/test-data/unit/check-vec.test +++ b/test-data/unit/check-vec.test @@ -1,4 +1,5 @@ [case testVecBasics] +from types import EllipsisType from typing import Optional, Any, TypeVar from librt.vecs import vec @@ -30,7 +31,7 @@ vec_object: vec[object] vec_bad_int: vec[int] # E: Invalid item type for "vec" vec_bad_tuple: vec[tuple[int, str]] # E: Invalid item type for "vec" -vec_bad_union: vec[str | ellipsis] # E: Invalid item type for "vec" +vec_bad_union: vec[str | EllipsisType] # E: Invalid item type for "vec" vec_bad_any: vec[Any] # E: Invalid item type for "vec" vec_bad_two_args: vec[i32, i32] # E: Invalid item type for "vec" vec_bad_optional1: vec[int | None] # E: Invalid item type for "vec" diff --git a/test-data/unit/exportjson.test b/test-data/unit/exportjson.test index 3a8508dd39ef1..2d6a8c56b20f7 100644 --- a/test-data/unit/exportjson.test +++ b/test-data/unit/exportjson.test @@ -321,36 +321,3 @@ from typing_extensions import Final "ignore_all": false, "plugin_data": null } -{ - "id": "types", - "path": ..., - "mtime": ..., - "size": 372, - "hash": "7542ae4787693f5598d0e8fc9efe396bd6f9af0c", - "data_mtime": ..., - "dependencies": [ - "typing", - "builtins" - ], - "suppressed": [], - "options": { - "other_options": "", - "platform": ... - }, - "dep_prios": [ - 5, - 5 - ], - "dep_lines": [ - 1, - 1 - ], - "dep_hashes": [ - "", - "" - ], - "interface_hash": "", - "version_id": ..., - "ignore_all": true, - "plugin_data": null -} diff --git a/test-data/unit/fine-grained-modules.test b/test-data/unit/fine-grained-modules.test index 3ee07a03792f8..53ee178557ebf 100644 --- a/test-data/unit/fine-grained-modules.test +++ b/test-data/unit/fine-grained-modules.test @@ -1277,12 +1277,12 @@ a.py:2: error: Too many arguments for "foo" [case testAddModuleAfterCache3-only_when_cache] # cmd: mypy main a.py -# cmd2: mypy main a.py b.py c.py d.py e.py f.py g.py h.py i.py j.py -# cmd3: mypy main a.py b.py c.py d.py e.py f.py g.py h.py i.py j.py +# cmd2: mypy main a.py b.py c.py d.py e.py f.py g.py h.py i.py j.py k.py l.py +# cmd3: mypy main a.py b.py c.py d.py e.py f.py g.py h.py i.py j.py k.py l.py # flags: --ignore-missing-imports --follow-imports=skip import a [file a.py] -import b, c, d, e, f, g, h, i, j +import b, c, d, e, f, g, h, i, j, k, l b.foo(10) [file b.py.2] def foo() -> None: pass @@ -1294,6 +1294,8 @@ def foo() -> None: pass [file h.py.2] [file i.py.2] [file j.py.2] +[file k.py.2] +[file l.py.2] -- No files should be stale or reprocessed in the first step since the large number -- of missing files will force build to give up on cache loading. @@ -2219,7 +2221,6 @@ import foobar [file ts/stdlib/builtins.pyi] class object: pass class str: pass -class ellipsis: pass [file ts/stdlib/sys.pyi] [file ts/stdlib/types.pyi] [file ts/stdlib/typing.pyi] diff --git a/test-data/unit/fine-grained.test b/test-data/unit/fine-grained.test index ef2e8c0b343bf..d6e7b3e352e83 100644 --- a/test-data/unit/fine-grained.test +++ b/test-data/unit/fine-grained.test @@ -493,7 +493,7 @@ x = 3 == == == -a.py:3: error: "object" has no attribute "whatever" +a.py:3: error: Module has no attribute "whatever" [case testAddedIgnoreWithMissingImports] import a @@ -2654,7 +2654,7 @@ from typing import Generic, TypeVar T = TypeVar('T') class C(Generic[T]): pass [out] -main:4: error: "object" has no attribute "C" +main:4: error: Module has no attribute "C" == main:4: error: Need type annotation for "x" @@ -11854,7 +11854,7 @@ def loads() -> None: ... [file pkg/sub.pyi.2] [out] == -main:3: error: "object" has no attribute "loads" +main:3: error: Module has no attribute "loads" [case testStarExportedNameDeleted2] import pkg @@ -11870,7 +11870,7 @@ class C: pass [file pkg/sub.pyi.2] [out] == -main:3: error: "object" has no attribute "C" +main:3: error: Module has no attribute "C" [case testStarExportedNameDeleted3] from pkg import loads @@ -11902,7 +11902,7 @@ x = 1 [file pkg/sub.pyi.2] [out] == -main:3: error: "object" has no attribute "x" +main:3: error: Module has no attribute "x" [case testStarExportedNameDeleted5] from pkg import sub diff --git a/test-data/unit/fixtures/args.pyi b/test-data/unit/fixtures/args.pyi index 0020d9ceff468..724a9f530062c 100644 --- a/test-data/unit/fixtures/args.pyi +++ b/test-data/unit/fixtures/args.pyi @@ -1,6 +1,7 @@ # Builtins stub used to support *args, **kwargs. import _typeshed +import types from typing import TypeVar, Generic, Iterable, Sequence, Tuple, Dict, Any, overload, Mapping Tco = TypeVar('Tco', covariant=True) @@ -32,4 +33,3 @@ class str: pass class bytes: pass class bool: pass class function: pass -class ellipsis: pass diff --git a/test-data/unit/fixtures/async_await.pyi b/test-data/unit/fixtures/async_await.pyi index 96ade881111b3..5076dcaee4157 100644 --- a/test-data/unit/fixtures/async_await.pyi +++ b/test-data/unit/fixtures/async_await.pyi @@ -1,3 +1,4 @@ +import types import typing T = typing.TypeVar('T') @@ -23,4 +24,3 @@ class StopIteration(BaseException): pass class StopAsyncIteration(BaseException): pass def iter(obj: typing.Any) -> typing.Any: pass def next(obj: typing.Any) -> typing.Any: pass -class ellipsis: ... diff --git a/test-data/unit/fixtures/bool.pyi b/test-data/unit/fixtures/bool.pyi index bc58a22b952bd..80ec071f99eb3 100644 --- a/test-data/unit/fixtures/bool.pyi +++ b/test-data/unit/fixtures/bool.pyi @@ -1,4 +1,5 @@ # builtins stub used in boolean-related test cases. +import types from typing import Generic, TypeVar T = TypeVar('T') @@ -14,7 +15,6 @@ class int: pass class bool(int): pass class float: pass class str: pass -class ellipsis: pass class list(Generic[T]): pass class property: pass class dict: pass diff --git a/test-data/unit/fixtures/callable.pyi b/test-data/unit/fixtures/callable.pyi index 44abf0691ceb9..2b1a5a155e754 100644 --- a/test-data/unit/fixtures/callable.pyi +++ b/test-data/unit/fixtures/callable.pyi @@ -1,3 +1,4 @@ +import types from typing import Generic, Tuple, TypeVar, Union T = TypeVar('T') @@ -26,6 +27,5 @@ class bool(int): pass class str: def __add__(self, other: 'str') -> 'str': pass def __eq__(self, other: 'str') -> bool: pass -class ellipsis: pass class list: ... class dict: pass diff --git a/test-data/unit/fixtures/classmethod.pyi b/test-data/unit/fixtures/classmethod.pyi index 97e018b1dc1cc..7f72574bc70c9 100644 --- a/test-data/unit/fixtures/classmethod.pyi +++ b/test-data/unit/fixtures/classmethod.pyi @@ -1,3 +1,4 @@ +import types import typing _T = typing.TypeVar('_T') @@ -23,7 +24,6 @@ class float: pass class str: pass class bytes: pass class bool: pass -class ellipsis: pass class tuple(typing.Generic[_T]): pass diff --git a/test-data/unit/fixtures/complex_tuple.pyi b/test-data/unit/fixtures/complex_tuple.pyi index 81f1d33d1207d..8e3358df0adfd 100644 --- a/test-data/unit/fixtures/complex_tuple.pyi +++ b/test-data/unit/fixtures/complex_tuple.pyi @@ -1,3 +1,4 @@ +import types from typing import Generic, TypeVar _T = TypeVar('_T') @@ -12,5 +13,4 @@ class int: pass class float: pass class complex: pass class str: pass -class ellipsis: pass class dict: pass diff --git a/test-data/unit/fixtures/dataclasses.pyi b/test-data/unit/fixtures/dataclasses.pyi index b6b17a15610a1..3f570b410ddfa 100644 --- a/test-data/unit/fixtures/dataclasses.pyi +++ b/test-data/unit/fixtures/dataclasses.pyi @@ -1,4 +1,5 @@ import _typeshed +import types from typing import ( Generic, Iterator, Iterable, Mapping, Optional, Sequence, Tuple, TypeVar, Union, overload, @@ -17,7 +18,6 @@ class object: def __ne__(self, o: object) -> bool: pass class type: pass -class ellipsis: pass class tuple(Generic[_T]): pass class int: pass class float: pass diff --git a/test-data/unit/fixtures/dict-full.pyi b/test-data/unit/fixtures/dict-full.pyi index 4f4097b77788a..6cc32055fb87f 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 types from _typeshed import SupportsKeysAndGetItem import _typeshed from typing import ( @@ -78,7 +79,6 @@ class float: pass class complex: pass class bool(int): pass -class ellipsis: pass def isinstance(x: object, t: Union[type, Tuple[type, ...]]) -> bool: pass class BaseException: pass diff --git a/test-data/unit/fixtures/dict.pyi b/test-data/unit/fixtures/dict.pyi index 4dc9aa3e7713e..63698a89281c3 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 types from _typeshed import SupportsKeysAndGetItem import _typeshed from typing import ( @@ -59,7 +60,6 @@ class function: pass class float: pass class complex: pass class bool(int): pass -class ellipsis: pass class BaseException: pass def isinstance(x: object, t: Union[type, Tuple[type, ...]]) -> bool: pass diff --git a/test-data/unit/fixtures/divmod.pyi b/test-data/unit/fixtures/divmod.pyi index 4d81d8fb47a27..124e318b7f1e2 100644 --- a/test-data/unit/fixtures/divmod.pyi +++ b/test-data/unit/fixtures/divmod.pyi @@ -1,3 +1,4 @@ +import types from typing import TypeVar, Tuple, SupportsInt class object: def __init__(self): pass @@ -15,7 +16,6 @@ class tuple: pass class function: pass class str: pass class type: pass -class ellipsis: pass _N = TypeVar('_N', int, float) def divmod(_x: _N, _y: _N) -> Tuple[_N, _N]: ... diff --git a/test-data/unit/fixtures/enum.pyi b/test-data/unit/fixtures/enum.pyi index 22e7193da0415..373683c425e04 100644 --- a/test-data/unit/fixtures/enum.pyi +++ b/test-data/unit/fixtures/enum.pyi @@ -1,4 +1,5 @@ # Minimal set of builtins required to work with Enums +import types from typing import TypeVar, Generic, Iterator, Sequence, overload, Iterable T = TypeVar('T') @@ -16,7 +17,6 @@ class str: def __iter__(self) -> Iterator[str]: pass class dict: pass -class ellipsis: pass class list(Sequence[T]): @overload diff --git a/test-data/unit/fixtures/exception.pyi b/test-data/unit/fixtures/exception.pyi index 963192cc86ab3..ebc1e632b64c4 100644 --- a/test-data/unit/fixtures/exception.pyi +++ b/test-data/unit/fixtures/exception.pyi @@ -1,4 +1,5 @@ import sys +import types from typing import Generic, TypeVar T = TypeVar('T') @@ -15,7 +16,6 @@ class int: pass class float: pass class str: pass class bool: pass -class ellipsis: pass class BaseException: def __init__(self, *args: object) -> None: ... diff --git a/test-data/unit/fixtures/f_string.pyi b/test-data/unit/fixtures/f_string.pyi index 328c666b7ece3..1fb9c1b2d1355 100644 --- a/test-data/unit/fixtures/f_string.pyi +++ b/test-data/unit/fixtures/f_string.pyi @@ -1,6 +1,7 @@ # Builtins stub used for format-string-related test cases. # We need str and list, and str needs join and format methods. +import types from typing import TypeVar, Generic, Iterable, Iterator, List, overload T = TypeVar('T') @@ -11,7 +12,6 @@ class object: class type: def __init__(self, x) -> None: pass -class ellipsis: pass class list(Iterable[T], Generic[T]): @overload diff --git a/test-data/unit/fixtures/fine_grained.pyi b/test-data/unit/fixtures/fine_grained.pyi index e454a27a5ebd6..46701f469786f 100644 --- a/test-data/unit/fixtures/fine_grained.pyi +++ b/test-data/unit/fixtures/fine_grained.pyi @@ -25,6 +25,5 @@ class float: pass class bytes: pass class tuple(Generic[T]): pass class function: pass -class ellipsis: pass class list(Generic[T]): pass class dict: pass diff --git a/test-data/unit/fixtures/float.pyi b/test-data/unit/fixtures/float.pyi index 9e2d20f04edf4..7231b61fdbfc1 100644 --- a/test-data/unit/fixtures/float.pyi +++ b/test-data/unit/fixtures/float.pyi @@ -1,3 +1,4 @@ +import types from typing import Generic, TypeVar, Any T = TypeVar('T') @@ -16,9 +17,6 @@ class bytes: pass class tuple(Generic[T]): pass class function: pass -class ellipsis: pass - - class int: def __abs__(self) -> int: ... def __float__(self) -> float: ... diff --git a/test-data/unit/fixtures/floatdict.pyi b/test-data/unit/fixtures/floatdict.pyi index 11c7286f5ed42..b635ee5fed8a2 100644 --- a/test-data/unit/fixtures/floatdict.pyi +++ b/test-data/unit/fixtures/floatdict.pyi @@ -1,3 +1,4 @@ +import types from typing import TypeVar, Generic, Iterable, Iterator, Mapping, Tuple, overload, Optional, Union, Any T = TypeVar('T') @@ -20,7 +21,6 @@ class tuple(Generic[T]): pass class slice: pass class function: pass -class ellipsis: pass class list(Iterable[T], Generic[T]): @overload diff --git a/test-data/unit/fixtures/for.pyi b/test-data/unit/fixtures/for.pyi index 80c8242c2a5e7..e4410ee3129e9 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 types from typing import TypeVar, Generic, Iterable, Iterator, Generator from abc import abstractmethod, ABCMeta @@ -12,7 +13,6 @@ class type: pass class tuple(Generic[t]): def __iter__(self) -> Iterator[t]: pass class function: pass -class ellipsis: pass class bool: pass class int: pass # for convenience class float: pass # for convenience diff --git a/test-data/unit/fixtures/for_else_exception.pyi b/test-data/unit/fixtures/for_else_exception.pyi index 98c953caff722..d469960482813 100644 --- a/test-data/unit/fixtures/for_else_exception.pyi +++ b/test-data/unit/fixtures/for_else_exception.pyi @@ -1,6 +1,7 @@ # Fixture for for-else tests with exceptions # Combines needed elements from primitives.pyi and exception.pyi +import types from typing import Generic, Iterator, Mapping, Sequence, TypeVar T = TypeVar('T') @@ -36,7 +37,6 @@ class dict(Mapping[T, V]): def __iter__(self) -> Iterator[T]: pass class tuple(Generic[T]): def __contains__(self, other: object) -> bool: pass -class ellipsis: pass class BaseException: def __init__(self, *args: object) -> None: ... diff --git a/test-data/unit/fixtures/isinstance.pyi b/test-data/unit/fixtures/isinstance.pyi index cb492ed5dfe5b..0f55a1ca0bc2b 100644 --- a/test-data/unit/fixtures/isinstance.pyi +++ b/test-data/unit/fixtures/isinstance.pyi @@ -1,3 +1,4 @@ +import types from typing import Tuple, TypeVar, Generic, Union, cast, Any, Type T = TypeVar('T') @@ -24,7 +25,6 @@ class bool(int): pass class str: def __new__(cls, o: object = ...) -> str: pass def __add__(self, other: 'str') -> 'str': pass -class ellipsis: pass NotImplemented = cast(Any, None) diff --git a/test-data/unit/fixtures/isinstance_python3_10.pyi b/test-data/unit/fixtures/isinstance_python3_10.pyi index 0918d10ab1ef1..de8e933ce884d 100644 --- a/test-data/unit/fixtures/isinstance_python3_10.pyi +++ b/test-data/unit/fixtures/isinstance_python3_10.pyi @@ -24,7 +24,6 @@ class float: pass class bool(int): pass class str: def __add__(self, other: 'str') -> 'str': pass -class ellipsis: pass NotImplemented = cast(Any, None) diff --git a/test-data/unit/fixtures/isinstancelist.pyi b/test-data/unit/fixtures/isinstancelist.pyi index 0426b4e0cbfb1..9577bdd3119f9 100644 --- a/test-data/unit/fixtures/isinstancelist.pyi +++ b/test-data/unit/fixtures/isinstancelist.pyi @@ -13,9 +13,7 @@ class type: class function: pass class classmethod: pass -class ellipsis: pass -EllipsisType = ellipsis -Ellipsis = ellipsis() +Ellipsis: types.EllipsisType def isinstance(x: object, t: Union[type, Tuple]) -> bool: pass def issubclass(x: object, t: Union[type, Tuple]) -> bool: pass diff --git a/test-data/unit/fixtures/len.pyi b/test-data/unit/fixtures/len.pyi index ee39d952701fa..805cd877444d9 100644 --- a/test-data/unit/fixtures/len.pyi +++ b/test-data/unit/fixtures/len.pyi @@ -1,3 +1,4 @@ +import types from typing import Tuple, TypeVar, Generic, Union, Type, Sequence, Mapping from typing_extensions import Protocol @@ -36,4 +37,3 @@ class int: class float: pass class bool(int): pass class str(Sequence[str]): pass -class ellipsis: pass diff --git a/test-data/unit/fixtures/list.pyi b/test-data/unit/fixtures/list.pyi index 3dcdf18b2faa3..10eb7e29fe89e 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 types from typing import TypeVar, Generic, Iterable, Iterator, Sequence, overload T = TypeVar('T') @@ -9,7 +10,6 @@ class object: def __eq__(self, other: object) -> bool: pass class type: pass -class ellipsis: pass class list(Sequence[T]): @overload diff --git a/test-data/unit/fixtures/module.pyi b/test-data/unit/fixtures/module.pyi index 92f78a42f92fe..a50aedac54b4e 100644 --- a/test-data/unit/fixtures/module.pyi +++ b/test-data/unit/fixtures/module.pyi @@ -1,5 +1,5 @@ from typing import Any, Dict, Generic, TypeVar, Sequence -from types import ModuleType +from types import ModuleType, EllipsisType T = TypeVar('T') S = TypeVar('S') @@ -16,7 +16,6 @@ class str: pass class bool: pass class tuple(Generic[T]): pass class dict(Generic[T, S]): pass -class ellipsis: pass classmethod = object() staticmethod = object() diff --git a/test-data/unit/fixtures/module_all.pyi b/test-data/unit/fixtures/module_all.pyi index d6060583b20e1..fb96f31c912d8 100644 --- a/test-data/unit/fixtures/module_all.pyi +++ b/test-data/unit/fixtures/module_all.pyi @@ -16,5 +16,4 @@ class list(Generic[_T], Sequence[_T]): def remove(self, x: _T): pass def __add__(self, rhs: Sequence[_T]) -> list[_T]: pass class tuple(Generic[_T]): pass -class ellipsis: pass class dict: pass diff --git a/test-data/unit/fixtures/narrowing.pyi b/test-data/unit/fixtures/narrowing.pyi index a36ac7f29bd27..5f0c46663358f 100644 --- a/test-data/unit/fixtures/narrowing.pyi +++ b/test-data/unit/fixtures/narrowing.pyi @@ -1,4 +1,5 @@ # Builtins stub used in check-narrowing test cases. +import types from typing import Generic, Sequence, Tuple, Type, TypeVar, Union, Iterable @@ -12,7 +13,6 @@ class object: class type: pass class tuple(Sequence[Tco], Generic[Tco]): pass class function: pass -class ellipsis: pass class int: pass class str: pass class float: pass diff --git a/test-data/unit/fixtures/notimplemented.pyi b/test-data/unit/fixtures/notimplemented.pyi index 9442c21aa464f..5f5f6d2033761 100644 --- a/test-data/unit/fixtures/notimplemented.pyi +++ b/test-data/unit/fixtures/notimplemented.pyi @@ -10,7 +10,6 @@ class int: pass class str: pass class dict: pass class tuple: pass -class ellipsis: pass class list: pass from types import NotImplementedType diff --git a/test-data/unit/fixtures/object_hashable.pyi b/test-data/unit/fixtures/object_hashable.pyi index 49b17991f01c6..ed205232c5ae7 100644 --- a/test-data/unit/fixtures/object_hashable.pyi +++ b/test-data/unit/fixtures/object_hashable.pyi @@ -1,3 +1,5 @@ +import types + class object: def __hash__(self) -> int: ... @@ -5,6 +7,5 @@ class type: ... class int: ... class float: ... class str: ... -class ellipsis: ... class tuple: ... class dict: pass diff --git a/test-data/unit/fixtures/object_with_init_subclass.pyi b/test-data/unit/fixtures/object_with_init_subclass.pyi index 445d650236902..c30b0883e8d6c 100644 --- a/test-data/unit/fixtures/object_with_init_subclass.pyi +++ b/test-data/unit/fixtures/object_with_init_subclass.pyi @@ -1,4 +1,5 @@ import _typeshed +import types from typing import Sequence, Iterator, TypeVar, Mapping, Iterable, Optional, Union, overload, Tuple, Generic, List class object: @@ -33,7 +34,6 @@ class bytes(Sequence[int]): class bytearray: pass class tuple(Generic[T]): pass class function: pass -class ellipsis: pass # copy-pasted from list.pyi class list(Sequence[T]): diff --git a/test-data/unit/fixtures/ops.pyi b/test-data/unit/fixtures/ops.pyi index 67bc74b35c51d..df615f8f65746 100644 --- a/test-data/unit/fixtures/ops.pyi +++ b/test-data/unit/fixtures/ops.pyi @@ -1,3 +1,4 @@ +import types from typing import overload, Any, Generic, Sequence, Tuple, TypeVar, Optional Tco = TypeVar('Tco', covariant=True) @@ -71,6 +72,5 @@ class BaseException: pass def __print(a1: object = None, a2: object = None, a3: object = None, a4: object = None) -> None: pass -class ellipsis: pass class dict: pass diff --git a/test-data/unit/fixtures/paramspec.pyi b/test-data/unit/fixtures/paramspec.pyi index af2331dbdc5d5..a21f1ce1bda3e 100644 --- a/test-data/unit/fixtures/paramspec.pyi +++ b/test-data/unit/fixtures/paramspec.pyi @@ -1,6 +1,7 @@ # builtins stub for paramspec-related test cases import _typeshed +import types from typing import ( Sequence, Generic, TypeVar, Iterable, Iterator, Tuple, Mapping, Optional, Union, Type, overload, Protocol @@ -15,7 +16,6 @@ class object: def __init__(self) -> None: ... class function: ... -class ellipsis: ... class classmethod: ... class type: diff --git a/test-data/unit/fixtures/plugin_attrs.pyi b/test-data/unit/fixtures/plugin_attrs.pyi index 7fd641727253e..169738a720ff0 100644 --- a/test-data/unit/fixtures/plugin_attrs.pyi +++ b/test-data/unit/fixtures/plugin_attrs.pyi @@ -1,4 +1,5 @@ # Builtins stub used to support attrs plugin tests. +import types from typing import Union, overload, Generic, Sequence, TypeVar, Type, Iterable, Iterator class object: @@ -24,7 +25,6 @@ class complex: def __init__(self, real: str = ...) -> None: ... class str: pass -class ellipsis: pass class list: pass class dict: pass diff --git a/test-data/unit/fixtures/primitives.pyi b/test-data/unit/fixtures/primitives.pyi index 2069f56dd5fc1..a6c94b96bb591 100644 --- a/test-data/unit/fixtures/primitives.pyi +++ b/test-data/unit/fixtures/primitives.pyi @@ -1,5 +1,6 @@ # builtins stub with non-generic primitive types import _typeshed +import types from typing import Generic, TypeVar, Sequence, Iterator, Mapping, Iterable, Tuple, Union T = TypeVar('T') @@ -69,7 +70,6 @@ class set(Iterable[T]): class frozenset(Iterable[T]): def __iter__(self) -> Iterator[T]: pass class function: pass -class ellipsis: pass class range(Sequence[int]): def __init__(self, __x: int, __y: int = ..., __z: int = ...) -> None: pass diff --git a/test-data/unit/fixtures/property.pyi b/test-data/unit/fixtures/property.pyi index 933868ac9907b..78cccc566c60f 100644 --- a/test-data/unit/fixtures/property.pyi +++ b/test-data/unit/fixtures/property.pyi @@ -1,3 +1,4 @@ +import types import typing _T = typing.TypeVar('_T') @@ -20,6 +21,5 @@ class float: pass class str: pass class bytes: pass class bool: pass -class ellipsis: pass class tuple(typing.Generic[_T]): pass diff --git a/test-data/unit/fixtures/sentinel.pyi b/test-data/unit/fixtures/sentinel.pyi index 690efb0df32ac..3098533247bc2 100644 --- a/test-data/unit/fixtures/sentinel.pyi +++ b/test-data/unit/fixtures/sentinel.pyi @@ -1,5 +1,6 @@ # Builtins stub used in sentinel-related test cases. +import types from typing import Self class object: @@ -9,7 +10,6 @@ class object: class type: pass class function: __name__: str -class ellipsis: pass class int: pass class bool(int): pass diff --git a/test-data/unit/fixtures/set.pyi b/test-data/unit/fixtures/set.pyi index f757679a95f4e..50b5afe488ce1 100644 --- a/test-data/unit/fixtures/set.pyi +++ b/test-data/unit/fixtures/set.pyi @@ -1,5 +1,6 @@ # Builtins stub used in set-related test cases. +import types from typing import TypeVar, Generic, Iterator, Iterable, Set T = TypeVar('T') @@ -16,7 +17,6 @@ class int: pass class float: pass class str: pass class bool: pass -class ellipsis: pass class set(Iterable[T], Generic[T]): def __init__(self, iterable: Iterable[T] = ...) -> None: ... diff --git a/test-data/unit/fixtures/slice.pyi b/test-data/unit/fixtures/slice.pyi index 78cc24ab3d24b..aa376cec1a876 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 types from typing import Generic, TypeVar, Protocol T = TypeVar('T') _Tco = TypeVar('_Tco', covariant=True) @@ -17,7 +18,6 @@ class int: pass class str: pass class slice(Generic[_Tco]): pass -class ellipsis: pass class dict: pass class list(Generic[T]): def __getitem__(self, x: slice[SupportsIndex | None]) -> list[T]: pass diff --git a/test-data/unit/fixtures/staticmethod.pyi b/test-data/unit/fixtures/staticmethod.pyi index a0ca831c7527e..d1bfc7f03ebbd 100644 --- a/test-data/unit/fixtures/staticmethod.pyi +++ b/test-data/unit/fixtures/staticmethod.pyi @@ -1,3 +1,4 @@ +import types import typing class object: @@ -17,6 +18,5 @@ class int: class str: pass class bytes: pass -class ellipsis: pass class dict: pass class tuple: pass diff --git a/test-data/unit/fixtures/tuple-typeshed.pyi b/test-data/unit/fixtures/tuple-typeshed.pyi index 57a1a29a87ada..a5edeb345eb3f 100644 --- a/test-data/unit/fixtures/tuple-typeshed.pyi +++ b/test-data/unit/fixtures/tuple-typeshed.pyi @@ -47,7 +47,6 @@ class bool(int): pass class str: pass # For convenience class object: pass class type: pass -class ellipsis: pass class SupportsIndex(Protocol): def __index__(self) -> int: pass class list(Sequence[_T], Generic[_T]): diff --git a/test-data/unit/fixtures/tuple.pyi b/test-data/unit/fixtures/tuple.pyi index 35ce704ee820a..e2bd03b736bca 100644 --- a/test-data/unit/fixtures/tuple.pyi +++ b/test-data/unit/fixtures/tuple.pyi @@ -30,7 +30,6 @@ class tuple(Sequence[_Tco], Generic[_Tco]): def count(self, obj: object) -> int: pass class function: __name__: str -class ellipsis: pass class classmethod: pass # We need int and slice for indexing tuples. diff --git a/test-data/unit/fixtures/type.pyi b/test-data/unit/fixtures/type.pyi index 83c54b558ccf1..752cfda484511 100644 --- a/test-data/unit/fixtures/type.pyi +++ b/test-data/unit/fixtures/type.pyi @@ -26,7 +26,6 @@ class function: pass class bool: pass class int: pass class str: pass -class ellipsis: pass class float: pass def isinstance(obj: object, class_or_tuple: type | types.UnionType, /) -> bool: ... diff --git a/test-data/unit/lib-stub/builtins.pyi b/test-data/unit/lib-stub/builtins.pyi index 17d519cc8eeae..eea54878568f8 100644 --- a/test-data/unit/lib-stub/builtins.pyi +++ b/test-data/unit/lib-stub/builtins.pyi @@ -3,6 +3,7 @@ # Use [builtins fixtures/...pyi] if you need more features. import _typeshed +import types class object: def __init__(self) -> None: pass @@ -21,7 +22,6 @@ class bytes: pass class function: __name__: str -class ellipsis: pass from typing import Generic, Iterator, Sequence, TypeVar _T = TypeVar('_T') diff --git a/test-data/unit/lib-stub/types.pyi b/test-data/unit/lib-stub/types.pyi index 28a45366dbea3..02f7785f827bc 100644 --- a/test-data/unit/lib-stub/types.pyi +++ b/test-data/unit/lib-stub/types.pyi @@ -19,3 +19,5 @@ class UnionType: def __or__(self, x) -> UnionType: ... class NotImplementedType: ... + +class EllipsisType: pass diff --git a/test-data/unit/typexport-basic.test b/test-data/unit/typexport-basic.test index 77e7763824d64..0aed4f83f8d5b 100644 --- a/test-data/unit/typexport-basic.test +++ b/test-data/unit/typexport-basic.test @@ -64,7 +64,7 @@ NameExpr(10) : A import typing ... [out] -EllipsisExpr(2) : builtins.ellipsis +EllipsisExpr(2) : types.EllipsisType [case testMemberAccess] ## MemberExpr|CallExpr