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

Commit96c4365

Browse files
committed
flake8 and mypy fixes
1 parentf62c8d8 commit96c4365

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

‎git/cmd.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# typing ---------------------------------------------------------------------------
4444

4545
fromtypingimport (Any,AnyStr,BinaryIO,Callable,Dict,IO,List,Mapping,
46-
Sequence,TYPE_CHECKING,Tuple,Union,cast,overload)
46+
Sequence,TYPE_CHECKING,TextIO,Tuple,Union,cast,overload)
4747

4848
fromgit.typesimportPathLike,Literal,TBD
4949

@@ -98,14 +98,17 @@ def handle_process_output(process: subprocess.Popen,
9898
or if decoding must happen later (i.e. for Diffs).
9999
"""
100100
# Use 2 "pump" threads and wait for both to finish.
101-
defpump_stream(cmdline:str,name:str,stream:BinaryIO,is_decode:bool,
102-
handler:Union[None,Callable[[str],None]])->None:
101+
defpump_stream(cmdline:str,name:str,stream:Union[BinaryIO,TextIO],is_decode:bool,
102+
handler:Union[None,Callable[[Union[bytes,str]],None]])->None:
103103
try:
104104
forlineinstream:
105105
ifhandler:
106106
ifis_decode:
107+
assertisinstance(line,bytes)
107108
line_str=line.decode(defenc)
108-
handler(line_str)
109+
handler(line_str)
110+
else:
111+
handler(line)
109112
exceptExceptionasex:
110113
log.error("Pumping %r of cmd(%s) failed due to: %r",name,remove_password_if_present(cmdline),ex)
111114
raiseCommandError(['<%s-pump>'%name]+remove_password_if_present(cmdline),ex)fromex
@@ -337,12 +340,12 @@ def is_cygwin(cls) -> bool:
337340

338341
@overload
339342
@classmethod
340-
defpolish_url(cls,url:str,is_cygwin:Union[None,bool]=None)->str:
343+
defpolish_url(cls,url:str,is_cygwin:Literal[False]=...)->str:
341344
...
342345

343346
@overload
344347
@classmethod
345-
defpolish_url(cls,url:PathLike,is_cygwin:Union[None,bool]=None)->PathLike:
348+
defpolish_url(cls,url:PathLike,is_cygwin:Union[None,bool]=None)->str:
346349
...
347350

348351
@classmethod
@@ -628,16 +631,16 @@ def version_info(self) -> Tuple[int, int, int, int]:
628631
defexecute(self,
629632
command:Union[str,Sequence[Any]],
630633
*,
631-
as_process:Literal[True],
632-
)->AutoInterrupt:
634+
as_process:Literal[True]
635+
)->'AutoInterrupt':
633636
...
634637

635638
@overload
636639
defexecute(self,
637640
command:Union[str,Sequence[Any]],
638641
*,
639642
as_process:Literal[False]=False,
640-
stdout_as_string:Literal[True],
643+
stdout_as_string:Literal[True]
641644
)->Union[str,Tuple[int,str,str]]:
642645
...
643646

@@ -646,7 +649,7 @@ def execute(self,
646649
command:Union[str,Sequence[Any]],
647650
*,
648651
as_process:Literal[False]=False,
649-
stdout_as_string:Literal[False]=False,
652+
stdout_as_string:Literal[False]=False
650653
)->Union[bytes,Tuple[int,bytes,str]]:
651654
...
652655

@@ -656,8 +659,7 @@ def execute(self,
656659
*,
657660
with_extended_output:Literal[False],
658661
as_process:Literal[False],
659-
stdout_as_string:Literal[True],
660-
662+
stdout_as_string:Literal[True]
661663
)->str:
662664
...
663665

@@ -667,8 +669,7 @@ def execute(self,
667669
*,
668670
with_extended_output:Literal[False],
669671
as_process:Literal[False],
670-
stdout_as_string:Literal[False],
671-
672+
stdout_as_string:Literal[False]
672673
)->bytes:
673674
...
674675

@@ -829,16 +830,13 @@ def execute(self,
829830
creationflags=PROC_CREATIONFLAGS,
830831
**subprocess_kwargs
831832
)
832-
proc=cast(Popen[bytes],proc)
833833

834-
proc.stdout=cast(BinaryIO,proc.stdout)
835834
exceptcmd_not_found_exceptionaserr:
836835
raiseGitCommandNotFound(redacted_command,err)fromerr
837836
else:
838-
assertisinstance(proc.stdout,BinaryIO)
839-
assertisinstance(proc.stderr,BinaryIO)
840-
# proc.stdout = cast(BinaryIO, proc.stdout)
841-
# proc.stderr = cast(BinaryIO, proc.stderr)
837+
proc=cast(Popen,proc)
838+
proc.stdout=cast(BinaryIO,proc.stdout)
839+
proc.stderr=cast(BinaryIO,proc.stderr)
842840

843841
ifas_process:
844842
returnself.AutoInterrupt(proc,command)
@@ -1164,6 +1162,8 @@ def _prepare_ref(self, ref: AnyStr) -> bytes:
11641162
refstr=ref.decode('ascii')# type: str
11651163
elifnotisinstance(ref,str):
11661164
refstr=str(ref)# could be ref-object
1165+
else:
1166+
refstr=ref
11671167

11681168
ifnotrefstr.endswith("\n"):
11691169
refstr+="\n"

‎git/util.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,6 @@ def _cygexpath(drive: Optional[str], path: PathLike) -> str:
281281
)# type: Tuple[Tuple[Pattern[str], Callable, bool], ...]
282282

283283

284-
@overload
285-
defcygpath(path:str)->str:
286-
...
287-
288-
289-
@overload
290-
defcygpath(path:PathLike)->PathLike:
291-
...
292-
293-
294284
defcygpath(path:PathLike)->PathLike:
295285
"""Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment."""
296286
path=str(path)# ensure is str and not AnyPath.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp