Mercurial > hg
changeset 51894:992fcf6b2473
typing: add a handful more annotations to `mercurial/vfs.py`
These came out of refactoring into a protocol class, but they can stand on their
own.
The `audit` callback is kinda screwy because the internal lambda and the callable
for `pathutil.pathauditor` have different args and a different return type. It's
conditionalized where it is called, and can be cleaned up later if desired.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 23 Sep 2024 14:58:37 -0400 |
parents | 22e1924e9402 |
children | ee7e106b372b |
files | mercurial/vfs.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/vfs.py Sat Sep 21 13:53:05 2024 -0400 +++ b/mercurial/vfs.py Mon Sep 23 14:58:37 2024 -0400 @@ -19,6 +19,7 @@ Any, BinaryIO, Callable, + Dict, Iterable, Iterator, List, @@ -27,6 +28,7 @@ Tuple, Type, TypeVar, + Union, ) from .i18n import _ @@ -455,7 +457,12 @@ See pathutil.pathauditor() for details. """ + audit: Union[pathutil.pathauditor, Callable[[bytes, Optional[bytes]], Any]] + base: bytes createmode: Optional[int] + options: Dict[bytes, Any] + _audit: bool + _trustnlink: Optional[bool] def __init__( self, @@ -688,11 +695,11 @@ return self.vfs._auditpath(path, mode) @property - def options(self): + def options(self) -> Dict[bytes, Any]: return self.vfs.options @options.setter - def options(self, value): + def options(self, value: Dict[bytes, Any]) -> None: self.vfs.options = value @property @@ -703,7 +710,7 @@ class filtervfs(proxyvfs, abstractvfs): '''Wrapper vfs for filtering filenames with a function.''' - def __init__(self, vfs: vfs, filter) -> None: + def __init__(self, vfs: vfs, filter: Callable[[bytes], bytes]) -> None: proxyvfs.__init__(self, vfs) self._filter = filter