diff mercurial/dirstate.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 b332ae615714
children a7dcb7c1ff5a
line wrap: on
line diff
--- a/mercurial/dirstate.py	Tue Feb 04 14:02:20 2025 -0500
+++ b/mercurial/dirstate.py	Thu Jan 30 18:22:01 2025 +0100
@@ -24,6 +24,7 @@
 )
 
 from .i18n import _
+from .interfaces.types import MatcherT
 
 from hgdemandimport import tracing
 
@@ -483,7 +484,7 @@
         return self._map.hastrackeddir(d)
 
     @rootcache(b'.hgignore')
-    def _ignore(self) -> matchmod.basematcher:
+    def _ignore(self) -> MatcherT:
         files = self._ignorefiles()
         if not files:
             return matchmod.never()
@@ -1359,7 +1360,7 @@
 
     def walk(
         self,
-        match: matchmod.basematcher,
+        match: MatcherT,
         subrepos: Any,
         unknown: bool,
         ignored: bool,
@@ -1639,7 +1640,7 @@
 
     def status(
         self,
-        match: matchmod.basematcher,
+        match: MatcherT,
         subrepos: bool,
         ignored: bool,
         clean: bool,
@@ -1796,7 +1797,7 @@
         )
         return (lookup, status, mtime_boundary)
 
-    def matches(self, match: matchmod.basematcher) -> Iterable[bytes]:
+    def matches(self, match: MatcherT) -> Iterable[bytes]:
         """
         return files in the dirstate (in whatever state) filtered by match
         """