Skip to content

Add parse_tag limit for compressed tags#1224

Merged
henryiii merged 3 commits into
pypa:mainfrom
trail-of-forks:ft/limit-parsed-tags
Jun 29, 2026
Merged

Add parse_tag limit for compressed tags#1224
henryiii merged 3 commits into
pypa:mainfrom
trail-of-forks:ft/limit-parsed-tags

Conversation

@facutuesca

Copy link
Copy Markdown
Contributor

This PR adds a new kw-only parameter to parse_tags() to limit the amout of tags that can be generated from compressed tags. If the limit is exceeded, a new exception (TooManyTagsError) is raised.

The parameter is limit: int | None and defaults to None.

Fixes #1220

@henryiii

Copy link
Copy Markdown
Contributor

This one does need a rebase, has merge conflicts!

@brettcannon brettcannon self-requested a review June 11, 2026 21:37

@brettcannon brettcannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are unfortunately merge conflicts.

Comment thread src/packaging/tags.py Outdated
Comment thread tests/test_tags.py
@facutuesca facutuesca force-pushed the ft/limit-parsed-tags branch from 4544c0e to 8ca6def Compare June 11, 2026 21:50
@facutuesca facutuesca requested a review from brettcannon June 11, 2026 22:32
@henryiii

Copy link
Copy Markdown
Contributor

FWIW, there's one other place this is used; it's part of parse_wheel_filename. We could add a kwarg there, or we could just wait till #1113 and make sure it's part of that when it lands (currently on hold waiting for wheel variants).

@brettcannon

Copy link
Copy Markdown
Member

I say it can wait for #1113 as this protection is for being extra cautious and not something that is a critical concern, but if @facutuesca wants to add a keyword argument I'm also okay with taking that change.

@brettcannon

Copy link
Copy Markdown
Member

@facutuesca do you mind fixing the merge conflicts (I don't have permissions to do it myself)?

@facutuesca facutuesca force-pushed the ft/limit-parsed-tags branch from 248ac24 to bf04bac Compare June 29, 2026 19:07
@facutuesca

Copy link
Copy Markdown
Contributor Author

@facutuesca do you mind fixing the merge conflicts (I don't have permissions to do it myself)?

fixed!

@henryiii henryiii enabled auto-merge (squash) June 29, 2026 19:09
@henryiii henryiii merged commit 4c362e3 into pypa:main Jun 29, 2026
69 checks passed
@facutuesca facutuesca deleted the ft/limit-parsed-tags branch June 29, 2026 19:27
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.

Limiting the maximum number of tags on Tag.parse_tag()

3 participants