Skip to content
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

Merged
merged 7 commits into from Oct 6, 2022
Merged

Add @typing.override #78

merged 7 commits into from Oct 6, 2022

Conversation

JelleZijlstra
Copy link
Member

No description provided.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a 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

src/typing_extensions.py Outdated Show resolved Hide resolved
@JelleZijlstra
Copy link
Member Author

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.

@JelleZijlstra
Copy link
Member Author

@stroxler could you take a look? The docstring is probably the only interesting part.

Copy link
Contributor

@stroxler stroxler left a 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!

src/typing_extensions.py Outdated Show resolved Hide resolved
Co-authored-by: Steven Troxler <steven.troxler@gmail.com>
Comment on lines +2007 to +2009
_F = typing.TypeVar("_F", bound=typing.Callable[..., typing.Any])

def override(__arg: _F) -> _F:
Copy link
Contributor

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?

Copy link
Collaborator

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.

Copy link
Member

@AlexWaygood AlexWaygood left a 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.

src/test_typing_extensions.py Show resolved Hide resolved
src/typing_extensions.py Outdated Show resolved Hide resolved
Comment on lines +2103 to +2104
This helps prevent bugs that may occur when a base class is changed
without an equivalent change to a child class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member Author

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.

Copy link
Member

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>
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

Successfully merging this pull request may close these issues.

None yet

5 participants