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
I'm not sure this is supposed to work:
from typing import Optional class A: def __init__(self): self.n: Optional[int] = 1 def f(self) -> None: if self.n is None: raise RuntimeError("") self.n += 1 # no mypy error here def f_false_positive(self) -> None: self.check_n() self.n += 1 # mypy error here def destroy(self) -> None: self.n = None def check_n(self): if self.n is None: raise RuntimeError("")
The error is at line 16:
$ mypy /tmp/1.py /tmp/1.py:16: error: Unsupported operand types for + ("None" and "int") /tmp/1.py:16: note: Left operand is of type "Optional[int]"
Line 11 is correct instead.
The text was updated successfully, but these errors were encountered:
This is essentially a duplicate of #4063
Sorry, something went wrong.
No branches or pull requests
I'm not sure this is supposed to work:
The error is at line 16:
Line 11 is correct instead.
The text was updated successfully, but these errors were encountered: