We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# example.py foo: list[str | int] = [0,1,2,3,'strings', 'as', 'well', 'here', 'bar', 'baz'] for i in range(len(foo)-1): if (isinstance(foo[i+1], str) and foo[i+1].upper() == 'BAR'): # error: Item "int" of "str | int" has no attribute "upper" [union-attr] print('FOOBAR')
I figure this type test is simple enough that mypy should know foo[i+1] must be a str.
foo[i+1]
str
Your Environment
mypy 1.6.1 (compiled: yes) Python 3.10.12
mypy --strict ~/example.py
The text was updated successfully, but these errors were encountered:
Duplicate of #7339
Sorry, something went wrong.
No branches or pull requests
I figure this type test is simple enough that mypy should know
foo[i+1]
must be astr
.Your Environment
mypy 1.6.1 (compiled: yes)
Python 3.10.12
mypy --strict ~/example.py
The text was updated successfully, but these errors were encountered: