Skip to content

Commit e530544

Browse files
committed
reformat according to 'black' configuration file.
1 parent f78fc42 commit e530544

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+577
-1753
lines changed

doc/source/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444

4545
# General information about the project.
4646
project = "GitPython"
47-
copyright = (
48-
"Copyright (C) 2008, 2009 Michael Trier and contributors, 2010-2015 Sebastian Thiel"
49-
)
47+
copyright = "Copyright (C) 2008, 2009 Michael Trier and contributors, 2010-2015 Sebastian Thiel"
5048

5149
# The version info for the project you're documenting, acts as replacement for
5250
# |version| and |release|, also used in various other places throughout the

git/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ def _init_externals() -> None:
6161

6262
# } END imports
6363

64-
__all__ = [
65-
name
66-
for name, obj in locals().items()
67-
if not (name.startswith("_") or inspect.ismodule(obj))
68-
]
64+
__all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))]
6965

7066

7167
# { Initialize git executable path

git/cmd.py

Lines changed: 31 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,8 @@ def handle_process_output(
9797
Callable[[List[AnyStr]], None],
9898
Callable[[bytes, "Repo", "DiffIndex"], None],
9999
],
100-
stderr_handler: Union[
101-
None, Callable[[AnyStr], None], Callable[[List[AnyStr]], None]
102-
],
103-
finalizer: Union[
104-
None, Callable[[Union[subprocess.Popen, "Git.AutoInterrupt"]], None]
105-
] = None,
100+
stderr_handler: Union[None, Callable[[AnyStr], None], Callable[[List[AnyStr]], None]],
101+
finalizer: Union[None, Callable[[Union[subprocess.Popen, "Git.AutoInterrupt"]], None]] = None,
106102
decode_streams: bool = True,
107103
kill_after_timeout: Union[None, float] = None,
108104
) -> None:
@@ -144,14 +140,10 @@ def pump_stream(
144140
handler(line)
145141

146142
except Exception as ex:
147-
log.error(
148-
f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}"
149-
)
143+
log.error(f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}")
150144
if "I/O operation on closed file" not in str(ex):
151145
# Only reraise if the error was not due to the stream closing
152-
raise CommandError(
153-
[f"<{name}-pump>"] + remove_password_if_present(cmdline), ex
154-
) from ex
146+
raise CommandError([f"<{name}-pump>"] + remove_password_if_present(cmdline), ex) from ex
155147
finally:
156148
stream.close()
157149

