Skip to content

Fix HfArgumentParser on Python 3.15 - #50651

Open
qgallouedec wants to merge 1 commit into
mainfrom
hf-argparser-frozendict
Open

qgallouedec wants to merge 1 commit into
mainfrom
hf-argparser-frozendict

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

🤗 Transformers CI

Fixes #50650

On Python 3.15, a dataclass field declared without metadata gets an empty frozendict, whose copy() is still a frozendict, so kwargs.pop("aliases", []) raised. dict(field.metadata) gives a mutable copy on every Python version.

tests/utils/test_hf_argparser.py on Python 3.15.1: 13 failed on main, 15 passed (2 skipped) with this PR. 17 passed on Python 3.13. These existing tests already cover the fix once CI runs Python 3.15, so no new test.

On Python 3.15, a field declared without metadata gets an empty frozendict, whose copy() is still a frozendict, so the parser's pop() failed.
@qgallouedec
qgallouedec requested a review from SunMarc November 12, 2026 10:46
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

This branch has not been deployed

No deployments
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.

HfArgumentParser fails on Python 3.15: 'frozendict' object has no attribute 'pop'

2 participants