# HG changeset patch # User Matt Harbison # Date 1724271194 14400 # Node ID 71fb6e0a7a35373ce136dbe13a677c6d545edec5 # Parent 438f4fca513e2d1384fe4e7aa6c61f17c99e0b48 typing: add type hints to the `opener` attributes and arguments of revlog When making revlog and filelog classes visible to pytype, it got confused quite a bit in `mercurial/revlogutils/rewrite.py`, thinking it had a plain `Callable`, and flagging additional methods on it like `join()` and `rename()`. I couldn't figure out how it reduced to that (and PyCharm flagged `opener` references as `Any`), but this makes it happy. So make this change before making the classes visible. The vfs class hierarchy is a bit wonky (e.g. `filteredvfs` is not a `vfs`), so this may need to be revisited with a Protocol class that covers all of the `vfs` classes. But for now, everything works. diff -r 438f4fca513e -r 71fb6e0a7a35 mercurial/revlog.py --- a/mercurial/revlog.py Wed Aug 21 16:09:22 2024 -0400 +++ b/mercurial/revlog.py Wed Aug 21 16:13:14 2024 -0400 @@ -91,6 +91,7 @@ revlogutils, templatefilters, util, + vfs as vfsmod, ) from .interfaces import ( repository, @@ -363,9 +364,11 @@ boundaries are arbitrary and based on what we can delegate to Rust. """ + opener: vfsmod.vfs + def __init__( self, - opener, + opener: vfsmod.vfs, index, index_file, data_file, @@ -1293,6 +1296,8 @@ _flagserrorclass = error.RevlogError + opener: vfsmod.vfs + @staticmethod def is_inline_index(header_bytes): """Determine if a revlog is inline from the initial bytes of the index""" @@ -1311,7 +1316,7 @@ def __init__( self, - opener, + opener: vfsmod.vfs, target, radix, postfix=None, # only exist for `tmpcensored` now