Mercurial > public > mercurial-scm > hg
diff mercurial/subrepo.py @ 52452:9d79ffeed7c0
typing: use the `Status` protocol wherever `scmutil.status` was being used
This likely isn't everything, but these were all of the places the latter was
referenced in the generated *.pyi files, plus a few cases that were inferred as
`Any`, but found in a module that was being changed anyway.
We should figure out some sort of consistency as far as naming these Protocol
classes (stdlib ones tend to be CamelCase and imported directly). The current
convention of `from xxx.interfaces import foo as ifoo` is a little clever, but a
little annoying to type out. Also, this package is likely to grow beyond just
Protocol classes, where treating the types as interfaces is wrong (e.g. a
theoretical `NodeT` type to represent the binary form of a node, instead of
treating that and the incompatible hex form as both bytes). But that's a
project for another day.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 09 Dec 2024 00:21:38 -0500 |
parents | f4733654f144 |
children | 35cc15fbc523 |
line wrap: on
line diff
--- a/mercurial/subrepo.py Mon Dec 09 00:01:03 2024 -0500 +++ b/mercurial/subrepo.py Mon Dec 09 00:21:38 2024 -0500 @@ -39,6 +39,9 @@ util, vfs as vfsmod, ) +from .interfaces import ( + status as istatus, +) from .utils import ( dateutil, hashutil, @@ -332,7 +335,7 @@ def cat(self, match, fm, fntemplate, prefix, **opts): return 1 - def status(self, rev2, **opts): + def status(self, rev2, **opts) -> istatus.Status: return scmutil.status([], [], [], [], [], [], []) def diff(self, ui, diffopts, node2, match, prefix, **opts): @@ -614,7 +617,7 @@ ) @annotatesubrepoerror - def status(self, rev2, **opts): + def status(self, rev2, **opts) -> istatus.Status: try: rev1 = self._state[1] ctx1 = self._repo[rev1] @@ -1971,7 +1974,7 @@ return 0 @annotatesubrepoerror - def status(self, rev2, **opts): + def status(self, rev2, **opts) -> istatus.Status: rev1 = self._state[1] if self._gitmissing() or not rev1: # if the repo is missing, return no results