Description
This appeared in #1856
The problem is that type variable names in some stubs don't follow PEP 8 that recommends short names. This recommendation exists for a reason: behaviour of some constructs is subtly different with type variables and normal types, so it should be immediately clear that a given name refers to a type variable. Most notable examples are generic base classes and generic type aliases, where this leads to false negatives (unless --disallow-any-generics
is used):
LongNameLikeAClass = TypeVar('LongNameLikeAClass')
# 300 lines later
class Cls(Iterable[LongNameLikeAClass]): # it's not obvious this class is generic
...
Alias = Dict[str, List[LongNameLikeAClass]] # even more here, this looks like a normal alias
def fun(arg: Cls) -> Alias: # two `Any`s sneaked in here
...
(it is not something hypothetic, I have seen this kind of errors many times)
I propose to replace the existing long type variable names to follow PEP 8 style. If someone really doesn't like short names, we could propose some other agreement, like end long type variable names with _TVar
.