diff mercurial/match.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 5cc8deb96b48
children 0bd91b0a1a93
line wrap: on
line diff
--- a/mercurial/match.py	Tue Feb 04 14:02:20 2025 -0500
+++ b/mercurial/match.py	Thu Jan 30 18:22:01 2025 +0100
@@ -24,6 +24,9 @@
 )
 
 from .i18n import _
+from .interfaces.types import (
+    MatcherT,
+)
 from . import (
     encoding,
     error,
@@ -34,6 +37,10 @@
 )
 from .utils import stringutil
 
+from .interfaces import (
+    matcher as int_matcher,
+)
+
 rustmod = policy.importrust('dirstate')
 
 allpatternkinds = (
@@ -403,7 +410,7 @@
     return kindpats
 
 
-class basematcher:
+class basematcher(int_matcher.IMatcher):
     def __init__(self, badfn=None):
         self._was_tampered_with = False
         if badfn is not None:
@@ -1081,7 +1088,7 @@
     sub/x.txt: No such file
     """
 
-    def __init__(self, path: bytes, matcher: basematcher) -> None:
+    def __init__(self, path: bytes, matcher: MatcherT) -> None:
         super().__init__()
         self._path = path
         self._matcher = matcher