-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Omitted Generics Should Be Disallowed #3469
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
Well, to make this the default/only way, you would have to propose a change to PEP 484 and get pytype and PyCharm to agree. And there may be a lot of code to update. |
I am against making this the default. FWIW I have seen lots of code on GitHub that just uses plain |
yeah, these are good points. |
@ilevkivskyi, I think that may be a good idea but at the same time it may flood the user's console with such errors. Of course, we can do what |
I think the right place in the tradeoff space may be to allow e.g. |
I think this is now fixed, since we have |
Currently, if a generic type parameter is not specified, it is assumed to be Any (
List
becomesList[Any]
).Forgetting to provide a generic type is an easy mistake to make, which makes mypy less effective at typechecking as the generic type will be inferred as
Any
. We should make sure e.g.List[Any]
is actually what user wants by making the user explicitly stateList[Any]
as the type.If the generic parameter is not specified, mypy should output an error.
There’s also the problem of
list
,set
, etc. We should probably forbid these too and give a nice error message saying they should useList
. However, this part of the proposal requires more consideration since, for instance, it’s possible that the user does not want to importtyping
module.As a migration aid, we can provide a flag to allow implicit any from omitted generics but eventually we should remove it too.
The text was updated successfully, but these errors were encountered: