-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct code
Description
This generates a false positive:
# mypy: no-strict-optional
from typing import Tuple, Dict, Optional, NamedTuple
class C(NamedTuple):
x: int
t: Optional[C]
d: Dict[C, bytes]
x = t and d[t]
if x:
x.startswith(b'x') # Item "C" of "Union[C, bytes]" has no attribute "startswith"It started happening as a side effect of #10389.
This is a regression, so this may be high priority. However, since this only seems to happen when strict optional checking is disabled, the impact may be pretty minor.
cc @ethan-leba
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct code