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

Commit595181d

Browse files
committed
flake8 and mypy fixes
1 parentf58702b commit595181d

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

‎git/cmd.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def _set_cache_(self, attr: str) -> None:
615615
# END handle version info
616616

617617
@property
618-
defworking_dir(self)->Union[None,str]:
618+
defworking_dir(self)->Union[None,PathLike]:
619619
""":return: Git directory we are working on"""
620620
returnself._working_dir
621621

@@ -1187,7 +1187,7 @@ def __get_object_header(self, cmd, ref: AnyStr) -> Tuple[str, str, int]:
11871187
cmd.stdin.flush()
11881188
returnself._parse_object_header(cmd.stdout.readline())
11891189

1190-
defget_object_header(self,ref:AnyStr)->Tuple[str,str,int]:
1190+
defget_object_header(self,ref:str)->Tuple[str,str,int]:
11911191
""" Use this method to quickly examine the type and size of the object behind
11921192
the given ref.
11931193
@@ -1198,7 +1198,7 @@ def get_object_header(self, ref: AnyStr) -> Tuple[str, str, int]:
11981198
cmd=self._get_persistent_cmd("cat_file_header","cat_file",batch_check=True)
11991199
returnself.__get_object_header(cmd,ref)
12001200

1201-
defget_object_data(self,ref:AnyStr)->Tuple[str,str,int,bytes]:
1201+
defget_object_data(self,ref:str)->Tuple[str,str,int,bytes]:
12021202
""" As get_object_header, but returns object data as well
12031203
:return: (hexsha, type_string, size_as_int,data_string)
12041204
:note: not threadsafe"""
@@ -1207,7 +1207,7 @@ def get_object_data(self, ref: AnyStr) -> Tuple[str, str, int, bytes]:
12071207
del(stream)
12081208
return (hexsha,typename,size,data)
12091209

1210-
defstream_object_data(self,ref:AnyStr)->Tuple[str,str,int,'Git.CatFileContentStream']:
1210+
defstream_object_data(self,ref:str)->Tuple[str,str,int,'Git.CatFileContentStream']:
12111211
""" As get_object_header, but returns the data as a stream
12121212
12131213
:return: (hexsha, type_string, size_as_int, stream)

‎git/db.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# typing-------------------------------------------------
1414

15-
fromtypingimportTYPE_CHECKING,AnyStr
15+
fromtypingimportTYPE_CHECKING
1616
fromgit.typesimportPathLike
1717

1818
ifTYPE_CHECKING:
@@ -39,18 +39,18 @@ def __init__(self, root_path: PathLike, git: 'Git') -> None:
3939
super(GitCmdObjectDB,self).__init__(root_path)
4040
self._git=git
4141

42-
definfo(self,sha:bytes)->OInfo:
43-
hexsha,typename,size=self._git.get_object_header(bin_to_hex(sha))
42+
definfo(self,binsha:bytes)->OInfo:
43+
hexsha,typename,size=self._git.get_object_header(bin_to_hex(binsha))
4444
returnOInfo(hex_to_bin(hexsha),typename,size)
4545

46-
defstream(self,sha:bytes)->OStream:
46+
defstream(self,binsha:bytes)->OStream:
4747
"""For now, all lookup is done by git itself"""
48-
hexsha,typename,size,stream=self._git.stream_object_data(bin_to_hex(sha))
48+
hexsha,typename,size,stream=self._git.stream_object_data(bin_to_hex(binsha))
4949
returnOStream(hex_to_bin(hexsha),typename,size,stream)
5050

5151
# { Interface
5252

53-
defpartial_to_complete_sha_hex(self,partial_hexsha:AnyStr)->bytes:
53+
defpartial_to_complete_sha_hex(self,partial_hexsha:str)->bytes:
5454
""":return: Full binary 20 byte sha from the given partial hexsha
5555
:raise AmbiguousObjectName:
5656
:raise BadObject:

‎git/index/base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def merge_tree(self, rhs: Treeish, base: Union[None, Treeish] = None) -> 'IndexF
272272
returnself
273273

274274
@classmethod
275-
defnew(cls,repo:'Repo',*tree_sha:bytes)->'IndexFile':
275+
defnew(cls,repo:'Repo',*tree_sha:Union[str,Tree])->'IndexFile':
276276
""" Merge the given treeish revisions into a new index which is returned.
277277
This method behaves like git-read-tree --aggressive when doing the merge.
278278

‎git/index/util.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111

1212
# typing ----------------------------------------------------------------------
1313

14-
fromtypingimport (Any,Callable,List,Sequence,TYPE_CHECKING,Tuple,cast)
14+
fromtypingimport (Any,Callable)
1515

1616
fromgit.typesimportPathLike
1717

18-
ifTYPE_CHECKING:
19-
fromgit.repoimportRepo
20-
2118
# ---------------------------------------------------------------------------------
2219

2320

‎git/refs/log.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def from_line(cls, line):
9797
" Got %s"%repr(line))
9898
# END handle first split
9999

100-
oldhexsha=info[:40]
101-
newhexsha=info[41:81]
100+
oldhexsha=info[:40]# type: str
101+
newhexsha=info[41:81]# type: str
102102
forhexshain (oldhexsha,newhexsha):
103103
ifnotcls._re_hexsha_only.match(hexsha):
104104
raiseValueError("Invalid hexsha: %r"% (hexsha,))

‎git/repo/fun.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# Typing ----------------------------------------------------------------------
2020

21-
fromtypingimportAnyStr,Union,Optional,cast,TYPE_CHECKING
21+
fromtypingimportUnion,Optional,cast,TYPE_CHECKING
2222
fromgit.typesimportPathLike
2323
ifTYPE_CHECKING:
2424
from .baseimportRepo
@@ -103,7 +103,7 @@ def find_submodule_git_dir(d: PathLike) -> Optional[PathLike]:
103103
returnNone
104104

105105

106-
defshort_to_long(odb:'GitCmdObjectDB',hexsha:AnyStr)->Optional[bytes]:
106+
defshort_to_long(odb:'GitCmdObjectDB',hexsha:str)->Optional[bytes]:
107107
""":return: long hexadecimal sha1 from the given less-than-40 byte hexsha
108108
or None if no candidate could be found.
109109
:param hexsha: hexsha with less than 40 byte"""

‎git/util.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
fromtypingimport (Any,AnyStr,BinaryIO,Callable,Dict,Generator,IO,Iterator,List,
2525
Optional,Pattern,Sequence,Tuple,Union,cast,TYPE_CHECKING,overload)
2626

27+
importpathlib
2728

2829
ifTYPE_CHECKING:
2930
fromgit.remoteimportRemote
@@ -379,7 +380,9 @@ def expand_path(p: PathLike, expand_vars: bool = ...) -> str:
379380
...
380381

381382

382-
defexpand_path(p:Union[None,PathLike],expand_vars:bool=True)->Optional[str]:
383+
defexpand_path(p:Union[None,PathLike],expand_vars:bool=True)->Optional[PathLike]:
384+
ifisinstance(p,pathlib.Path):
385+
returnp.resolve()
383386
try:
384387
p=osp.expanduser(p)# type: ignore
385388
ifexpand_vars:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp