changeset 51881:d62887764687

lfs: fix various signature mismatches for vfs subclasses These were flagged by PyCharm. I'm not sure why pytype doesn't catch these- only `hgext/lfs/__init__.py` in the lfs extension is excluded from being checked. I'm not sure if the `*insidef` arg to `join()` was meant as an internal convencience, because I see another class that gets flagged for the same signature problem (to be fixed next). But I don't feel bold enough to make this an internal function, and provide a simplified public `join()` on the `vfs` classes. That can still be done later, if desired. For now, process the additional args and pass them along, even though there don't appear to be any current callers that provide extra args to these classes. We need all of the subclasses to agree on the signature, or they won't be considered to implement the `Vfs` protocol being developed. While we're copy/pasting from the base class, bring the type annotations along for the ride.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 22 Sep 2024 17:02:42 -0400
parents 8f3cbea2547c
children 2391a5fa111e
files hgext/lfs/blobstore.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py	Sun Sep 22 17:18:05 2024 -0400
+++ b/hgext/lfs/blobstore.py	Sun Sep 22 17:02:42 2024 -0400
@@ -15,6 +15,10 @@
 import re
 import socket
 
+from typing import (
+    Optional,
+)
+
 from mercurial.i18n import _
 from mercurial.node import hex
 
@@ -42,11 +46,11 @@
 
 
 class lfsvfs(vfsmod.vfs):
-    def join(self, path):
+    def join(self, path: Optional[bytes], *insidef: bytes) -> bytes:
         """split the path at first two characters, like: XX/XXXXX..."""
         if not _lfsre.match(path):
             raise error.ProgrammingError(b'unexpected lfs path: %s' % path)
-        return super(lfsvfs, self).join(path[0:2], path[2:])
+        return super(lfsvfs, self).join(path[0:2], path[2:], *insidef)
 
     def walk(self, path=None, onerror=None):
         """Yield (dirpath, [], oids) tuple for blobs under path
@@ -77,7 +81,7 @@
     def __init__(self):
         pass
 
-    def exists(self, oid):
+    def exists(self, path: Optional[bytes] = None) -> bool:
         return False
 
     def read(self, oid):
@@ -93,8 +97,8 @@
     def walk(self, path=None, onerror=None):
         return (b'', [], [])
 
-    def write(self, oid, data):
-        pass
+    def write(self, *args, **kwargs) -> int:
+        return 0
 
 
 class lfsuploadfile(httpconnectionmod.httpsendfile):