Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,12 @@ def verify_var(
runtime_type = get_mypy_type_of_runtime_value(runtime.value)
if runtime_type is not None and is_subtype_helper(runtime_type, stub.type):
should_error = False
# We always allow setting the stub value to ...
if (
isinstance(stub.type, mypy.types.Instance)
and stub.type.type.fullname == "builtins.ellipsis"
):
should_error = False

if should_error:
yield Error(
Expand Down
19 changes: 19 additions & 0 deletions mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,25 @@ def baz(x=Flags3(0)): pass
""",
error=None,
)
yield Case(
runtime="""
import enum
class SomeObject: ...

class WeirdEnum(enum.Enum):
a = SomeObject()
b = SomeObject()
""",
stub="""
import enum
class SomeObject: ...
class WeirdEnum(enum.Enum):
_value_: SomeObject
a = ...
b = ...
""",
error=None,
)
yield Case(
stub="""
class Flags4(enum.Flag):
Expand Down