@@ -178,9 +170,7 @@ def pump_stream(
178170
threads: List[threading.Thread] = []
179171

180172
for name, stream, handler in pumps:
181-
t = threading.Thread(
182-
target=pump_stream, args=(cmdline, name, stream, decode_streams, handler)
183-
)
173+
t = threading.Thread(target=pump_stream, args=(cmdline, name, stream, decode_streams, handler))
184174
t.daemon = True
185175
t.start()
186176
threads.append(t)
@@ -199,8 +189,7 @@ def pump_stream(
199189
)
200190
if stderr_handler:
201191
error_str: Union[str, bytes] = (
202-
"error: process killed because it timed out."
203-
f" kill_after_timeout={kill_after_timeout} seconds"
192+
"error: process killed because it timed out." f" kill_after_timeout={kill_after_timeout} seconds"
204193
)
205194
if not decode_streams and isinstance(p_stderr, BinaryIO):
206195
# Assume stderr_handler needs binary input
@@ -224,9 +213,7 @@ def slots_to_dict(self: object, exclude: Sequence[str] = ()) -> Dict[str, Any]:
224213
return {s: getattr(self, s) for s in self.__slots__ if s not in exclude}
225214

226215

227-
def dict_to_slots_and__excluded_are_none(
228-
self: object, d: Mapping[str, Any], excluded: Sequence[str] = ()
229-
) -> None:
216+
def dict_to_slots_and__excluded_are_none(self: object, d: Mapping[str, Any], excluded: Sequence[str] = ()) -> None:
230217
for k, v in d.items():
231218
setattr(self, k, v)
232219
for k in excluded:
@@ -242,9 +229,7 @@ def dict_to_slots_and__excluded_are_none(
242229
## CREATE_NEW_PROCESS_GROUP is needed to allow killing it afterwards,
243230
# see https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal
244231
PROC_CREATIONFLAGS = (
245-
CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore[attr-defined]
246-
if is_win
247-
else 0
232+
CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP if is_win else 0 # type: ignore[attr-defined]
248233
) # mypy error if not windows
249234

250235

@@ -557,9 +542,7 @@ def wait(self, stderr: Union[None, str, bytes] = b"") -> int:
557542
status = self.status
558543
p_stderr = None
559544

560-
def read_all_from_possibly_closed_stream(
561-
stream: Union[IO[bytes], None]
562-
) -> bytes:
545+
def read_all_from_possibly_closed_stream(stream: Union[IO[bytes], None]) -> bytes:
563546
if stream:
564547
try:
565548
return stderr_b + force_bytes(stream.read())
@@ -573,9 +556,7 @@ def read_all_from_possibly_closed_stream(
573556
if status != 0:
574557
errstr = read_all_from_possibly_closed_stream(p_stderr)
575558
log.debug("AutoInterrupt wait stderr: %r" % (errstr,))
576-
raise GitCommandError(
577-
remove_password_if_present(self.args), status, errstr
578-
)
559+
raise GitCommandError(remove_password_if_present(self.args), status, errstr)
579560
return status
580561

581562
# END auto interrupt
@@ -725,16 +706,12 @@ def set_persistent_git_options(self, **kwargs: Any) -> None:
725706
the subcommand.
726707
"""
727708

728-
self._persistent_git_options = self.transform_kwargs(
729-
split_single_char_options=True, **kwargs
730-
)
709+
self._persistent_git_options = self.transform_kwargs(split_single_char_options=True, **kwargs)
731710

732711
def _set_cache_(self, attr: str) -> None:
733712
if attr == "_version_info":
734713
# We only use the first 4 numbers, as everything else could be strings in fact (on windows)
735-
process_version = self._call_process(
736-
"version"
737-
) # should be as default *args and **kwargs used
714+
process_version = self._call_process("version") # should be as default *args and **kwargs used
738715
version_numbers = process_version.split(" ")[2]
739716

740717
self._version_info = cast(
@@ -759,9 +736,7 @@ def version_info(self) -> Tuple[int, int, int, int]:
759736
return self._version_info
760737

761738
@overload
762-
def execute(
763-
self, command: Union[str, Sequence[Any]], *, as_process: Literal[True]
764-
) -> "AutoInterrupt":
739+
def execute(self, command: Union[str, Sequence[Any]], *, as_process: Literal[True]) -> "AutoInterrupt":
765740
...
766741

767742
@overload
@@ -946,16 +921,10 @@ def execute(
946921
'"kill_after_timeout" feature is not supported on Windows.',
947922
)
948923
else:
949-
cmd_not_found_exception = (
950-
FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
951-
)
924+
cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
952925
# end handle
953926

954-
stdout_sink = (
955-
PIPE
956-
if with_stdout
957-
else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
958-
)
927+
stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
959928
istream_ok = "None"
960929
if istream:
961930
istream_ok = "<valid stream>"
@@ -1027,9 +996,7 @@ def _kill_process(pid: int) -> None:
1027996

1028997
if kill_after_timeout is not None:
1029998
kill_check = threading.Event()
1030-
watchdog = threading.Timer(
1031-
kill_after_timeout, _kill_process, args=(proc.pid,)
1032-
)
999+
watchdog = threading.Timer(kill_after_timeout, _kill_process, args=(proc.pid,))
10331000

10341001
# Wait for the process to return
10351002
status = 0
@@ -1044,9 +1011,9 @@ def _kill_process(pid: int) -> None:
10441011
if kill_after_timeout is not None:
10451012
watchdog.cancel()
10461013
if kill_check.is_set():
1047-
stderr_value = (
1048-
'Timeout: the command "%s" did not complete in %d '
1049-
"secs." % (" ".join(redacted_command), kill_after_timeout)
1014+
stderr_value = 'Timeout: the command "%s" did not complete in %d ' "secs." % (
1015+
" ".join(redacted_command),
1016+
kill_after_timeout,
10501017
)
10511018
if not universal_newlines:
10521019
stderr_value = stderr_value.encode(defenc)
@@ -1058,11 +1025,7 @@ def _kill_process(pid: int) -> None:
10581025

10591026
status = proc.returncode
10601027
else:
1061-
max_chunk_size = (
1062-
max_chunk_size
1063-
if max_chunk_size and max_chunk_size > 0
1064-
else io.DEFAULT_BUFFER_SIZE
1065-
)
1028+
max_chunk_size = max_chunk_size if max_chunk_size and max_chunk_size > 0 else io.DEFAULT_BUFFER_SIZE
10661029
stream_copy(proc.stdout, output_stream, max_chunk_size)
10671030
stdout_value = proc.stdout.read()
10681031
stderr_value = proc.stderr.read()
@@ -1079,9 +1042,7 @@ def _kill_process(pid: int) -> None:
10791042
cmdstr = " ".join(redacted_command)
10801043

10811044
def as_text(stdout_value: Union[bytes, str]) -> str:
1082-
return (
1083-
not output_stream and safe_decode(stdout_value) or "<OUTPUT_STREAM>"
1084-
)
1045+
return not output_stream and safe_decode(stdout_value) or "<OUTPUT_STREAM>"
10851046

10861047
# end
10871048

@@ -1094,19 +1055,15 @@ def as_text(stdout_value: Union[bytes, str]) -> str:
10941055
safe_decode(stderr_value),
10951056
)
10961057
elif stdout_value:
1097-
log.info(
1098-
"%s -> %d; stdout: '%s'", cmdstr, status, as_text(stdout_value)
1099-
)
1058+
log.info("%s -> %d; stdout: '%s'", cmdstr, status, as_text(stdout_value))
11001059
else:
11011060
log.info("%s -> %d", cmdstr, status)
11021061
# END handle debug printing
11031062

11041063
if with_exceptions and status != 0:
11051064
raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
11061065

1107-
if (
1108-
isinstance(stdout_value, bytes) and stdout_as_string
1109-
): # could also be output_stream
1066+
if isinstance(stdout_value, bytes) and stdout_as_string: # could also be output_stream
11101067
stdout_value = safe_decode(stdout_value)
11111068

11121069
# Allow access to the command's status code
@@ -1163,9 +1120,7 @@ def custom_environment(self, **kwargs: Any) -> Iterator[None]:
11631120
finally:
11641121
self.update_environment(**old_env)
11651122

1166-
def transform_kwarg(
1167-
self, name: str, value: Any, split_single_char_options: bool
1168-
) -> List[str]:
1123+
def transform_kwarg(self, name: str, value: Any, split_single_char_options: bool) -> List[str]:
11691124
if len(name) == 1:
11701125
if value is True:
11711126
return ["-%s" % name]
@@ -1181,9 +1136,7 @@ def transform_kwarg(
11811136
return ["--%s=%s" % (dashify(name), value)]
11821137
return []
11831138

1184-
def transform_kwargs(
1185-
self, split_single_char_options: bool = True, **kwargs: Any
1186-
) -> List[str]:
1139+
def transform_kwargs(self, split_single_char_options: bool = True, **kwargs: Any) -> List[str]:
11871140
"""Transforms Python style kwargs into git command line options."""
11881141
args = []
11891142
for k, v in kwargs.items():
@@ -1218,9 +1171,7 @@ def __call__(self, **kwargs: Any) -> "Git":
12181171
12191172
``Examples``::
12201173
git(work_tree='/tmp').difftool()"""
1221-
self._git_options = self.transform_kwargs(
1222-
split_single_char_options=True, **kwargs
1223-
)
1174+
self._git_options = self.transform_kwargs(split_single_char_options=True, **kwargs)
12241175
return self
12251176

12261177
@overload
@@ -1330,15 +1281,9 @@ def _parse_object_header(self, header_line: str) -> Tuple[str, str, int]:
13301281
tokens = header_line.split()
13311282
if len(tokens) != 3:
13321283
if not tokens:
1333-
raise ValueError(
1334-
"SHA could not be resolved, git returned: %r"
1335-
% (header_line.strip())
1336-
)
1284+
raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
13371285
else:
1338-
raise ValueError(
1339-
"SHA %s could not be resolved, git returned: %r"
1340-
% (tokens[0], header_line.strip())
1341-
)
1286+
raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip()))
13421287
# END handle actual return value
13431288
# END error handling
13441289

@@ -1360,9 +1305,7 @@ def _prepare_ref(self, ref: AnyStr) -> bytes:
13601305
refstr += "\n"
13611306
return refstr.encode(defenc)
13621307

1363-
def _get_persistent_cmd(
1364-
self, attr_name: str, cmd_name: str, *args: Any, **kwargs: Any
1365-
) -> "Git.AutoInterrupt":
1308+
def _get_persistent_cmd(self, attr_name: str, cmd_name: str, *args: Any, **kwargs: Any) -> "Git.AutoInterrupt":
13661309
cur_val = getattr(self, attr_name)
13671310
if cur_val is not None:
13681311
return cur_val
@@ -1375,9 +1318,7 @@ def _get_persistent_cmd(
13751318
cmd = cast("Git.AutoInterrupt", cmd)
13761319
return cmd
13771320

1378-
def __get_object_header(
1379-
self, cmd: "Git.AutoInterrupt", ref: AnyStr
1380-
) -> Tuple[str, str, int]:
1321+
def __get_object_header(self, cmd: "Git.AutoInterrupt", ref: AnyStr) -> Tuple[str, str, int]:
13811322
if cmd.stdin and cmd.stdout:
13821323
cmd.stdin.write(self._prepare_ref(ref))
13831324
cmd.stdin.flush()
@@ -1405,9 +1346,7 @@ def get_object_data(self, ref: str) -> Tuple[str, str, int, bytes]:
14051346
del stream
14061347
return (hexsha, typename, size, data)
14071348

1408-
def stream_object_data(
1409-
self, ref: str
1410-
) -> Tuple[str, str, int, "Git.CatFileContentStream"]:
1349+
def stream_object_data(self, ref: str) -> Tuple[str, str, int, "Git.CatFileContentStream"]:
14111350
"""As get_object_header, but returns the data as a stream
14121351
14131352
:return: (hexsha, type_string, size_as_int, stream)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy