summaryrefslogtreecommitdiff
path: root/git/exc.py
diff options
context:
space:
mode:
authoryobmod <yobmod@gmail.com>2021-05-03 15:59:07 +0100
committeryobmod <yobmod@gmail.com>2021-05-03 15:59:07 +0100
commit6752fad0e93d1d2747f56be30a52fea212bd15d6 (patch)
treea0618d53d06f35d7326fcacdcaf1832d7ab55b8c /git/exc.py
parent2fd9f6ee5c8b4ae4e01a40dc398e2768d838210d (diff)
downloadgitpython-6752fad0e93d1d2747f56be30a52fea212bd15d6.tar.gz
add initial types to remote.py
Diffstat (limited to 'git/exc.py')
-rw-r--r--git/exc.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/git/exc.py b/git/exc.py
index c02b2b3a..6e646921 100644
--- a/git/exc.py
+++ b/git/exc.py
@@ -5,14 +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 git.compat import safe_decode
# typing ----------------------------------------------------
-from git.repo.base import Repo
+from typing import IO, List, Optional, Tuple, Union, TYPE_CHECKING
from git.types import PathLike
-from typing import IO, List, Optional, Tuple, Union
+
+if TYPE_CHECKING:
+ from git.repo.base import Repo
# ------------------------------------------------------------------
@@ -63,10 +66,12 @@ class CommandError(GitError):
status = "'%s'" % s if isinstance(status, str) else s
self._cmd = safe_decode(command[0])
- self._cmdline = ' '.join(str(safe_decode(i)) for i in command)
+ self._cmdline = ' '.join(safe_decode(i) for i in command)
self._cause = status and " due to: %s" % status or "!"
- self.stdout = stdout and "\n stdout: '%s'" % safe_decode(str(stdout)) or ''
- self.stderr = stderr and "\n stderr: '%s'" % safe_decode(str(stderr)) or ''
+ stdout_decode = safe_decode(stdout)
+ stderr_decode = safe_decode(stderr)
+ self.stdout = stdout_decode and "\n stdout: '%s'" % stdout_decode or ''
+ self.stderr = stderr_decode and "\n stderr: '%s'" % stderr_decode or ''
def __str__(self) -> str:
return (self._msg + "\n cmdline: %s%s%s") % (
@@ -142,7 +147,7 @@ class HookExecutionError(CommandError):
class RepositoryDirtyError(GitError):
"""Thrown whenever an operation on a repository fails as it has uncommitted changes that would be overwritten"""
- def __init__(self, repo: Repo, message: str) -> None:
+ def __init__(self, repo: 'Repo', message: str) -> None:
self.repo = repo
self.message = message