You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several classes in typeshed inherit from Any, and should not.
$ ag "class .*\(Any\)"
stdlib\3\multiprocessing\context.pyi
118: class ForkProcess(Any): # type: ignore
124: class SpawnProcess(Any): # type: ignore
130: class ForkServerProcess(Any): # type: ignore
148: class SpawnProcess(Any): # type: ignore
stdlib\3\types.pyi
81:class SimpleNamespace(Any): ... # type: ignore
stdlib\3\unittest\mock.pyi
34: class NonCallableMock(Any):
tests\pytype_blacklist.txt
11:# Because of 'class ForkProcess(Any): # type: ignore'
third_party\3\jwt\algorithms.pyi
3:class Algorithm(Any): ... # type: ignore
As can be seen, all but one of these are type-ignore'd and thus not picked up by mypy.
The multiprocessing classes have # TODO: type should be BaseProcess once a stub in multiprocessing.process exists, so that should be okay to change, as that module is there.
The types.pyiSimpleNameSpace needed my __setattr__ implementation.
Activity
JelleZijlstra commentedon Jul 4, 2017
Feel free to send some PRs. :)
ignore type for mock.pyi inheritance from Any
srittau commentedon Sep 11, 2018
Updated list:
Some are fixed, the protobuf one is new, but is marked explicitly as "not yet typed".
Annotate jwt.algorithms
Annotate jwt.algorithms (#2532)
Annotate jwt.algorithms (python#2532)
hauntsaninja commentedon Jan 8, 2020
Looks like it's only the protobuf containers one left. Is it worth adding a test to prevent the addition of Any others?
srittau commentedon Jan 8, 2020
I think adding a test to flake8-pyi would make sense.
JelleZijlstra commentedon Jan 8, 2020
It would be better to turn on mypy's
--disallow-subclassing-anyflag (maybe with a type ignore for the protobuf ones).srittau commentedon Jan 8, 2020
Good point.
Enable --disallow-subclassing-any
Enable --disallow-subclassing-any (#3591)