Why mypy is failing when running this code:
$ cat /tmp/test.py from git import Blob
$ mypy /tmp/test.py
/tmp/test.py:1: error: Module "git" has no attribute "Blob"
Found 1 error in 1 file (checked 1 source file)
$ python3 -c "import git; print(git.__version__)"
3.1.23
$ mypy --version
mypy 0.910
$ python3 --version
Python 3.9.7
?
I can see that there is a conditional import in git/objects/base.py:
ifTYPE_CHECKING:
fromgit.repoimportRepofromgitdb.baseimportOStreamfrom .treeimportTreefrom .blobimportBlobfrom .submodule.baseimportSubmodulefromgit.refs.referenceimport
and it seems that TYPE_CHECKING is set to False (I guess so based on the above error). Do you know why is that? How to workaround the problem?
Why
mypyis failing when running this code:?
I can see that there is a conditional import in
git/objects/base.py:and it seems that
TYPE_CHECKINGis set toFalse(I guess so based on the above error). Do you know why is that? How to workaround the problem?