It’s not entirely clear how one is supposed to name GitPython’s exceptions:
- According to the API reference, they live in the
git.exc module.
- In
__init__.py, the very first line does from git.exp import *, meaning they can actually just be referenced in the git module instead if one wishes (is that intentional/public knowledge?).
Then, further down __init__.py, there are two places where except Something as exc is done in module-level code. While those won’t execute on success (and will prevent the module from importing on failure), they do confuse Pylint: if I try to except git.exc.InvalidGitRepositoryError in my own code and then lint it, Pylint complains that Instance of 'GitError' has no 'InvalidGitRepositoryError' member, because it believes the name git.exc itself might actually be an instance of GitError (as it would be if this except clause were taken).
Is it intended that we refer to exception classes from git rather than git.exc? If so, could the documentation be updated? If not—if we are not supposed to know about the from git.exc import *—could the variable names used in those except blocks be modified to not collide with a submodule name?
It’s not entirely clear how one is supposed to name GitPython’s exceptions:
git.excmodule.__init__.py, the very first line doesfrom git.exp import *, meaning they can actually just be referenced in thegitmodule instead if one wishes (is that intentional/public knowledge?).Then, further down
__init__.py, there are two places whereexcept Something as excis done in module-level code. While those won’t execute on success (and will prevent the module from importing on failure), they do confuse Pylint: if I try toexcept git.exc.InvalidGitRepositoryErrorin my own code and then lint it, Pylint complains thatInstance of 'GitError' has no 'InvalidGitRepositoryError' member, because it believes the namegit.excitself might actually be an instance ofGitError(as it would be if thisexceptclause were taken).Is it intended that we refer to exception classes from
gitrather thangit.exc? If so, could the documentation be updated? If not—if we are not supposed to know about thefrom git.exc import *—could the variable names used in thoseexceptblocks be modified to not collide with a submodule name?