Skip to content

Classes should not inherit from Any #1446

@emmatyping

Description

@emmatyping

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.pyi SimpleNameSpace needed my __setattr__ implementation.

Apparently the same for NonCallableMock

JWT stubs just seem very incomplete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: improvementImprove/refactor existing annotations, other stubs issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions