-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Delete many redundant method redefinitions #6877
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
Conversation
This comment has been minimized.
This comment has been minimized.
I assume |
This comment has been minimized.
This comment has been minimized.
More likely it distinguishes between classes that override |
So as a corollary, we should not remove any other |
Sure, that makes sense for |
This comment has been minimized.
This comment has been minimized.
I don't have time to look into the details right now (got a lot of things to catch up with), but I believe mypy's logic for unsafe |
I'm reverting it as we speak, dw! Was just curious, it's obvs not your job to figure it out for me :) |
|
||
class _ExceptionWithTraceback: | ||
exc: BaseException | ||
tb: TracebackType | ||
def __init__(self, exc: BaseException, tb: TracebackType) -> None: ... | ||
def __reduce__(self) -> str | tuple[Any, ...]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure about this since I could imagine a type checker checking whether an object can be pickled safely and checking __reduce__
overrides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've changed your tune ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I just default to not making changes when we don't have a clear reason for change :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A sound policy.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Thanks! |
All classes implicitly inherit from
object
in Python 3, so it's almost never necessary to explicitly define__str__
or__repr__
in the stubs (there are a few exceptions, if it's e.g. marked as an abstract method in a base class).I haven't touched any of the files in the
stubs
directory in this PR, as some of those need compatibility with Python 2; this PR only touches the standard-library stubs.