Add __all__
in git.exc by EliahKagan · Pull Request #1719 · gitpython-developers/GitPython (original) (raw)
Fixes #1718
This adds __all__
in git.exc
, and adjusts __init__.py
imports.
The git.exc
module imports exceptions from gitdb.exc
to republish them, as well as defining its own (also for use from outside). But because it did not define __all__
, the intent for the exceptions it imported was unclear, since names that are introduced by imports and not present in __all__
are not generally considered public, even when __all__
is absent and a *
import would reimport them.
This rectifies that by adding __all__
and listing both imported and newly introduced exceptions explicitly in it. Although this strictly expands which names are public under typical conventions, it strictly contracts which names are imported by a *
import, because the presence of __all__
suppresses names not listed in it from being imported that way. However, because under typical conventions those other names are not considered public, and they were not even weakly documented as public, this should be okay.
(Even though this is not a breaking change, in that code it would break would already technically be broken... if it turns out that it is common to wrongly rely on the availability of those names, then this may need to be revisited and slightly modified.)
This brings the readily identified public interface of git.exc
in line with what is weakly implied (and intended) by its docstring.
This also modifies __init__.py
accordingly: The top-level git module has for some time used a *
import on git.exc
, causing the extra names originally meant as implementation details to be included. Because its own __all__
was dynamically generated until c862845, #1659 also added 8edc53b to retain the formerly present names in __all__
. So the change here imports those names from the modules that deliberately provide them, to preserve compatibility.