Skip to content

Fix annotations reader for python 3.14 in PreTrainedModel#44672

Merged
Rocketknight1 merged 1 commit intohuggingface:mainfrom
neo:py314-annotations
Mar 19, 2026
Merged

Fix annotations reader for python 3.14 in PreTrainedModel#44672
Rocketknight1 merged 1 commit intohuggingface:mainfrom
neo:py314-annotations

Conversation

@neo
Copy link
Copy Markdown
Contributor

@neo neo commented Mar 13, 2026

What does this PR do?

There's an issue in Python 3.14 that __annotations__ is not available anymore because of an implementation change (ref), and it breaks the config retrieving logic.

This fix would use the recommended reader to properly get the annotations.

This is similar to and trying to fix the same issue as #44165, but it should hopefully look and feel less risky.

(I hope this can also be patched back to v4)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@Rocketknight1 @ArthurZucker @Cyrilvallez @vasqu

@Rocketknight1
Copy link
Copy Markdown
Member

This LGTM, and is a much cleaner fix! It will not work on Python 3.9 or earlier, but these are now EOL and no longer supported, so I think it's okay.

@Rocketknight1 Rocketknight1 enabled auto-merge March 18, 2026 16:02
@neo
Copy link
Copy Markdown
Contributor Author

neo commented Mar 18, 2026

Thank you @Rocketknight1! ❤️

I do wonder if we're going to backport this to another v4 release 😳

@Rocketknight1 Rocketknight1 added this pull request to the merge queue Mar 18, 2026
@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.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Mar 18, 2026
@Rocketknight1 Rocketknight1 added this pull request to the merge queue Mar 19, 2026
@Rocketknight1
Copy link
Copy Markdown
Member

@neo unlikely unfortunately, backports to v4 are generally not happening!

Merged via the queue into huggingface:main with commit be6cf08 Mar 19, 2026
28 checks passed
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.

3 participants