diff mercurial/interfaces/repository.py @ 52755: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 0f2268783c11
children 483b0bb23085
line wrap: on
line diff
--- a/mercurial/interfaces/repository.py	Tue Feb 04 14:02:20 2025 -0500
+++ b/mercurial/interfaces/repository.py	Thu Jan 30 18:22:01 2025 +0100
@@ -32,7 +32,6 @@
     # Almost all mercurial modules are only imported in the type checking phase
     # to avoid circular imports
     from .. import (
-        match as matchmod,
         pathutil,
         util,
     )
@@ -40,7 +39,10 @@
         urlutil,
     )
 
-    from . import dirstate as intdirstate
+    from . import (
+        dirstate as intdirstate,
+        matcher,
+    )
 
     # TODO: make a protocol class for this
     NodeConstants = Any
@@ -1184,7 +1186,7 @@
         """Returns a bool indicating if a directory is in this manifest."""
 
     @abc.abstractmethod
-    def walk(self, match: matchmod.basematcher) -> Iterator[bytes]:
+    def walk(self, match: matcher.IMatcher) -> Iterator[bytes]:
         """Generator of paths in manifest satisfying a matcher.
 
         If the matcher has explicit files listed and they don't exist in
@@ -1195,7 +1197,7 @@
     def diff(
         self,
         other: Any,  # TODO: 'manifestdict' or (better) equivalent interface
-        match: matchmod.basematcher | None = None,
+        match: matcher.IMatcher | None = None,
         clean: bool = False,
     ) -> dict[
         bytes,