From c86284565ce97de07870379e52a567343d7c4662 Mon Sep 17 00:00:00 2001 From: DeflateAwning <11021263+DeflateAwning@users.noreply.github.com> Date: Tue, 12 Sep 2023 10:12:58 -0600 Subject: [PATCH 1/6] Fix dynamically-set __all__ variable --- git/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/git/__init__.py b/git/__init__.py index 6196a42d7..cc0ca2136 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -61,8 +61,19 @@ def _init_externals() -> None: # } END imports -__all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))] - +# __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__ = ['BadName', 'safe_decode', + 'remove_password_if_present', 'List', 'Sequence', 'Tuple', 'Union', 'TYPE_CHECKING', + 'PathLike', 'GitError', 'InvalidGitRepositoryError', 'WorkTreeRepositoryUnsupported', + 'NoSuchPathError', 'UnsafeProtocolError', 'UnsafeOptionError', 'CommandError', 'GitCommandNotFound', + 'GitCommandError', 'CheckoutError', 'CacheError', 'UnmergedEntriesError', 'HookExecutionError', + 'RepositoryDirtyError', 'Optional', 'GitConfigParser', 'Object', 'IndexObject', 'Blob', 'Commit', + 'Submodule', 'UpdateProgress', 'RootModule', 'RootUpdateProgress', 'TagObject', 'TreeModifier', + 'Tree', 'SymbolicReference', 'Reference', 'HEAD', 'Head', 'TagReference', 'Tag', 'RemoteReference', + 'RefLog', 'RefLogEntry', 'Diffable', 'DiffIndex', 'Diff', 'NULL_TREE', 'GitCmdObjectDB', 'GitDB', + 'Git', 'Repo', 'RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote', 'IndexFile', 'StageType', + 'BlobFilter', 'BaseIndexEntry', 'IndexEntry', 'LockFile', 'BlockingLockFile', 'Stats', 'Actor', 'rmtree'] # { Initialize git executable path GIT_OK = None From 8edc53b7c9be8beebef240b9a2a8fff19b79d21e Mon Sep 17 00:00:00 2001 From: DeflateAwning <11021263+DeflateAwning@users.noreply.github.com> Date: Fri, 6 Oct 2023 12:18:30 -0600 Subject: [PATCH 2/6] Clean up __all__ in main, and explicit imports in exc - explicit imports in exc added to avoid linting errors in __init__ --- git/__init__.py | 88 ++++++++++++++++++++++++++++++++++++++++++------- git/exc.py | 13 ++++++-- 2 files changed, 88 insertions(+), 13 deletions(-) diff --git a/git/__init__.py b/git/__init__.py index cc0ca2136..00e7b8dd3 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -63,17 +63,83 @@ def _init_externals() -> None: # __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__ = ['BadName', 'safe_decode', - 'remove_password_if_present', 'List', 'Sequence', 'Tuple', 'Union', 'TYPE_CHECKING', - 'PathLike', 'GitError', 'InvalidGitRepositoryError', 'WorkTreeRepositoryUnsupported', - 'NoSuchPathError', 'UnsafeProtocolError', 'UnsafeOptionError', 'CommandError', 'GitCommandNotFound', - 'GitCommandError', 'CheckoutError', 'CacheError', 'UnmergedEntriesError', 'HookExecutionError', - 'RepositoryDirtyError', 'Optional', 'GitConfigParser', 'Object', 'IndexObject', 'Blob', 'Commit', - 'Submodule', 'UpdateProgress', 'RootModule', 'RootUpdateProgress', 'TagObject', 'TreeModifier', - 'Tree', 'SymbolicReference', 'Reference', 'HEAD', 'Head', 'TagReference', 'Tag', 'RemoteReference', - 'RefLog', 'RefLogEntry', 'Diffable', 'DiffIndex', 'Diff', 'NULL_TREE', 'GitCmdObjectDB', 'GitDB', - 'Git', 'Repo', 'RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote', 'IndexFile', 'StageType', - 'BlobFilter', 'BaseIndexEntry', 'IndexEntry', 'LockFile', 'BlockingLockFile', 'Stats', 'Actor', 'rmtree'] +__all__ = [ + 'Actor', + 'AmbiguousObjectName', + 'BadName', + 'BadObject', + 'BadObjectType', + 'BaseIndexEntry', + 'Blob', + 'BlobFilter', + 'BlockingLockFile', + 'CacheError', + 'CheckoutError', + 'CommandError', + 'Commit', + 'Diff', + 'DiffIndex', + 'Diffable', + 'FetchInfo', + 'Git', + 'GitCmdObjectDB', + 'GitCommandError', + 'GitCommandNotFound', + 'GitConfigParser', + 'GitDB', + 'GitError', + 'HEAD', + 'Head', + 'HookExecutionError', + 'IndexEntry', + 'IndexFile', + 'IndexObject', + 'InvalidDBRoot', + 'InvalidGitRepositoryError', + 'List', + 'LockFile', + 'NULL_TREE', + 'NoSuchPathError', + 'ODBError', + 'Object', + 'Optional', + 'ParseError', + 'PathLike', + 'PushInfo', + 'RefLog', + 'RefLogEntry', + 'Reference', + 'Remote', + 'RemoteProgress', + 'RemoteReference', + 'Repo', + 'RepositoryDirtyError', + 'RootModule', + 'RootUpdateProgress', + 'Sequence', + 'StageType', + 'Stats', + 'Submodule', + 'SymbolicReference', + 'TYPE_CHECKING', + 'Tag', + 'TagObject', + 'TagReference', + 'Tree', + 'TreeModifier', + 'Tuple', + 'Union', + 'UnmergedEntriesError', + 'UnsafeOptionError', + 'UnsafeProtocolError', + 'UnsupportedOperation', + 'UpdateProgress', + 'WorkTreeRepositoryUnsupported', + 'remove_password_if_present', + 'rmtree', + 'safe_decode', + 'to_hex_sha', +] # { Initialize git executable path GIT_OK = None diff --git a/git/exc.py b/git/exc.py index 775528bf6..0c939f929 100644 --- a/git/exc.py +++ b/git/exc.py @@ -5,8 +5,17 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php """ Module containing all exceptions thrown throughout the git package, """ -from gitdb.exc import BadName # NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614 -from gitdb.exc import * # NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614 +from gitdb.exc import ( + AmbiguousObjectName, + BadName, + BadObject, + BadObjectType, + InvalidDBRoot, + ODBError, + ParseError, + UnsupportedOperation, + to_hex_sha, +) # NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614 from git.compat import safe_decode from git.util import remove_password_if_present From 9ac6bb0b58c88490a8195a62b9b9662bdd538bd6 Mon Sep 17 00:00:00 2001 From: DeflateAwning <11021263+DeflateAwning@users.noreply.github.com> Date: Fri, 6 Oct 2023 12:53:18 -0600 Subject: [PATCH 3/6] Add @UnusedImport to recent changes --- git/exc.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/git/exc.py b/git/exc.py index 0c939f929..936381fd8 100644 --- a/git/exc.py +++ b/git/exc.py @@ -6,16 +6,16 @@ """ Module containing all exceptions thrown throughout the git package, """ from gitdb.exc import ( - AmbiguousObjectName, - BadName, - BadObject, - BadObjectType, - InvalidDBRoot, - ODBError, - ParseError, - UnsupportedOperation, - to_hex_sha, -) # NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614 + AmbiguousObjectName, # @UnusedImport + BadName, # @UnusedImport + BadObject, # @UnusedImport + BadObjectType, # @UnusedImport + InvalidDBRoot, # @UnusedImport + ODBError, # @UnusedImport + ParseError, # @UnusedImport + UnsupportedOperation, # @UnusedImport + to_hex_sha, # @UnusedImport +) from git.compat import safe_decode from git.util import remove_password_if_present From ebd9ce50ebd702b0655384db0d509113c70ad94c Mon Sep 17 00:00:00 2001 From: DeflateAwning <11021263+DeflateAwning@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:03:43 -0600 Subject: [PATCH 4/6] Fix unused import linting --- git/exc.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/git/exc.py b/git/exc.py index 936381fd8..66cf9ad06 100644 --- a/git/exc.py +++ b/git/exc.py @@ -5,16 +5,16 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php """ Module containing all exceptions thrown throughout the git package, """ -from gitdb.exc import ( - AmbiguousObjectName, # @UnusedImport - BadName, # @UnusedImport - BadObject, # @UnusedImport - BadObjectType, # @UnusedImport - InvalidDBRoot, # @UnusedImport - ODBError, # @UnusedImport - ParseError, # @UnusedImport - UnsupportedOperation, # @UnusedImport - to_hex_sha, # @UnusedImport +from gitdb.exc import ( # noqa: @UnusedImport + AmbiguousObjectName, + BadName, + BadObject, + BadObjectType, + InvalidDBRoot, + ODBError, + ParseError, + UnsupportedOperation, + to_hex_sha, ) from git.compat import safe_decode from git.util import remove_password_if_present From b1478bb1091e24dc001798da6d28bb366baf733f Mon Sep 17 00:00:00 2001 From: DeflateAwning <11021263+DeflateAwning@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:19:01 -0600 Subject: [PATCH 5/6] Typo --- git/exc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/exc.py b/git/exc.py index 66cf9ad06..5110d502d 100644 --- a/git/exc.py +++ b/git/exc.py @@ -3,7 +3,7 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -""" Module containing all exceptions thrown throughout the git package, """ +""" Module containing all exceptions thrown throughout the git package """ from gitdb.exc import ( # noqa: @UnusedImport AmbiguousObjectName, From a4eb2b3ea7680ac4da01d72746d9e82aa0cb0422 Mon Sep 17 00:00:00 2001 From: DeflateAwning <11021263+DeflateAwning@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:24:15 -0600 Subject: [PATCH 6/6] black lint --- git/__init__.py | 150 ++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/git/__init__.py b/git/__init__.py index 00e7b8dd3..ef7493079 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -64,81 +64,81 @@ def _init_externals() -> None: # __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__ = [ - 'Actor', - 'AmbiguousObjectName', - 'BadName', - 'BadObject', - 'BadObjectType', - 'BaseIndexEntry', - 'Blob', - 'BlobFilter', - 'BlockingLockFile', - 'CacheError', - 'CheckoutError', - 'CommandError', - 'Commit', - 'Diff', - 'DiffIndex', - 'Diffable', - 'FetchInfo', - 'Git', - 'GitCmdObjectDB', - 'GitCommandError', - 'GitCommandNotFound', - 'GitConfigParser', - 'GitDB', - 'GitError', - 'HEAD', - 'Head', - 'HookExecutionError', - 'IndexEntry', - 'IndexFile', - 'IndexObject', - 'InvalidDBRoot', - 'InvalidGitRepositoryError', - 'List', - 'LockFile', - 'NULL_TREE', - 'NoSuchPathError', - 'ODBError', - 'Object', - 'Optional', - 'ParseError', - 'PathLike', - 'PushInfo', - 'RefLog', - 'RefLogEntry', - 'Reference', - 'Remote', - 'RemoteProgress', - 'RemoteReference', - 'Repo', - 'RepositoryDirtyError', - 'RootModule', - 'RootUpdateProgress', - 'Sequence', - 'StageType', - 'Stats', - 'Submodule', - 'SymbolicReference', - 'TYPE_CHECKING', - 'Tag', - 'TagObject', - 'TagReference', - 'Tree', - 'TreeModifier', - 'Tuple', - 'Union', - 'UnmergedEntriesError', - 'UnsafeOptionError', - 'UnsafeProtocolError', - 'UnsupportedOperation', - 'UpdateProgress', - 'WorkTreeRepositoryUnsupported', - 'remove_password_if_present', - 'rmtree', - 'safe_decode', - 'to_hex_sha', + "Actor", + "AmbiguousObjectName", + "BadName", + "BadObject", + "BadObjectType", + "BaseIndexEntry", + "Blob", + "BlobFilter", + "BlockingLockFile", + "CacheError", + "CheckoutError", + "CommandError", + "Commit", + "Diff", + "DiffIndex", + "Diffable", + "FetchInfo", + "Git", + "GitCmdObjectDB", + "GitCommandError", + "GitCommandNotFound", + "GitConfigParser", + "GitDB", + "GitError", + "HEAD", + "Head", + "HookExecutionError", + "IndexEntry", + "IndexFile", + "IndexObject", + "InvalidDBRoot", + "InvalidGitRepositoryError", + "List", + "LockFile", + "NULL_TREE", + "NoSuchPathError", + "ODBError", + "Object", + "Optional", + "ParseError", + "PathLike", + "PushInfo", + "RefLog", + "RefLogEntry", + "Reference", + "Remote", + "RemoteProgress", + "RemoteReference", + "Repo", + "RepositoryDirtyError", + "RootModule", + "RootUpdateProgress", + "Sequence", + "StageType", + "Stats", + "Submodule", + "SymbolicReference", + "TYPE_CHECKING", + "Tag", + "TagObject", + "TagReference", + "Tree", + "TreeModifier", + "Tuple", + "Union", + "UnmergedEntriesError", + "UnsafeOptionError", + "UnsafeProtocolError", + "UnsupportedOperation", + "UpdateProgress", + "WorkTreeRepositoryUnsupported", + "remove_password_if_present", + "rmtree", + "safe_decode", + "to_hex_sha", ] # { Initialize git executable path