-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Classes should not inherit from Any #1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Feel free to send some PRs. :) |
**Problem**: Any time I run `mypy`, I get an error like `<site-packages>/lib/mypy/typeshed/stdlib/3/unittest/mock.pyi:34: error: Class cannot subclass 'Any' (has type 'Any')` **Analysis**: python#1446 complains about the inheritance from `Any`, among other things, but what's relevant to this PR is where the use of `# type: ignore` is followed everywhere else this inheritance happens. I'm not sure if it's the "right" solution, but adding `# type: ignore` to `mock.pyi`'s use of `Any` resolves the error message I keep seeing. It also passes all of the [tests requested](https://github.com/python/typeshed/blob/master/README.md#running-the-tests). **Resolution**: I added the same `# type: ignore` comment to the inheritance from `Any` in `mock.pyi` that is used in other places that that inheritance is done. **Documentation**: No docs modified/added for this change. **Testing**: Ran the [tests](https://github.com/python/typeshed/blob/master/README.md#running-the-tests) locally on osx 10.11.6, and they all passed. **Impact**: Patch - ignoring an illegal type inheritance that appears to work but is flagged by mypy (and is ignored in other areas of typeshed code).
Updated list:
Some are fixed, the protobuf one is new, but is marked explicitly as "not yet typed". |
Looks like it's only the protobuf containers one left. Is it worth adding a test to prevent the addition of Any others? |
I think adding a test to flake8-pyi would make sense. |
It would be better to turn on mypy's |
Good point. |
Several classes in typeshed inherit from
Any
, and should not.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.
The text was updated successfully, but these errors were encountered: