-
-
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 codepriority-1-normaltopic-join-v-unionUsing join vs. using unionsUsing join vs. using unionstopic-ternary-expressiona if b else ca if b else c
Description
I faced with a strange mypy error, with such a code below:
def foo() -> None:
message = 'test'
raise Exception(message) if message else Exception # -> mypy error
def bar() -> None:
raise Exception # ok
def baz() -> None:
message = 'test'
raise Exception(message) # ok
def qux() -> None:
message = 'test'
raise Exception if not message else Exception(message) # -> mypy error
if __name__ == '__main__':
foo()
It seems legal code, but mypy produces two error messages there.
$ mypy test.py
test.py:3: error: Exception must be derived from BaseException
test.py:17: error: Exception must be derived from BaseException
Actually, this error seems to happen not only with Exception
but with any other built-in exceptions.
The version of mypy is 0.600, and that of Python is 3.6.3.
Thanks in advance.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-join-v-unionUsing join vs. using unionsUsing join vs. using unionstopic-ternary-expressiona if b else ca if b else c