comparison hgext/extdiff.py @ 51855: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
comparison
equal deleted inserted replaced
51854:2fd44b3dcc33 51855:b60f25f00e94
85 import os 85 import os
86 import re 86 import re
87 import shutil 87 import shutil
88 import stat 88 import stat
89 import subprocess 89 import subprocess
90 import typing
91 from typing import (
92 List,
93 Optional,
94 Tuple,
95 )
90 96
91 from mercurial.i18n import _ 97 from mercurial.i18n import _
92 from mercurial.node import ( 98 from mercurial.node import (
93 nullrev, 99 nullrev,
94 short, 100 short,
109 from mercurial.utils import ( 115 from mercurial.utils import (
110 procutil, 116 procutil,
111 stringutil, 117 stringutil,
112 ) 118 )
113 119
120 if typing.TYPE_CHECKING:
121 from mercurial import (
122 localrepo,
123 ui as uimod,
124 )
125
114 cmdtable = {} 126 cmdtable = {}
115 command = registrar.command(cmdtable) 127 command = registrar.command(cmdtable)
116 128
117 configtable = {} 129 configtable = {}
118 configitem = registrar.configitem(configtable) 130 configitem = registrar.configitem(configtable)
148 # be specifying the version(s) of Mercurial they are tested with, or 160 # be specifying the version(s) of Mercurial they are tested with, or
149 # leave the attribute unspecified. 161 # leave the attribute unspecified.
150 testedwith = b'ships-with-hg-core' 162 testedwith = b'ships-with-hg-core'
151 163
152 164
153 def snapshot(ui, repo, files, node, tmproot, listsubrepos): 165 def snapshot(
166 ui: "uimod.ui",
167 repo: "localrepo.localrepository",
168 files,
169 node: Optional[bytes],
170 tmproot: bytes,
171 listsubrepos: bool,
172 ) -> Tuple[bytes, List[Tuple[bytes, bytes, os.stat_result]]]:
154 """snapshot files as of some revision 173 """snapshot files as of some revision
155 if not using snapshot, -I/-X does not work and recursive diff 174 if not using snapshot, -I/-X does not work and recursive diff
156 in tools like kdiff3 and meld displays too many files.""" 175 in tools like kdiff3 and meld displays too many files."""
157 dirname = os.path.basename(repo.root) 176 dirname = os.path.basename(repo.root)
158 if dirname == b"": 177 if dirname == b"":