Skip to content

Many redundant methods in subclasses #229

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

Closed
rwbarton opened this issue May 28, 2016 · 2 comments
Closed

Many redundant methods in subclasses #229

rwbarton opened this issue May 28, 2016 · 2 comments

Comments

@rwbarton
Copy link
Contributor

For example, dict is a subclass of MutableMapping and hence also Mapping and other classes, and almost all of dict's methods are actually provided by one of those superclasses with the same signature. Is there a good reason to repeat the declarations of these methods in dict? (Perhaps they predate dict's superclasses?) I tried removing get and there seemed to be no ill effects.

One possible reason: it's convenient to see the types of all of dict's methods in one place. But it also creates more work when changing these types, as in #223. For being able to see all the methods of dict at once, we could have mypy automatically generate documentation (or perhaps a python documentation tool already understands function annotations).

@gvanrossum
Copy link
Member

I think it's mostly a historical accident. I would generally discourage people from reading the stubs as a form of documentation, they're really not meant for that.

momandine pushed a commit to momandine/typeshed that referenced this issue Jul 5, 2016
@srittau
Copy link
Collaborator

srittau commented Sep 11, 2018

I am going to close this. While those redundant definitions are not harmful, we gladly accept patches that will remove these redundancies.

@srittau srittau closed this as completed Sep 11, 2018
hswong3i pushed a commit to alvistack/python-typeshed that referenced this issue May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants