Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite530544

Browse files
committed
reformat according to 'black' configuration file.
1 parentf78fc42 commite530544

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-
forname,objinlocals().items()
67-
ifnot (name.startswith("_")orinspect.ismodule(obj))
68-
]
64+
__all__= [nameforname,objinlocals().items()ifnot (name.startswith("_")orinspect.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
exceptExceptionasex:
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"notinstr(ex):
151145
# Only reraise if the error was not due to the stream closing
152-
raiseCommandError(
153-
[f"<{name}-pump>"]+remove_password_if_present(cmdline),ex
154-
)fromex
146+
raiseCommandError([f"<{name}-pump>"]+remove_password_if_present(cmdline),ex)fromex
155147
finally:
156148
stream.close()
157149

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

180172
forname,stream,handlerinpumps:
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
ifstderr_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
ifnotdecode_streamsandisinstance(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)forsinself.__slots__ifsnotinexclude}
225214

226215

227-
defdict_to_slots_and__excluded_are_none(
228-
self:object,d:Mapping[str,Any],excluded:Sequence[str]= ()
229-
)->None:
216+
defdict_to_slots_and__excluded_are_none(self:object,d:Mapping[str,Any],excluded:Sequence[str]= ())->None:
230217
fork,vind.items():
231218
setattr(self,k,v)
232219
forkinexcluded:
@@ -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-
ifis_win
247-
else0
232+
CREATE_NO_WINDOW|subprocess.CREATE_NEW_PROCESS_GROUPifis_winelse0# 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-
defread_all_from_possibly_closed_stream(
561-
stream:Union[IO[bytes],None]
562-
)->bytes:
545+
defread_all_from_possibly_closed_stream(stream:Union[IO[bytes],None])->bytes:
563546
ifstream:
564547
try:
565548
returnstderr_b+force_bytes(stream.read())
@@ -573,9 +556,7 @@ def read_all_from_possibly_closed_stream(
573556
ifstatus!=0:
574557
errstr=read_all_from_possibly_closed_stream(p_stderr)
575558
log.debug("AutoInterrupt wait stderr: %r"% (errstr,))
576-
raiseGitCommandError(
577-
remove_password_if_present(self.args),status,errstr
578-
)
559+
raiseGitCommandError(remove_password_if_present(self.args),status,errstr)
579560
returnstatus
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
ifattr=="_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
returnself._version_info
760737

761738
@overload
762-
defexecute(
763-
self,command:Union[str,Sequence[Any]],*,as_process:Literal[True]
764-
)->"AutoInterrupt":
739+
defexecute(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-
ifwith_stdout
957-
elsegetattr(subprocess,"DEVNULL",None)oropen(os.devnull,"wb")
958-
)
927+
stdout_sink=PIPEifwith_stdoutelsegetattr(subprocess,"DEVNULL",None)oropen(os.devnull,"wb")
959928
istream_ok="None"
960929
ifistream:
961930
istream_ok="<valid stream>"
@@ -1027,9 +996,7 @@ def _kill_process(pid: int) -> None:
1027996

1028997
ifkill_after_timeoutisnotNone:
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
ifkill_after_timeoutisnotNone:
10451012
watchdog.cancel()
10461013
ifkill_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
ifnotuniversal_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-
ifmax_chunk_sizeandmax_chunk_size>0
1064-
elseio.DEFAULT_BUFFER_SIZE
1065-
)
1028+
max_chunk_size=max_chunk_sizeifmax_chunk_sizeandmax_chunk_size>0elseio.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
defas_text(stdout_value:Union[bytes,str])->str:
1082-
return (
1083-
notoutput_streamandsafe_decode(stdout_value)or"<OUTPUT_STREAM>"
1084-
)
1045+
returnnotoutput_streamandsafe_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
elifstdout_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
ifwith_exceptionsandstatus!=0:
11051064
raiseGitCommandError(redacted_command,status,stderr_value,stdout_value)
11061065

1107-
if (
1108-
isinstance(stdout_value,bytes)andstdout_as_string
1109-
):# could also be output_stream
1066+
ifisinstance(stdout_value,bytes)andstdout_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-
deftransform_kwarg(
1167-
self,name:str,value:Any,split_single_char_options:bool
1168-
)->List[str]:
1123+
deftransform_kwarg(self,name:str,value:Any,split_single_char_options:bool)->List[str]:
11691124
iflen(name)==1:
11701125
ifvalueisTrue:
11711126
return ["-%s"%name]
@@ -1181,9 +1136,7 @@ def transform_kwarg(
11811136
return ["--%s=%s"% (dashify(name),value)]
11821137
return []
11831138

1184-
deftransform_kwargs(
1185-
self,split_single_char_options:bool=True,**kwargs:Any
1186-
)->List[str]:
1139+
deftransform_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
fork,vinkwargs.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
returnself
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
iflen(tokens)!=3:
13321283
ifnottokens:
1333-
raiseValueError(
1334-
"SHA could not be resolved, git returned: %r"
1335-
% (header_line.strip())
1336-
)
1284+
raiseValueError("SHA could not be resolved, git returned: %r"% (header_line.strip()))
13371285
else:
1338-
raiseValueError(
1339-
"SHA %s could not be resolved, git returned: %r"
1340-
% (tokens[0],header_line.strip())
1341-
)
1286+
raiseValueError("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
returnrefstr.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
ifcur_valisnotNone:
13681311
returncur_val
@@ -1375,9 +1318,7 @@ def _get_persistent_cmd(
13751318
cmd=cast("Git.AutoInterrupt",cmd)
13761319
returncmd
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
ifcmd.stdinandcmd.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
delstream
14061347
return (hexsha,typename,size,data)
14071348

1408-
defstream_object_data(
1409-
self,ref:str
1410-
)->Tuple[str,str,int,"Git.CatFileContentStream"]:
1349+
defstream_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)

[8]ページ先頭

©2009-2025 Movatter.jp