| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -425,6 +425,7 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No | |||
| 425 | 425 | raise ValueError("A URL was not given and a repository did not exist at %s" % path) | |
| 426 | 426 | # END check url | |
| 427 | 427 | mrepo = sm.module() | |
| 428 | + assert isinstance(mrepo, Repo) | ||
| 428 | 429 | urls = [r.url for r in mrepo.remotes] | |
| 429 | 430 | if not urls: | |
| 430 | 431 | raise ValueError("Didn't find any remote url in repository at %s" % sm.abspath) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,12 @@ | |||
| 35 | 35 | from .submodule.base import Submodule | |
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | + class TraverseNT(NamedTuple): | ||
| 39 | + depth: int | ||
| 40 | + item: Union['Traversable', 'Blob'] | ||
| 41 | + src: Union['Traversable', None] | ||
| 42 | + | ||
| 43 | + | ||
| 38 | 44 | T_TIobj = TypeVar('T_TIobj', bound='TraversableIterableObj') # for TraversableIterableObj.traverse() | |
| 39 | 45 | ||
| 40 | 46 | TraversedTup = Union[Tuple[Union['Traversable', None], 'Traversable'], # for commit, submodule | |
@@ -379,10 +385,6 @@ def traverse(self, | |||
| 379 | 385 | ignore_self=True is_edge=False --> Iterator[item] | |
| 380 | 386 | ignore_self=False is_edge=True -> Iterator[item] | Iterator[Tuple[src, item]] | |
| 381 | 387 | ignore_self=False is_edge=False -> Iterator[Tuple[src, item]]""" | |
| 382 | - class TraverseNT(NamedTuple): | ||
| 383 | - depth: int | ||
| 384 | - item: Union['Traversable', 'Blob'] | ||
| 385 | - src: Union['Traversable', None] | ||
| 386 | 388 | ||
| 387 | 389 | visited = set() | |
| 388 | 390 | stack = deque() # type: Deque[TraverseNT] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,13 +36,14 @@ | |||
| 36 | 36 | from git.remote import Remote | |
| 37 | 37 | from git.repo.base import Repo | |
| 38 | 38 | from git.config import GitConfigParser, SectionConstraint | |
| 39 | - from git.objects.base import IndexObject | ||
| 39 | + # from git.objects.base import IndexObject | ||
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | 42 | from .types import (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) | ||
| 44 | 45 | ||
| 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) | ||
| 46 | 47 | # So IterableList[Head] is subtype of IterableList[IterableObj] | |
| 47 | 48 | ||
| 48 | 49 | # --------------------------------------------------------------------- | |
@@ -82,7 +83,7 @@ | |||
| 82 | 83 | HIDE_WINDOWS_KNOWN_ERRORS = is_win and os.environ.get('HIDE_WINDOWS_KNOWN_ERRORS', True) | |
| 83 | 84 | HIDE_WINDOWS_FREEZE_ERRORS = is_win and os.environ.get('HIDE_WINDOWS_FREEZE_ERRORS', True) | |
| 84 | 85 | ||
| 85 | - #{ Utility Methods | ||
| 86 | + # { Utility Methods | ||
| 86 | 87 | ||
| 87 | 88 | T = TypeVar('T') | |
| 88 | 89 | ||
@@ -247,7 +248,7 @@ def is_exec(fpath: str) -> bool: | |||
| 247 | 248 | ||
| 248 | 249 | def _cygexpath(drive: Optional[str], path: str) -> str: | |
| 249 | 250 | if osp.isabs(path) and not drive: | |
| 250 | - ## Invoked from `cygpath()` directly with `D:Apps\123`? | ||
| 251 | + # Invoked from `cygpath()` directly with `D:Apps\123`? | ||
| 251 | 252 | # It's an error, leave it alone just slashes) | |
| 252 | 253 | p = path # convert to str if AnyPath given | |
| 253 | 254 | else: | |
@@ -265,8 +266,8 @@ def _cygexpath(drive: Optional[str], path: str) -> str: | |||
| 265 | 266 | ||
| 266 | 267 | ||
| 267 | 268 | _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 | ||
| 270 | 271 | (re.compile(r"\\\\\?\\UNC\\([^\\]+)\\([^\\]+)(?:\\(.*))?"), | |
| 271 | 272 | (lambda server, share, rest_path: '//%s/%s/%s' % (server, share, rest_path.replace('\\', '/'))), | |
| 272 | 273 | False | |
@@ -297,7 +298,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str: | |||
| 297 | 298 | def cygpath(path: str) -> str: | |
| 298 | 299 | """Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment.""" | |
| 299 | 300 | 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? | ||
| 301 | 302 | if not path.startswith(('/cygdrive', '//')): | |
| 302 | 303 | for regex, parser, recurse in _cygpath_parsers: | |
| 303 | 304 | match = regex.match(path) | |
@@ -357,7 +358,7 @@ def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: | |||
| 357 | 358 | res = py_where(git_executable) | |
| 358 | 359 | git_dir = osp.dirname(res[0]) if res else "" | |
| 359 | 360 | ||
| 360 | - ## Just a name given, not a real path. | ||
| 361 | + # Just a name given, not a real path. | ||
| 361 | 362 | uname_cmd = osp.join(git_dir, 'uname') | |
| 362 | 363 | process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, | |
| 363 | 364 | universal_newlines=True) | |
@@ -378,7 +379,7 @@ def get_user_id() -> str: | |||
| 378 | 379 | ||
| 379 | 380 | def finalize_process(proc: subprocess.Popen, **kwargs: Any) -> None: | |
| 380 | 381 | """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?? | ||
| 382 | 383 | proc.wait(**kwargs) | |
| 383 | 384 | ||
| 384 | 385 | ||
@@ -432,9 +433,9 @@ def remove_password_if_present(cmdline): | |||
| 432 | 433 | return new_cmdline | |
| 433 | 434 | ||
| 434 | 435 | ||
| 435 | - #} END utilities | ||
| 436 | + # } END utilities | ||
| 436 | 437 | ||
| 437 | - #{ Classes | ||
| 438 | + # { Classes | ||
| 438 | 439 | ||
| 439 | 440 | ||
| 440 | 441 | class RemoteProgress(object): | |
@@ -984,15 +985,15 @@ def __contains__(self, attr: object) -> bool: | |||
| 984 | 985 | return False | |
| 985 | 986 | # END handle membership | |
| 986 | 987 | ||
| 987 | - def __getattr__(self, attr: str) -> Any: | ||
| 988 | + def __getattr__(self, attr: str) -> T_IterableObj: | ||
| 988 | 989 | attr = self._prefix + attr | |
| 989 | 990 | for item in self: | |
| 990 | 991 | if getattr(item, self._id_attr) == attr: | |
| 991 | 992 | return item | |
| 992 | 993 | # END for each item | |
| 993 | 994 | return list.__getattribute__(self, attr) | |
| 994 | 995 | ||
| 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 | ||
| 996 | 997 | ||
| 997 | 998 | assert isinstance(index, (int, str, slice)), "Index of IterableList should be an int or str" | |
| 998 | 999 | ||
@@ -1007,7 +1008,7 @@ def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> Any: | |||
| 1007 | 1008 | raise IndexError("No item found with id %r" % (self._prefix + index)) from e | |
| 1008 | 1009 | # END handle getattr | |
| 1009 | 1010 | ||
| 1010 | - def __delitem__(self, index: Union[SupportsIndex, int, slice, str]) -> Any: | ||
| 1011 | + def __delitem__(self, index: Union[SupportsIndex, int, slice, str]) -> None: | ||
| 1011 | 1012 | ||
| 1012 | 1013 | assert isinstance(index, (int, str)), "Index of IterableList should be an int or str" | |
| 1013 | 1014 | ||
@@ -1101,7 +1102,7 @@ def iter_items(cls, repo: 'Repo', *args: Any, **kwargs: Any | |||
| 1101 | 1102 | :return: iterator yielding Items""" | |
| 1102 | 1103 | raise NotImplementedError("To be implemented by Subclass") | |
| 1103 | 1104 | ||
| 1104 | - #} END classes | ||
| 1105 | + # } END classes | ||
| 1105 | 1106 | ||
| 1106 | 1107 | ||
| 1107 | 1108 | class NullHandler(logging.Handler): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments