changeset 51872:5e79783d4bc7

revlog: make `clearcaches()` signature consistent with ManifestRevlog I'm not sure if this a newly added bug, because of using a different version of pytype, or if the recent work around avoiding the zope interface types in the type checking phase (see 5eb98ea78fd7 and friends)... but pytype 2023.11.21 started flagging this series since it was last pushed ~6 weeks ago: File "/mnt/c/Users/Matt/hg/mercurial/bundlerepo.py", line 204, in <module>: Overriding method signature mismatch [signature-mismatch] Base signature: 'def mercurial.manifest.ManifestRevlog.clearcaches(self, clear_persisted_data: Any = ...) -> None'. Subclass signature: 'def mercurial.revlog.revlog.clearcaches(self) -> None'. Not enough positional parameters in overriding method. Maybe the multiple inheritance in `bundlerepo.bundlemanifest` is bad, but it seems like a `ManifestRevlog` is-a `revlog`, even though the class hierarchy isn't coded that way. Additionally, it looks like `revlog.clearcaches()` is dealing with some persistent data, so maybe this is useful to have there anyway. Also sprinkle some trivial type hints on the method, because there are other `clearcaches()` definitions in the codebase with these hints, and I don't feel like waiting for another pytype run to see if it cares that specifically about the signature matching.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 18 Sep 2024 17:46:46 -0400
parents cfd30df0f8e4
children 0afd58c72175
files mercurial/interfaces/repository.py mercurial/manifest.py mercurial/revlog.py
diffstat 3 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/interfaces/repository.py	Sat Aug 03 01:33:13 2024 -0400
+++ b/mercurial/interfaces/repository.py	Wed Sep 18 17:46:46 2024 -0400
@@ -1532,7 +1532,7 @@
         TODO formalize interface for returned object.
         """
 
-    def clearcaches():
+    def clearcaches(clear_persisted_data: bool = False) -> None:
         """Clear caches associated with this collection."""
 
     def rev(node):
--- a/mercurial/manifest.py	Sat Aug 03 01:33:13 2024 -0400
+++ b/mercurial/manifest.py	Wed Sep 18 17:46:46 2024 -0400
@@ -1793,7 +1793,7 @@
     def fulltextcache(self):
         return self._fulltextcache
 
-    def clearcaches(self, clear_persisted_data=False):
+    def clearcaches(self, clear_persisted_data: bool = False) -> None:
         self._revlog.clearcaches()
         self._fulltextcache.clear(clear_persisted_data=clear_persisted_data)
         self._dirlogcache = {self.tree: self}
--- a/mercurial/revlog.py	Sat Aug 03 01:33:13 2024 -0400
+++ b/mercurial/revlog.py	Wed Sep 18 17:46:46 2024 -0400
@@ -1866,7 +1866,7 @@
             else:
                 nodemaputil.setup_persistent_nodemap(transaction, self)
 
-    def clearcaches(self):
+    def clearcaches(self, clear_persisted_data: bool = False) -> None:
         """Clear in-memory caches"""
         self._chainbasecache.clear()
         self._inner.clear_cache()