Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,14 @@ def verify_var(
stub,
runtime,
)
elif stub.final_value is not None and stub.final_value != runtime:
yield Error(
object_path,
f"is inconsistent, stub value {stub.final_value!r} differs from runtime value",
stub,
runtime,
stub_desc=repr(stub.final_value),
)


@verify.register(nodes.OverloadedFuncDef)
Expand Down
16 changes: 16 additions & 0 deletions mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,22 @@ def read_write_attr(self, val): self._val = val
""",
error=None,
)
yield Case(
stub="""
from typing import Final
X_FINAL: Final = 2
""",
runtime="X_FINAL = 1",
error="X_FINAL",
)
yield Case(
stub="""
from typing import Final
X_FINAL_OK: Final = 1
""",
runtime="X_FINAL_OK = 1",
error=None,
)

@collect_cases
def test_type_alias(self) -> Iterator[Case]:
Expand Down