From e49327dbe5ecd792d3c354155b6f186b31409c33 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 23 Feb 2024 19:51:39 -0500 Subject: [PATCH] Add refresh to top-level __all__ 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 #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. --- git/__init__.py | 63 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/git/__init__.py b/git/__init__.py index ed8a88d4b..ac211f9b9 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -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", @@ -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