Check that type arguments exist [type-arg]
If you use —disallow-any-generics
, mypy requires that each generictype has values for each type argument. For example, the types List
ordict
would be rejected. You should instead use types like List[int]
orDict[str, int]
. Any omitted generic type arguments get implicit Any
values. The type List
is equivalent to List[Any]
, and so on.
Example:
- # mypy: disallow-any-generics
- from typing import List
- # Error: Missing type parameters for generic type "List" [type-arg]
- def remove_dups(items: List) -> List:
- ...