Mercurial > public > mercurial-scm > hg
diff mercurial/interfaces/dirstate.py @ 52741:5c48fd4c0e68
typing: introduce a `types` module and a MatcherT alias
This is a proposal to formalise the way we do typing and do more of it.
The initial motivation to make progress is to help break the 100+ module
cycle that is slowing pytype a lot.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 30 Jan 2025 18:22:01 +0100 |
parents | 2ac368d0a5b6 |
children | a7dcb7c1ff5a |
line wrap: on
line diff
--- a/mercurial/interfaces/dirstate.py Tue Feb 04 14:02:20 2025 -0500 +++ b/mercurial/interfaces/dirstate.py Thu Jan 30 18:22:01 2025 +0100 @@ -21,11 +21,13 @@ # Almost all mercurial modules are only imported in the type checking phase # to avoid circular imports from .. import ( - match as matchmod, transaction as txnmod, ) - from . import status as istatus + from . import ( + matcher, + status as istatus, + ) # TODO: finish adding type hints AddParentChangeCallbackT = Callable[ @@ -95,7 +97,7 @@ # TODO: decorate with `@rootcache(b'.hgignore')` like dirstate class? @property - def _ignore(self) -> matchmod.basematcher: + def _ignore(self) -> matcher.IMatcher: """Matcher for ignored files.""" @property @@ -307,7 +309,7 @@ @abc.abstractmethod def walk( self, - match: matchmod.basematcher, + match: matcher.IMatcher, subrepos: Any, # TODO: figure out what this is unknown: bool, ignored: bool, @@ -327,7 +329,7 @@ @abc.abstractmethod def status( self, - match: matchmod.basematcher, + match: matcher.IMatcher, subrepos: bool, ignored: bool, clean: bool, @@ -352,7 +354,7 @@ # TODO: could return a list, except git.dirstate is a generator @abc.abstractmethod - def matches(self, match: matchmod.basematcher) -> Iterable[bytes]: + def matches(self, match: matcher.IMatcher) -> Iterable[bytes]: """ return files in the dirstate (in whatever state) filtered by match """