Mercurial > public > mercurial-scm > hg-stable
diff hgext/extdiff.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 | ca7bde5dbafb |
children | f4733654f144 |
line wrap: on
line diff
--- a/hgext/extdiff.py Wed Jun 19 18:06:50 2024 +0200 +++ b/hgext/extdiff.py Thu Sep 12 12:28:27 2024 -0400 @@ -87,6 +87,12 @@ import shutil import stat import subprocess +import typing +from typing import ( + List, + Optional, + Tuple, +) from mercurial.i18n import _ from mercurial.node import ( @@ -111,6 +117,12 @@ stringutil, ) +if typing.TYPE_CHECKING: + from mercurial import ( + localrepo, + ui as uimod, + ) + cmdtable = {} command = registrar.command(cmdtable) @@ -150,7 +162,14 @@ testedwith = b'ships-with-hg-core' -def snapshot(ui, repo, files, node, tmproot, listsubrepos): +def snapshot( + ui: "uimod.ui", + repo: "localrepo.localrepository", + files, + node: Optional[bytes], + tmproot: bytes, + listsubrepos: bool, +) -> Tuple[bytes, List[Tuple[bytes, bytes, os.stat_result]]]: """snapshot files as of some revision if not using snapshot, -I/-X does not work and recursive diff in tools like kdiff3 and meld displays too many files."""