##// END OF EJS Templates
interfaces: make `repository.imanifestlog` methods abstract...
interfaces: make `repository.imanifestlog` methods abstract Same as cdd4bc69bfc1 for `imanifestrevisionstored`, but this was already a Protocol class.

File last commit:

r52857:d7f17819 default
r53380:196f441f default
Show More
modules.py
85 lines | 2.4 KiB | text/x-python | PythonLexer
Matt Harbison
interfaces: introduce and use a protocol class for the `bdiff` module...
r52826 # 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 (
Matt Harbison
interfaces: add the optional `bdiff.xdiffblocks()` method...
r52827 Callable,
Matt Harbison
interfaces: introduce and use a protocol class for the `bdiff` module...
r52826 List,
Matt Harbison
interfaces: add the optional `bdiff.xdiffblocks()` method...
r52827 Optional,
Matt Harbison
interfaces: introduce and use a protocol class for the `bdiff` module...
r52826 Protocol,
Tuple,
)
if typing.TYPE_CHECKING:
BDiffBlock = Tuple[int, int, int, int]
Matt Harbison
interfaces: add the optional `bdiff.xdiffblocks()` method...
r52827 """An entry in the list returned by bdiff.{xdiff,}blocks()."""
BDiffBlocksFnc = Callable[[bytes, bytes], List[BDiffBlock]]
"""The signature of `bdiff.blocks()` and `bdiff.xdiffblocks()`."""
Matt Harbison
interfaces: introduce and use a protocol class for the `bdiff` module...
r52826
Matt Harbison
interfaces: introduce and use a protocol class for the `base85` module...
r52831 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"""
Matt Harbison
interfaces: introduce and use a protocol class for the `bdiff` module...
r52826 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:
...
Matt Harbison
interfaces: add the optional `bdiff.xdiffblocks()` method...
r52827
xdiffblocks: Optional[BDiffBlocksFnc]
"""This method is currently only available in the ``cext`` module."""
Matt Harbison
interfaces: introduce and use a protocol class for the `charencoding` module...
r52833
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.
"""
Matt Harbison
interfaces: introduce and use a protocol class for the `mpatch` module...
r52857
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:
...