Mercurial > public > mercurial-scm > hg-stable
diff mercurial/archival.py @ 51897:b60f25f00e94
typing: add explicit hints for recent pytype regressions
Somewhere between 454feddab720 and cd72a88c5599, pytype changed how it inferred
the return type in `extdiff.py` from
Tuple[Any, List[Tuple[bytes, Any, os.stat_result]]]
to
Tuple[Any, List[nothing]]
It also changed the return type in `archival.py` from `Any` to `NoReturn`. Fix
those up, and also the obvious parameter types while we're here.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 12 Sep 2024 12:28:27 -0400 |
parents | 3b8d92f71d92 |
children | f81e0ce5103a |
line wrap: on
line diff
--- a/mercurial/archival.py Wed Jun 19 18:06:50 2024 +0200 +++ b/mercurial/archival.py Thu Sep 12 12:28:27 2024 -0400 @@ -11,9 +11,14 @@ import struct import tarfile import time +import typing import zipfile import zlib +from typing import ( + Optional, +) + from .i18n import _ from .node import nullrev from .pycompat import open @@ -30,6 +35,11 @@ from .utils import stringutil +if typing.TYPE_CHECKING: + from . import ( + localrepo, + ) + stringio = util.stringio # from unzip source code: @@ -281,16 +291,16 @@ def archive( - repo, - dest, + repo: "localrepo.localrepository", + dest, # TODO: should be bytes, but could be Callable node, - kind, - decode=True, + kind: bytes, + decode: bool = True, match=None, - prefix=b'', - mtime=None, - subrepos=False, -): + prefix: bytes = b'', + mtime: Optional[float] = None, + subrepos: bool = False, +) -> int: """create archive of repo as it was at node. dest can be name of directory, name of archive file, a callable, or file