##// END OF EJS Templates
git: drop the zope `repository.ifilestorage` decoration on `gitlog.filelog`...
git: drop the zope `repository.ifilestorage` decoration on `gitlog.filelog` The next logical step is to disable the conditional import of `zope` in the `mercurial.interfaces.util` module, and just run with the no-op decorators. But doing that then generates these pytype errors: File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 485, in read: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 495, in lookup: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 505, in add: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 508, in __iter__: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 522, in rev: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 534, in node: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 549, in parents: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 556, in parents: No attribute '_db' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 564, in parents: No attribute 'gitrepo' on filelog [attribute-error] File "/mnt/c/Users/Matt/hg/hgext/git/gitlog.py", line 564, in parents: No attribute '_db' on filelog [attribute-error] I'm not sure what exactly the issue is, but the pyi file that was being generated up to this point has `filelog` typed as `Any` (because it had a decorator, and pytype chokes on that), and `baselog` was typed as a class. So it apparently can't see the `_db` and `gitrepo` attributes of the subclass, because it doesn't think `filelog` is a class. Leave the decorator commented out so it hits when searching for the remaining zope things that need to be updated to Protocol.

File last commit:

r52857:d7f17819 default
r53341:cdb45eb7 default
Show More
modules.py
85 lines | 2.4 KiB | text/x-python | PythonLexer
# modules.py - protocol classes for dynamically loaded modules
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import annotations
import typing
from typing import (
Callable,
List,
Optional,
Protocol,
Tuple,
)
if typing.TYPE_CHECKING:
BDiffBlock = Tuple[int, int, int, int]
"""An entry in the list returned by bdiff.{xdiff,}blocks()."""
BDiffBlocksFnc = Callable[[bytes, bytes], List[BDiffBlock]]
"""The signature of `bdiff.blocks()` and `bdiff.xdiffblocks()`."""
class Base85(Protocol):
"""A Protocol class for the various base85 module implementations."""
def b85encode(self, text: bytes, pad: bool = False) -> bytes:
"""encode text in base85 format"""
def b85decode(self, text: bytes) -> bytes:
"""decode base85-encoded text"""
class BDiff(Protocol):
"""A Protocol class for the various bdiff module implementations."""
def splitnewlines(self, text: bytes) -> List[bytes]:
"""like str.splitlines, but only split on newlines."""
def bdiff(self, a: bytes, b: bytes) -> bytes:
...
def blocks(self, a: bytes, b: bytes) -> List[BDiffBlock]:
...
def fixws(self, text: bytes, allws: bool) -> bytes:
...
xdiffblocks: Optional[BDiffBlocksFnc]
"""This method is currently only available in the ``cext`` module."""
class CharEncoding(Protocol):
"""A Protocol class for the various charencoding module implementations."""
def isasciistr(self, s: bytes) -> bool:
"""Can the byte string be decoded with the ``ascii`` codec?"""
def asciilower(self, s: bytes) -> bytes:
"""convert a string to lowercase if ASCII
Raises UnicodeDecodeError if non-ASCII characters are found."""
def asciiupper(self, s: bytes) -> bytes:
"""convert a string to uppercase if ASCII
Raises UnicodeDecodeError if non-ASCII characters are found."""
def jsonescapeu8fast(self, u8chars: bytes, paranoid: bool) -> bytes:
"""Convert a UTF-8 byte string to JSON-escaped form (fast path)
Raises ValueError if non-ASCII characters have to be escaped.
"""
class MPatch(Protocol):
"""A protocol class for the various mpatch module implementations."""
def patches(self, a: bytes, bins: List[bytes]) -> bytes:
...
def patchedsize(self, orig: int, delta: bytes) -> int:
...