Description
Ubuntu 21.04, tested on both Python 3.8 and Python 3.9 with mypy 0.910
I get a crash caused by transformers 4.10.0
when typechecking a private codebase which imports transformers. This is the error message:
src/transformers/trainer.py:1435: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.910
(I also get the crash trying mypy master. I'm going to submit a corresponding bug report directly to the mypy issue tracker.)
This is the corresponding line:
transformers/src/transformers/trainer.py
Line 1435 in b91e65a
That method is imported into the class, which presumably upsets mypy somehow.
Repro
I can reproduce this locally in the following way:
- Clone the transformers repo
- Create a blank virtualenv and install mypy 0.910
- Add the following
mypy.ini
file:[mypy] check_untyped_defs=True
- Run
mypy src/transformers/trainer.py
Confusingly, this local repro method also crashes mypy when using the 4.9.1 tag, but I don't experience the crash in my private codebase when using that transformers version 🤷
cc @sgugger