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

Commita024bdd

Browse files
committed
Move TraverseNT to global, cos mypy complained on testing
1 parent3c6deb0 commita024bdd

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

‎git/objects/submodule/base.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
425425
raiseValueError("A URL was not given and a repository did not exist at %s"%path)
426426
# END check url
427427
mrepo=sm.module()
428+
assertisinstance(mrepo,Repo)
428429
urls= [r.urlforrinmrepo.remotes]
429430
ifnoturls:
430431
raiseValueError("Didn't find any remote url in repository at %s"%sm.abspath)

‎git/objects/util.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
from .submodule.baseimportSubmodule
3636

3737

38+
classTraverseNT(NamedTuple):
39+
depth:int
40+
item:Union['Traversable','Blob']
41+
src:Union['Traversable',None]
42+
43+
3844
T_TIobj=TypeVar('T_TIobj',bound='TraversableIterableObj')# for TraversableIterableObj.traverse()
3945

4046
TraversedTup=Union[Tuple[Union['Traversable',None],'Traversable'],# for commit, submodule
@@ -379,10 +385,6 @@ def traverse(self,
379385
ignore_self=True is_edge=False --> Iterator[item]
380386
ignore_self=False is_edge=True -> Iterator[item] | Iterator[Tuple[src, item]]
381387
ignore_self=False is_edge=False -> Iterator[Tuple[src, item]]"""
382-
classTraverseNT(NamedTuple):
383-
depth:int
384-
item:Union['Traversable','Blob']
385-
src:Union['Traversable',None]
386388

387389
visited=set()
388390
stack=deque()# type: Deque[TraverseNT]

‎git/util.py‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@
3636
fromgit.remoteimportRemote
3737
fromgit.repo.baseimportRepo
3838
fromgit.configimportGitConfigParser,SectionConstraint
39-
fromgit.objects.baseimportIndexObject
39+
#from git.objects.base import IndexObject
4040

4141

4242
from .typesimport (Literal,SupportsIndex,# because behind py version guards
43-
PathLike,HSH_TD,Total_TD,Files_TD)# aliases
43+
PathLike,HSH_TD,Total_TD,Files_TD,# aliases
44+
Has_id_attribute)
4445

45-
T_IterableObj=TypeVar('T_IterableObj',bound=Union['IterableObj','IndexObject'],covariant=True)
46+
T_IterableObj=TypeVar('T_IterableObj',bound=Union['IterableObj','Has_id_attribute'],covariant=True)
4647
# So IterableList[Head] is subtype of IterableList[IterableObj]
4748

4849
# ---------------------------------------------------------------------
@@ -82,7 +83,7 @@
8283
HIDE_WINDOWS_KNOWN_ERRORS=is_winandos.environ.get('HIDE_WINDOWS_KNOWN_ERRORS',True)
8384
HIDE_WINDOWS_FREEZE_ERRORS=is_winandos.environ.get('HIDE_WINDOWS_FREEZE_ERRORS',True)
8485

85-
#{ Utility Methods
86+
#{ Utility Methods
8687

8788
T=TypeVar('T')
8889

@@ -247,7 +248,7 @@ def is_exec(fpath: str) -> bool:
247248

248249
def_cygexpath(drive:Optional[str],path:str)->str:
249250
ifosp.isabs(path)andnotdrive:
250-
## Invoked from `cygpath()` directly with `D:Apps\123`?
251+
# Invoked from `cygpath()` directly with `D:Apps\123`?
251252
# It's an error, leave it alone just slashes)
252253
p=path# convert to str if AnyPath given
253254
else:
@@ -265,8 +266,8 @@ def _cygexpath(drive: Optional[str], path: str) -> str:
265266

266267

267268
_cygpath_parsers= (
268-
## See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
269-
## and: https://www.cygwin.com/cygwin-ug-net/using.html#unc-paths
269+
# See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
270+
# and: https://www.cygwin.com/cygwin-ug-net/using.html#unc-paths
270271
(re.compile(r"\\\\\?\\UNC\\([^\\]+)\\([^\\]+)(?:\\(.*))?"),
271272
(lambdaserver,share,rest_path:'//%s/%s/%s'% (server,share,rest_path.replace('\\','/'))),
272273
False
@@ -297,7 +298,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str:
297298
defcygpath(path:str)->str:
298299
"""Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment."""
299300
path=str(path)# ensure is str and not AnyPath.
300-
#Fix to use Paths when 3.5 dropped. or to be just str if only for urls?
301+
#Fix to use Paths when 3.5 dropped. or to be just str if only for urls?
301302
ifnotpath.startswith(('/cygdrive','//')):
302303
forregex,parser,recursein_cygpath_parsers:
303304
match=regex.match(path)
@@ -357,7 +358,7 @@ def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:
357358
res=py_where(git_executable)
358359
git_dir=osp.dirname(res[0])ifreselse""
359360

360-
## Just a name given, not a real path.
361+
# Just a name given, not a real path.
361362
uname_cmd=osp.join(git_dir,'uname')
362363
process=subprocess.Popen([uname_cmd],stdout=subprocess.PIPE,
363364
universal_newlines=True)
@@ -378,7 +379,7 @@ def get_user_id() -> str:
378379

379380
deffinalize_process(proc:subprocess.Popen,**kwargs:Any)->None:
380381
"""Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
381-
## TODO: No close proc-streams??
382+
# TODO: No close proc-streams??
382383
proc.wait(**kwargs)
383384

384385

@@ -432,9 +433,9 @@ def remove_password_if_present(cmdline):
432433
returnnew_cmdline
433434

434435

435-
#} END utilities
436+
#} END utilities
436437

437-
#{ Classes
438+
#{ Classes
438439

439440

440441
classRemoteProgress(object):
@@ -984,15 +985,15 @@ def __contains__(self, attr: object) -> bool:
984985
returnFalse
985986
# END handle membership
986987

987-
def__getattr__(self,attr:str)->Any:
988+
def__getattr__(self,attr:str)->T_IterableObj:
988989
attr=self._prefix+attr
989990
foriteminself:
990991
ifgetattr(item,self._id_attr)==attr:
991992
returnitem
992993
# END for each item
993994
returnlist.__getattribute__(self,attr)
994995

995-
def__getitem__(self,index:Union[SupportsIndex,int,slice,str])->Any:
996+
def__getitem__(self,index:Union[SupportsIndex,int,slice,str])->'T_IterableObj':# type: ignore
996997

997998
assertisinstance(index, (int,str,slice)),"Index of IterableList should be an int or str"
998999

@@ -1007,7 +1008,7 @@ def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> Any:
10071008
raiseIndexError("No item found with id %r"% (self._prefix+index))frome
10081009
# END handle getattr
10091010

1010-
def__delitem__(self,index:Union[SupportsIndex,int,slice,str])->Any:
1011+
def__delitem__(self,index:Union[SupportsIndex,int,slice,str])->None:
10111012

10121013
assertisinstance(index, (int,str)),"Index of IterableList should be an int or str"
10131014

@@ -1101,7 +1102,7 @@ def iter_items(cls, repo: 'Repo', *args: Any, **kwargs: Any
11011102
:return: iterator yielding Items"""
11021103
raiseNotImplementedError("To be implemented by Subclass")
11031104

1104-
#} END classes
1105+
#} END classes
11051106

11061107

11071108
classNullHandler(logging.Handler):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp