Skip to content

Commit

Permalink
Deprecate public access to typing imports in git
Browse files Browse the repository at this point in the history
This adds comments to entries in git.__all__ for each of the
entries that come from the standard library typing module, noting
them as deprecated.

These imports were included in __all__ inadvertently due to the
way __all__ was dynamically constructed, and placed in __all__
explicitly when __all__ became static in gitpython-developers#1659. They are there for
backward compatibility, in case some code relies on them being
there. But a module is unlikely to rely intentionally on the git
module providing them, since they are not conceptually related to
GitPython.

`from git import *` should not typically be used, since wildcard
imports are not generally recommended, as discussed in PEP-8. But
if someone does choose to use it, they would probably benefit less
from DeprecationWarning being issued for each of those names than
they would usually benefit from DeprecationWarning. This could lead
to developers deciding not to enable DeprecationWarning when it may
otherwise be useful. For this reason, no attempt is currently made
to issue DeprecationWarning when those names are accessed as
attributes of the git module.
  • Loading branch information
EliahKagan committed Feb 24, 2024
1 parent 7c69fae commit bd0ffe6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
"IndexObject",
"InvalidDBRoot",
"InvalidGitRepositoryError",
"List",
"List", # Deprecated - import this from `typing` instead.
"LockFile",
"NULL_TREE",
"NoSuchPathError",
"ODBError",
"Object",
"Optional",
"Optional", # Deprecated - import this from `typing` instead.
"ParseError",
"PathLike",
"PushInfo",
Expand All @@ -58,19 +58,19 @@
"RepositoryDirtyError",
"RootModule",
"RootUpdateProgress",
"Sequence",
"Sequence", # Deprecated - import this from `typing` instead.
"StageType",
"Stats",
"Submodule",
"SymbolicReference",
"TYPE_CHECKING",
"TYPE_CHECKING", # Deprecated - import this from `typing` instead.
"Tag",
"TagObject",
"TagReference",
"Tree",
"TreeModifier",
"Tuple",
"Union",
"Tuple", # Deprecated - import this from `typing` instead.
"Union", # Deprecated - import this from `typing` instead.
"UnmergedEntriesError",
"UnsafeOptionError",
"UnsafeProtocolError",
Expand Down

0 comments on commit bd0ffe6

Please sign in to comment.