Description
Currently, if a generic type parameter is not specified, it is assumed to be Any (List
becomes List[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 state List[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 use List
. However, this part of the proposal requires more consideration since, for instance, it’s possible that the user does not want to import typing
module.
As a migration aid, we can provide a flag to allow implicit any from omitted generics but eventually we should remove it too.