Skip to content

3.14: PEP-784 compression except zstd - #13992

Merged
srittau merged 5 commits into
python:mainfrom
Rogdham:pep-784_compression
May 11, 2025
Merged

srittau merged 5 commits into
python:mainfrom
Rogdham:pep-784_compression

Conversation

@Rogdham

@Rogdham Rogdham commented May 10, 2025 •

Copy link
Copy Markdown
Contributor

First PR about PEP-784 in sdlib:

  • Re-export bz2/gzip/lzma/zlib in compression.*
  • Copy _compression into compression._common._streams, and re-export the latter from the former
  • Modify the stubtest_allowlists for 3.14 accordingly (the additions are copied that already exists in the non-compression modules)

For the last point, I did not find a better way than copying the file, because only one of the two modules exist depending on Python version (so cannot import from the other) ▶️ feel free to suggest a better idea! (or tell if I should add a comment about that somewhere)

Adding compression.zstd will be done in a distinct PR.

@github-actions

This comment has been minimized.

@python python deleted a comment May 10, 2025
@Rogdham
Rogdham force-pushed the pep-784_compression branch from 27b8b34 to 06181bc Compare May 10, 2025 20:01
@github-actions

This comment has been minimized.

@Rogdham
Rogdham force-pushed the pep-784_compression branch from 06181bc to e728c53 Compare May 10, 2025 20:12
@github-actions

This comment has been minimized.

@Rogdham
Rogdham force-pushed the pep-784_compression branch 2 times, most recently from 562bf17 to 24dafa3 Compare May 10, 2025 21:12
@github-actions

This comment has been minimized.

@Rogdham
Rogdham marked this pull request as ready for review May 10, 2025 21:26
@srittau

srittau commented May 10, 2025

Copy link
Copy Markdown
Collaborator

There's a (small) merge conflict now due to allowlist changes.

One request: Please don't force push here as that makes reviewing harder. We squash on merge anyway.

@Rogdham

Rogdham commented May 10, 2025

Copy link
Copy Markdown
Contributor Author

Conflict should be resolved now.

Sorry for the force-pushes earlier, I thought it was ok while the PR had the draft status.

@github-actions

This comment has been minimized.

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, a few remarks below.

Comment thread stdlib/compression/_common/_streams.pyi Outdated
@@ -0,0 +1,25 @@
from _typeshed import WriteableBuffer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
from _typeshed import WriteableBuffer
from _typeshed import Incomplete, WriteableBuffer

See below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just copied that file from _compression.pyi without any changes, should I make the requested changes on _compression.pyi as well?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That would be great, thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That should be done now!

Do you have any thoughts on the code duplication between the two? Like a way to remove the duplication, or if I should add a comment on both files telling that the other should probably be updated at the same time.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe it would make sense to add a comment to the top of _compression.pyi to copy all changes to compression.*. I don't think the reverse direction is as important (and often the changes won't apply to older Python versions anyway.) Maybe add a comment to DecompressReader.decomp_factory in case someone actually adds a proper return type at some point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have added the two comments, hopefully the wording is ok

Comment thread stdlib/compression/_common/_streams.pyi Outdated
Comment thread stdlib/compression/_common/_streams.pyi Outdated
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

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

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