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
Add @typing.override #78
Conversation
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.
Looks good, assuming you don't want any runtime recording of override
Thanks! The PEP specifies that there's no runtime effect, so that's what we're doing. |
@stroxler could you take a look? The docstring is probably the only interesting part. |
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.
Looks good to me, thanks @JelleZijlstra!
Co-authored-by: Steven Troxler <steven.troxler@gmail.com>
_F = typing.TypeVar("_F", bound=typing.Callable[..., typing.Any]) | ||
|
||
def override(__arg: _F) -> _F: |
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.
Just asking, my understanding was that types should not be added here and only provided via typeshed. I can't find a reference for it unfortunately. Did I miss something?
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.
It is true that type checkers will not look at this code. But types have value as documentation and perhaps some niche value for dynamic introspection.
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.
Looks good! Some minor suggestions on docs/tests.
This helps prevent bugs that may occur when a base class is changed | ||
without an equivalent change to a child class. |
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.
This helps prevent bugs that may occur when a base class is changed | |
without an equivalent change to a child class. | |
This helps prevent bugs that may occur when a method on a base class is renamed | |
without an equivalent change to a child class. |
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 prefer the current more general wording. For example, the base class method could be removed instead of renamed.
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.
Oh, good point. Ignore this then :)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
No description provided.