Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 52481: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 | 00f5966f0483 |
children | 89215c5b714c |
comparison
equal
deleted
inserted
replaced
52480:f5d134e57f51 | 52481:9d79ffeed7c0 |
---|---|
79 from .revlogutils import ( | 79 from .revlogutils import ( |
80 constants as revlog_constants, | 80 constants as revlog_constants, |
81 ) | 81 ) |
82 | 82 |
83 if TYPE_CHECKING: | 83 if TYPE_CHECKING: |
84 from .interfaces import ( | |
85 status as istatus, | |
86 ) | |
84 from . import ( | 87 from . import ( |
85 ui as uimod, | 88 ui as uimod, |
86 ) | 89 ) |
87 | 90 |
88 stringio = util.stringio | 91 stringio = util.stringio |
794 for dirobj in self.subdirs.values(): | 797 for dirobj in self.subdirs.values(): |
795 for st, fpath in dirobj.tersewalk(terseargs): | 798 for st, fpath in dirobj.tersewalk(terseargs): |
796 yield st, fpath | 799 yield st, fpath |
797 | 800 |
798 | 801 |
799 def tersedir(statuslist, terseargs): | 802 def tersedir(statuslist: istatus.Status, terseargs) -> istatus.Status: |
800 """ | 803 """ |
801 Terse the status if all the files in a directory shares the same status. | 804 Terse the status if all the files in a directory shares the same status. |
802 | 805 |
803 statuslist is scmutil.status() object which contains a list of files for | 806 statuslist is scmutil.status() object which contains a list of files for |
804 each status. | 807 each status. |