diff hgext/git/manifest.py @ 52503:048c11993d6a

typing: (mostly) align the signatures of `imanifestrevisionstored` overrides When we change the implementations to subclass this explicitly, pytype complains that the signatures mismatch for various methods. It seems hung up on ones in `mercurial.manifest` that have type hints on the return value, but lacked it in the Protocol class (which it thinks returns `None` if there's no annotation). The tricky part is that a lot of the return types in the `mercurial.manifest` module are custom types specific to that module (e.g. `'manifestctx' | 'treemanifestctx'`). Those should probably be replaced with Protocol classes. I was going to avoid making a long series longer by disabling that check for now by putting `Any` as the return type on the Protocol class methods, and then realized the problem is the class isn't marked as a Protocol (that property isn't inherited). For now, lock in the synchronized signatures.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 23 Oct 2024 12:44:09 -0400
parents f4733654f144
children d37d8dfe65bd
line wrap: on
line diff
--- a/hgext/git/manifest.py	Tue Oct 22 22:28:10 2024 -0400
+++ b/hgext/git/manifest.py	Wed Oct 23 12:44:09 2024 -0400
@@ -268,7 +268,7 @@
     def read(self):
         return gittreemanifest(self._repo, self._tree, None)
 
-    def readfast(self, shallow=False):
+    def readfast(self, shallow: bool = False):
         return self.read()
 
     def copy(self):
@@ -276,7 +276,7 @@
         # because the caller expects a mutable manifest.
         return memgittreemanifestctx(self._repo, self._tree)
 
-    def find(self, path):
+    def find(self, path: bytes) -> tuple[bytes, bytes]:
         return self.read()[path]