Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added type hints #8354

Merged
merged 4 commits into from
Sep 8, 2024
Merged

Added type hints #8354

merged 4 commits into from
Sep 8, 2024

Conversation

radarhere
Copy link
Member

No description provided.

tox.ini Show resolved Hide resolved
Comment on lines 2111 to 2120
if sys.version_info >= (3, 12):
from collections.abc import Buffer

def write(self, data: Buffer, /) -> int:
return self.f.write(data)

else:

def write(self, data: Any, /) -> int:
return self.f.write(data)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps something like this?

Suggested change
if sys.version_info >= (3, 12):
from collections.abc import Buffer
def write(self, data: Buffer, /) -> int:
return self.f.write(data)
else:
def write(self, data: Any, /) -> int:
return self.f.write(data)
if sys.version_info >= (3, 12):
from collections.abc import Buffer
else:
Buffer = Any
def write(self, data: Buffer, /) -> int:
return self.f.write(data)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I've actually moved Buffer into src/PIL/_typing.py so that this change can occur for GifImagePlugin cleanly as well.

@radarhere radarhere force-pushed the type_hint branch 2 times, most recently from 253f6d9 to f6f9c8c Compare September 7, 2024 21:01
@hugovk hugovk merged commit f30eefa into python-pillow:main Sep 8, 2024
65 of 66 checks passed
@radarhere radarhere deleted the type_hint branch September 8, 2024 13:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants