|
106 | 106 |
|
107 | 107 | # --------------------------------------------------------------------- |
108 | 108 |
|
109 | | -T_IterableObj = TypeVar("T_IterableObj", bound=Union["IterableObj", "Has_id_attribute"]) |
| 109 | +T_IterableObj = TypeVar("T_IterableObj", bound=Union["IterableObj", "Has_id_attribute"], covariant=True) |
110 | 110 | # So IterableList[Head] is subtype of IterableList[IterableObj]. |
111 | 111 |
|
112 | 112 | _logger = logging.getLogger(__name__) |
@@ -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[[PathLike], Any], 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. |
@@ -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[Any], "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,17 +520,17 @@ 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 | 529 | if p is None: |
530 | 530 | return None |
531 | | - if isinstance(p, Path): |
532 | | - return p.resolve() |
533 | 531 | try: |
| 532 | + if isinstance(p, Path): |
| 533 | + return p.resolve() |
534 | 534 | expanded_path = osp.expanduser(os.fspath(p)) |
535 | 535 | if expand_vars: |
536 | 536 | expanded_path = osp.expandvars(expanded_path) |
@@ -986,7 +986,7 @@ class IndexFileSHA1Writer: |
986 | 986 |
|
987 | 987 | __slots__ = ("f", "sha1") |
988 | 988 |
|
989 | | - def __init__(self, f: BinaryIO) -> None: |
| 989 | + def __init__(self, f: IO[bytes]) -> None: |
990 | 990 | self.f = f |
991 | 991 | self.sha1 = make_sha(b"") |
992 | 992 |
|
|