Skip to content

Commit

Permalink
Add refresh to top-level __all__
Browse files Browse the repository at this point in the history
This makes the git.refresh function unambiguously public.

git.refresh was already public in the sense that it was explicitly
documented as appropriate to call from code outside GitPython.
However, it had not been included in git.__all__.

Because __all__ existed but omitted "refresh", git.refresh had
appeared non-public to automated tools.

This also does some cleanup:

- It removes a comment that showed how git.__all__ had been defined
  dynamically before gitpython-developers#1659, since with the addition of "refresh",
  git.__all__ no longer contains exactly the same elements as that
  technique produced (as it examined the module's contents prior to
  running the def statement that bound the name "refresh").

- With that comment removed, it is no longer necessary to define
  __all__ below the imports to show what the dynamic techinque had
  operated on. So this moves it up above them in accordance with
  PEP-8.
  • Loading branch information
EliahKagan committed Mar 5, 2024
1 parent b2c3d8b commit de10791
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,6 @@

# @PydevCodeAnalysisIgnore

__version__ = "git"

from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING

from gitdb.util import to_hex_sha
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8
from git.types import PathLike

try:
from git.compat import safe_decode # @NoMove @IgnorePep8
from git.config import GitConfigParser # @NoMove @IgnorePep8
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
from git.cmd import Git # @NoMove @IgnorePep8
from git.repo import Repo # @NoMove @IgnorePep8
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
from git.util import ( # @NoMove @IgnorePep8
LockFile,
BlockingLockFile,
Stats,
Actor,
remove_password_if_present,
rmtree,
)
except GitError as _exc: # noqa: F405
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc

# __all__ must be statically defined by py.typed support
# __all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))]
__all__ = [ # noqa: F405
"Actor",
"AmbiguousObjectName",
Expand Down Expand Up @@ -109,12 +77,43 @@
"UnsupportedOperation",
"UpdateProgress",
"WorkTreeRepositoryUnsupported",
"refresh",
"remove_password_if_present",
"rmtree",
"safe_decode",
"to_hex_sha",
]

__version__ = "git"

from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING

from gitdb.util import to_hex_sha
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8
from git.types import PathLike

try:
from git.compat import safe_decode # @NoMove @IgnorePep8
from git.config import GitConfigParser # @NoMove @IgnorePep8
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
from git.cmd import Git # @NoMove @IgnorePep8
from git.repo import Repo # @NoMove @IgnorePep8
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
from git.util import ( # @NoMove @IgnorePep8
LockFile,
BlockingLockFile,
Stats,
Actor,
remove_password_if_present,
rmtree,
)
except GitError as _exc: # noqa: F405
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc

# { Initialize git executable path
GIT_OK = None

Expand Down

0 comments on commit de10791

Please sign in to comment.