-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Treat type inference which produces <nothing>
as an error or warning under --strict
mode
#15931
New issue
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
Comments
So, I don't think that this flag is possible. Testing types is the solution here, in my opinion. |
I agree that testing types is the best solution. Other than I'm hesitant to self-close this issue because what seems to have happened in |
|
Are you saying that I have written plenty of functions with |
Yes, |
Oh, then this issue report makes no sense! I'll self-close. I don't suppose we could make the str of it |
Hm, I don't know :) |
Feature
If a type is inferred as
<nothing>
and--strict
was used, treat this as an error or warning.Include a
--disallow-nothing/--allow-nothing
flag anddisallow_nothing
config value, or--warn-nothing/--no-warn-nothing
flag and variable to control the behavior more granularly.Pitch
From #3924, it was suggested that I open a new issue.
The following type alias produces
<nothing>
as the inferred return type of a function:In #3924, this is described as a bug with the binding of
T
in greater detail. #3924 also includes a comment stating that<nothing>
is a bottom type. I have also heardtyping.Never
/typing.NoReturn
referred to as a bottom type, but those types are useful and desirable -- so much so that users can refer to them directly and they are part of the stdlib.I've never wanted to produce
<nothing>
-- I didn't even know it existed until recently, after several years of using mypy.My use-case is... pallets/click#2558 . A bug in a mainstream library which was trying to do everything correctly, but didn't get any warning about shipping types which produced
<nothing>
.For
click
specifically, there are now typing tests withassert_type
, so this is unlikely to recur. But if any other library were to produce<nothing>
-- or, more nefariously, a type likedef [T] () -> def (T`-1) -> T`-1
which can result in<nothing>
-- it would be best to be able to catch it early, via the type checker.The text was updated successfully, but these errors were encountered: