Skip to content

Commit 7fd34ce

Browse files
committed
Reuse ellipsis type names
1 parent 80c82b7 commit 7fd34ce

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

mypy/plugins/enums.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from mypy.subtypes import is_equivalent
2323
from mypy.typeops import fixup_partial_type, make_simplified_union
2424
from mypy.types import (
25+
ELLIPSIS_TYPE_NAMES,
2526
CallableType,
2627
Instance,
2728
LiteralType,
@@ -90,10 +91,7 @@ def _infer_value_type_with_auto_fallback(
9091
# Enums in stubs may have ... instead of actual values. If `_value_` is annotated
9192
# (manually or inherited from IntEnum, for example), it is a more reasonable guess
9293
# than literal ellipsis type.
93-
if isinstance(proper_type, Instance) and proper_type.type.fullname in {
94-
"types.EllipsisType",
95-
"builtins.ellipsis",
96-
}:
94+
if isinstance(proper_type, Instance) and proper_type.type.fullname in ELLIPSIS_TYPE_NAMES:
9795
if (
9896
isinstance(ctx.type, Instance)
9997
and (value_type := ctx.type.type.get("_value_"))

mypy/stubtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ def verify_var(
11491149
proper_type = mypy.types.get_proper_type(stub.type)
11501150
if (
11511151
isinstance(proper_type, mypy.types.Instance)
1152-
and proper_type.type.fullname == "builtins.ellipsis"
1152+
and proper_type.type.fullname in mypy.types.ELLIPSIS_TYPE_NAMES
11531153
):
11541154
should_error = False
11551155

mypy/types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@
181181
# Supported @override decorator names.
182182
OVERRIDE_DECORATOR_NAMES: Final = ("typing.override", "typing_extensions.override")
183183

184+
ELLIPSIS_TYPE_NAMES: Final = ("builtins.ellipsis", "types.EllipsisType")
185+
184186
# A placeholder used for Bogus[...] parameters
185187
_dummy: Final[Any] = object()
186188

@@ -1574,7 +1576,7 @@ def is_singleton_type(self) -> bool:
15741576
return (
15751577
self.type.is_enum
15761578
and len(self.type.enum_members) == 1
1577-
or self.type.fullname in {"builtins.ellipsis", "types.EllipsisType"}
1579+
or self.type.fullname in ELLIPSIS_TYPE_NAMES
15781580
)
15791581

15801582

0 commit comments

Comments
 (0)