comparison mercurial/subrepoutil.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 4cb75772818d
comparison
equal deleted inserted replaced
52451:f5d134e57f51 52452:9d79ffeed7c0
50 if typing.TYPE_CHECKING: 50 if typing.TYPE_CHECKING:
51 from . import ( 51 from . import (
52 context, 52 context,
53 localrepo, 53 localrepo,
54 match as matchmod, 54 match as matchmod,
55 scmutil,
56 subrepo, 55 subrepo,
57 ui as uimod, 56 ui as uimod,
58 ) 57 )
58
59 from .interfaces import status as istatus
59 60
60 # keeps pyflakes happy 61 # keeps pyflakes happy
61 assert [ 62 assert [
62 context, 63 context,
63 localrepo, 64 localrepo,
64 matchmod, 65 matchmod,
65 scmutil,
66 subrepo, 66 subrepo,
67 uimod, 67 uimod,
68 ] 68 ]
69 69
70 Substate = Dict[bytes, Tuple[bytes, bytes, bytes]] 70 Substate = Dict[bytes, Tuple[bytes, bytes, bytes]]
332 332
333 333
334 def precommit( 334 def precommit(
335 ui: "uimod.ui", 335 ui: "uimod.ui",
336 wctx: "context.workingcommitctx", 336 wctx: "context.workingcommitctx",
337 status: "scmutil.status", 337 status: "istatus.Status",
338 match: "matchmod.basematcher", 338 match: "matchmod.basematcher",
339 force: bool = False, 339 force: bool = False,
340 ) -> Tuple[List[bytes], Set[bytes], Substate]: 340 ) -> Tuple[List[bytes], Set[bytes], Substate]:
341 """Calculate .hgsubstate changes that should be applied before committing 341 """Calculate .hgsubstate changes that should be applied before committing
342 342