-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
When type checking these files, there's a false positive in x.py when using a cold cache (rm -rf .mypy_cache first). This is a regression from mypy 1.17 and is a release blocker. The behavior is inconsistent between cached and uncached runs.
typ.py:
from typing import NamedTuple
NT = NamedTuple("NT", [("x", str | None)])mod.py:
# mypy: no-strict-optional
from typ import NT
def f() -> NT:
return NT(x='')x.py:
import mod
# Argument "x" to "NT" has incompatible type "None"; expected "str"
a = mod.NT(x=None)It looks like the NT parameter type gets simplified to just str from str | None when the type is used in a module with strict optional checking disabled.
This bisects to #19514 (cc @ilevkivskyi). Maybe the caching should be disabled in modules that don't use strict optional checking?