| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1358,7 +1358,7 @@ def execute( | |||
| 1358 | 1358 | ||
| 1359 | 1359 | # Allow the user to have the command executed in their working dir. | |
| 1360 | 1360 | try: | |
| 1361 | - cwd = self._working_dir or os.getcwd() # type: Union[None, str] | ||
| 1361 | + cwd = self._working_dir or os.getcwd() # type: Optional[PathLike] | ||
| 1362 | 1362 | if not os.access(str(cwd), os.X_OK): | |
| 1363 | 1363 | cwd = None | |
| 1364 | 1364 | except FileNotFoundError: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,7 +217,7 @@ def rmtree(path: PathLike) -> None: | |||
| 217 | 217 | couldn't be deleted are read-only. Windows will not remove them in that case. | |
| 218 | 218 | """ | |
| 219 | 219 | ||
| 220 | - def handler(function: Callable, path: PathLike, _excinfo: Any) -> None: | ||
| 220 | + def handler(function: Callable[[str], Any], path: str, _excinfo: Any) -> None: | ||
| 221 | 221 | """Callback for :func:`shutil.rmtree`. | |
| 222 | 222 | ||
| 223 | 223 | This works as either a ``onexc`` or ``onerror`` style callback. | |
@@ -401,7 +401,7 @@ def _cygexpath(drive: Optional[str], path: str, expand_vars: bool = True) -> str | |||
| 401 | 401 | return p_str.replace("\\", "/") | |
| 402 | 402 | ||
| 403 | 403 | ||
| 404 | - _cygpath_parsers: Tuple[Tuple[Pattern[str], Callable, bool], ...] = ( | ||
| 404 | + _cygpath_parsers: Tuple[Tuple[Pattern[str], Callable[..., str], bool], ...] = ( | ||
| 405 | 405 | # See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx | |
| 406 | 406 | # and: https://www.cygwin.com/cygwin-ug-net/using.html#unc-paths | |
| 407 | 407 | ( | |
@@ -508,7 +508,7 @@ def get_user_id() -> str: | |||
| 508 | 508 | return "%s@%s" % (getpass.getuser(), platform.node()) | |
| 509 | 509 | ||
| 510 | 510 | ||
| 511 | - def finalize_process(proc: Union[subprocess.Popen, "Git.AutoInterrupt"], **kwargs: Any) -> None: | ||
| 511 | + def finalize_process(proc: Union["subprocess.Popen[Any]", "Git.AutoInterrupt"], **kwargs: Any) -> None: | ||
| 512 | 512 | """Wait for the process (clone, fetch, pull or push) and handle its errors | |
| 513 | 513 | accordingly.""" | |
| 514 | 514 | # TODO: No close proc-streams?? | |
@@ -520,19 +520,21 @@ def expand_path(p: None, expand_vars: bool = ...) -> None: ... | |||
| 520 | 520 | ||
| 521 | 521 | ||
| 522 | 522 | @overload | |
| 523 | - def expand_path(p: PathLike, expand_vars: bool = ...) -> str: | ||
| 523 | + def expand_path(p: PathLike, expand_vars: bool = ...) -> Optional[PathLike]: | ||
| 524 | 524 | # TODO: Support for Python 3.5 has been dropped, so these overloads can be improved. | |
| 525 | 525 | ... | |
| 526 | 526 | ||
| 527 | 527 | ||
| 528 | 528 | def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[PathLike]: | |
| 529 | - if isinstance(p, Path): | ||
| 530 | - return p.resolve() | ||
| 529 | + if p is None: | ||
| 530 | + return None | ||
| 531 | 531 | try: | |
| 532 | - p = osp.expanduser(p) # type: ignore[arg-type] | ||
| 532 | + if isinstance(p, Path): | ||
| 533 | + return p.resolve() | ||
| 534 | + expanded_path = osp.expanduser(os.fspath(p)) | ||
| 533 | 535 | if expand_vars: | |
| 534 | - p = osp.expandvars(p) | ||
| 535 | - return osp.normpath(osp.abspath(p)) | ||
| 536 | + expanded_path = osp.expandvars(expanded_path) | ||
| 537 | + return osp.normpath(osp.abspath(expanded_path)) | ||
| 536 | 538 | except Exception: | |
| 537 | 539 | return None | |
| 538 | 540 | ||
@@ -767,7 +769,7 @@ class CallableRemoteProgress(RemoteProgress): | |||
| 767 | 769 | ||
| 768 | 770 | __slots__ = ("_callable",) | |
| 769 | 771 | ||
| 770 | - def __init__(self, fn: Callable) -> None: | ||
| 772 | + def __init__(self, fn: Callable[..., Any]) -> None: | ||
| 771 | 773 | self._callable = fn | |
| 772 | 774 | super().__init__() | |
| 773 | 775 | ||
@@ -846,7 +848,7 @@ def _main_actor( | |||
| 846 | 848 | cls, | |
| 847 | 849 | env_name: str, | |
| 848 | 850 | env_email: str, | |
| 849 | - config_reader: Union[None, "GitConfigParser", "SectionConstraint"] = None, | ||
| 851 | + config_reader: Union[None, "GitConfigParser", "SectionConstraint[GitConfigParser]"] = None, | ||
| 850 | 852 | ) -> "Actor": | |
| 851 | 853 | actor = Actor("", "") | |
| 852 | 854 | user_id = None # We use this to avoid multiple calls to getpass.getuser(). | |
@@ -882,7 +884,9 @@ def default_name() -> str: | |||
| 882 | 884 | return actor | |
| 883 | 885 | ||
| 884 | 886 | @classmethod | |
| 885 | - def committer(cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint"] = None) -> "Actor": | ||
| 887 | + def committer( | ||
| 888 | + cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint[GitConfigParser]"] = None | ||
| 889 | + ) -> "Actor": | ||
| 886 | 890 | """ | |
| 887 | 891 | :return: | |
| 888 | 892 | :class:`Actor` instance corresponding to the configured committer. It | |
@@ -897,7 +901,9 @@ def committer(cls, config_reader: Union[None, "GitConfigParser", "SectionConstra | |||
| 897 | 901 | return cls._main_actor(cls.env_committer_name, cls.env_committer_email, config_reader) | |
| 898 | 902 | ||
| 899 | 903 | @classmethod | |
| 900 | - def author(cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint"] = None) -> "Actor": | ||
| 904 | + def author( | ||
| 905 | + cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint[GitConfigParser]"] = None | ||
| 906 | + ) -> "Actor": | ||
| 901 | 907 | """Same as :meth:`committer`, but defines the main author. It may be specified | |
| 902 | 908 | in the environment, but defaults to the committer.""" | |
| 903 | 909 | return cls._main_actor(cls.env_author_name, cls.env_author_email, config_reader) | |
@@ -980,11 +986,11 @@ class IndexFileSHA1Writer: | |||
| 980 | 986 | ||
| 981 | 987 | __slots__ = ("f", "sha1") | |
| 982 | 988 | ||
| 983 | - def __init__(self, f: IO) -> None: | ||
| 989 | + def __init__(self, f: IO[bytes]) -> None: | ||
| 984 | 990 | self.f = f | |
| 985 | 991 | self.sha1 = make_sha(b"") | |
| 986 | 992 | ||
| 987 | - def write(self, data: AnyStr) -> int: | ||
| 993 | + def write(self, data: bytes) -> int: | ||
| 988 | 994 | self.sha1.update(data) | |
| 989 | 995 | return self.f.write(data) | |
| 990 | 996 | ||
@@ -1181,6 +1187,7 @@ def __new__(cls, id_attr: str, prefix: str = "") -> "IterableList[T_IterableObj] | |||
| 1181 | 1187 | return super().__new__(cls) | |
| 1182 | 1188 | ||
| 1183 | 1189 | def __init__(self, id_attr: str, prefix: str = "") -> None: | |
| 1190 | + super().__init__() | ||
| 1184 | 1191 | self._id_attr = id_attr | |
| 1185 | 1192 | self._prefix = prefix | |
| 1186 | 1193 | ||
@@ -1210,7 +1217,9 @@ def __getattr__(self, attr: str) -> T_IterableObj: | |||
| 1210 | 1217 | # END for each item | |
| 1211 | 1218 | return list.__getattribute__(self, attr) | |
| 1212 | 1219 | ||
| 1213 | - def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> T_IterableObj: # type: ignore[override] | ||
| 1220 | + def __getitem__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] | ||
| 1221 | + self, index: Union[SupportsIndex, int, slice, str] | ||
| 1222 | + ) -> T_IterableObj: | ||
| 1214 | 1223 | if isinstance(index, int): | |
| 1215 | 1224 | return list.__getitem__(self, index) | |
| 1216 | 1225 | elif isinstance(index, slice): | |
@@ -1288,7 +1297,7 @@ def list_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> IterableList[T_I | |||
| 1288 | 1297 | :return: | |
| 1289 | 1298 | list(Item,...) list of item instances | |
| 1290 | 1299 | """ | |
| 1291 | - out_list: IterableList = IterableList(cls._id_attribute_) | ||
| 1300 | + out_list: IterableList[T_IterableObj] = IterableList(cls._id_attribute_) | ||
| 1292 | 1301 | out_list.extend(cls.iter_items(repo, *args, **kwargs)) | |
| 1293 | 1302 | return out_list | |
| 1294 | 1303 | ||
@@ -1297,7 +1306,8 @@ class IterableClassWatcher(type): | |||
| 1297 | 1306 | """Metaclass that issues :exc:`DeprecationWarning` when :class:`git.util.Iterable` | |
| 1298 | 1307 | is subclassed.""" | |
| 1299 | 1308 | ||
| 1300 | - def __init__(cls, name: str, bases: Tuple, clsdict: Dict) -> None: | ||
| 1309 | + def __init__(cls, name: str, bases: Tuple[type, ...], clsdict: Dict[str, Any]) -> None: | ||
| 1310 | + super().__init__(name, bases, clsdict) | ||
| 1301 | 1311 | for base in bases: | |
| 1302 | 1312 | if type(base) is IterableClassWatcher: | |
| 1303 | 1313 | warnings.warn( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,17 @@ exclude = ["^git/ext/gitdb"] | |||
| 33 | 33 | module = "gitdb.*" | |
| 34 | 34 | ignore_missing_imports = true | |
| 35 | 35 | ||
| 36 | + [tool.basedpyright] | ||
| 37 | + typeCheckingMode = "standard" | ||
| 38 | + pythonVersion = "3.7" | ||
| 39 | + extraPaths = [ | ||
| 40 | + "git/ext/gitdb", | ||
| 41 | + "git/ext/gitdb/gitdb/ext/smmap", | ||
| 42 | + ] | ||
| 43 | + exclude = [ | ||
| 44 | + "git/ext/gitdb", | ||
| 45 | + ] | ||
| 46 | + | ||
| 36 | 47 | [tool.coverage.run] | |
| 37 | 48 | source = ["git"] | |
| 38 | 49 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments