GeezerVison is showing github.com — Fix warning in Pyright ("Repo" not exported from module "git") · Issue #1656 · gitpython-developers/GitPython
Fix warning in Pyright ("Repo" not exported from module "git") #1656
Description
In Pyright, the following line of code causes the following error:
import git
gitRepo = git.Repo(__file__)
Error:

Activity
EliahKagan commented on Sep 12, 2023
I think this happens because git.__all__ is built dynamically:
|
__all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))] |
Although "Repo" is in it, it's not given literally, and with pyright being a static analyzer, it cannot figure that out.
There are some other places where * imports are used that I expect might produce a similar effect, albeit for attributes that might be absent rather than attributes that might be considered private.
Byron commented on Sep 12, 2023
Thanks for posting, and thanks for the analysis @EliahKagan!
Spelling out __all__ should be easy enough and since GitPython is very stable, I don't think maintaining it would be a problem anymore. Since GitPython started to support type annotation, I think it's worth it to try make it even more useful, to get more mileage out of it.
Reacted by Eliah Kagan and Philipp Temminghoff
DeflateAwning commented on Oct 17, 2023
ContributorAuthor
More actions
This issue is resolved with #1659
Metadata
Metadata
Development
No branches or pull requestsIssue actions