-
-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mypy is failing on from git import Blob
#1349
Comments
Thanks for letting us know. If However, it looks like it should rather be imported from |
Initial thoughts are that the import from .blob is a relative import in the objects module, and the if TYPE_CHECKING is true for mypy, so I dont think that is the problem. mypy is working on all those files in CI What is test.py? Your own code? Can I see it? I do know mypy doesn't work on our test files, because it doesn't like imports like from git import Blob, where Blob is defined in a submodule (then imported in the parent module as a * import) You might just be able to change a mypy setting to get it to pass. E.g allow_reexport = True and strict = False (see the mypy settings in our pyproject.toml.) if using strict, the order of settings also makes a difference). If changing the import or mypy settings fixes it, let me know. |
This is a single-line script – see my post above: $ cat /tmp/test.py
from git import Blob |
SSCCEpython3.7 -m venv venv
venv/bin/pip install GitPython==3.1.24 mypy==0.910
vim sscce.py import git
git.Repo venv/bin/python sscce.py # runs fine
venv/bin/mypy --strict sscce.py Expected
Observed
NotesI suspect this is the same problem as pallets/click#1879 (related: python/mypy#10198). |
All `from <module> import *` has now been replaced by `from <module> import X, Y, ...`. Contributes to #1349
What feedback is this waiting on? |
Thanks for the hint, probably unintended. |
I believe the root cause of this issue is that the top-level Unfortunately, if I'm right, the fix may be to explicitly list all of the symbols intended to be exported from |
Why
mypy
is failing when running this code:?
I can see that there is a conditional import in
git/objects/base.py
:and it seems that
TYPE_CHECKING
is set toFalse
(I guess so based on the above error). Do you know why is that? How to workaround the problem?The text was updated successfully, but these errors were encountered: