Skip to content

v5.4.0 breaks PretrainedConfig type checking #45071

Closed

Description

@fynnsu

System Info

transformers 5.4.0
mypy 1.19.1
python 3.10

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

# transformers_typing.py
from transformers import LlamaConfig
llama_config = LlamaConfig(vocab_size=32000)

Run mypy type checker

mypy transformers_typing.py

Output:

transformers_typing.py:3: error: Unexpected keyword argument "vocab_size" for "LlamaConfig"  [call-arg]
Found 1 error in 1 file (checked 1 source file)

Note: It's not just vocab_size that's missing. As far as I can tell, this fails with all config attributes.

Expected behavior

Type checking passes. Note: this is the case for transformers<5.4.0.

Activity

  1. added a commit that references this issue on Mar 27, 2026
  2. Rocketknight1 commented on Apr 2, 2026

    @Rocketknight1
    Member

    We don't guarantee mypy compatibility unfortunately! If someone can find a clean fix that restores it, we might merge that PR, but we don't want to add a lot of code complexity to do it

  3. shhKnight30 commented on Apr 5, 2026

    @shhKnight30
    Contributor

    @Rocketknight1 please look at my PR once

  4. zucchini-nlp commented on Apr 9, 2026

    @zucchini-nlp
    Member

    @fynnsu hey, we'll merge the suggestion from @shhKnight30

    We don't guarantee that mypy would work, indeed. Instead, we are slowly moving towards making transformers ty-compatible, and I can confirm that ty complains about the same things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions