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
$ mypy --version
mypy 0.610
$ cat exception.py
def f() -> None:
excs = [IOError, LookupError]
try:
pass
except excs:
pass
$ mypy exception.py
exception.py:5: error: Exception type must be derived from BaseException
While it's true that this code is incorrect, I probably want to fix it by writing excs = (IOError, LookupError) rather than somehow making my list a subclass of BaseException.
The text was updated successfully, but these errors were encountered:
The error message is confusing in this case -- mypy accepts tuples already. One way to fix this would be to check if the exception is not a type object, and in that case change the message to something like this:
exception.py:5: error: Exception type must be a class derived from BaseException (or a tuple of exception classes)
While it's true that this code is incorrect, I probably want to fix it by writing
excs = (IOError, LookupError)
rather than somehow making my list a subclass ofBaseException
.The text was updated successfully, but these errors were encountered: