Skip to content

In email.feedparser, BytesFeedParser is a subclass of FeedParser #11110

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

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

tungol
Copy link
Contributor

@tungol tungol commented Dec 6, 2023

related to #3968

@overload
def __init__(self: BytesFeedParser[Message], _factory: None = None, *, policy: Policy = ...) -> None: ...
@overload
def __init__(self, _factory: Callable[[], _MessageT], *, policy: Policy = ...) -> None: ...
def feed(self, data: bytes | bytearray) -> None: ...
def feed(self, data: bytes | bytearray) -> None: ... # type: ignore[override]
def close(self) -> _MessageT: ...
Copy link
Contributor Author

@tungol tungol Dec 6, 2023

Choose a reason for hiding this comment

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

I think we need to keep the redefinition of __init__ even though it's not actually redefined in the subclass in cpython, due to the typing on the self argument.

That said, the redefinition of close() here could be removed. it's identical to that of the superclass. I wasn't sure whether that meant that it should be removed or not. In the end it kept the diff very simple to leave it alone, so that's what I did.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We generally remove redundant definitions in sub-classes, especially if they aren't defined in the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - I removed it.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Dec 7, 2023

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit e915cb2 into python:main Dec 7, 2023
@tungol tungol deleted the email branch December 7, 2023 10:35
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.

2 participants