You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected no error.
I expected the type narrowing to apply to the if block and its generator.
Actual Behavior
% mypy file.pyfile.py:6: note: Revealed type is "Union[None, builtins.str]"file.py:8: note: Revealed type is "builtins.str"file.py:9: error: Item "None" of "Optional[str]" has no attribute "__iter__" (not iterable)Found 1 error in 1 file (checked 1 source file)
Your Environment
Mypy version used:
% mypy --versionmypy 0.961 (compiled: yes)
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
Python version used: 3.10.1
Operating system and version: macOS Monterey 12.0.1 (21A559)
The text was updated successfully, but these errors were encountered:
Bug Report
An argument typed as
None | str
gets correctly narrowed tostr
after anif argument:
, but the narrowing is not applied inside theif
block.To Reproduce
Expected Behavior
I expected no error.
I expected the type narrowing to apply to the
if
block and its generator.Actual Behavior
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: