1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
import sys
from collections.abc import Callable, Iterable, Iterator, Sequence
from typing import Any, AnyStr, Generic, Literal, NamedTuple, TypeVar, overload
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [
"get_close_matches",
"ndiff",
"restore",
"SequenceMatcher",
"Differ",
"IS_CHARACTER_JUNK",
"IS_LINE_JUNK",
"context_diff",
"unified_diff",
"diff_bytes",
"HtmlDiff",
"Match",
]
_T = TypeVar("_T")
class Match(NamedTuple):
a: int
b: int
size: int
class SequenceMatcher(Generic[_T]):
@overload
def __init__(self, isjunk: Callable[[_T], bool] | None, a: Sequence[_T], b: Sequence[_T], autojunk: bool = True) -> None: ...
@overload
def __init__(self, *, a: Sequence[_T], b: Sequence[_T], autojunk: bool = True) -> None: ...
@overload
def __init__(
self: SequenceMatcher[str],
isjunk: Callable[[str], bool] | None = None,
a: Sequence[str] = "",
b: Sequence[str] = "",
autojunk: bool = True,
) -> None: ...
def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ...
def set_seq1(self, a: Sequence[_T]) -> None: ...
def set_seq2(self, b: Sequence[_T]) -> None: ...
if sys.version_info >= (3, 9):
def find_longest_match(self, alo: int = 0, ahi: int | None = None, blo: int = 0, bhi: int | None = None) -> Match: ...
else:
def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ...
def get_matching_blocks(self) -> list[Match]: ...
def get_opcodes(self) -> list[tuple[Literal["replace", "delete", "insert", "equal"], int, int, int, int]]: ...
def get_grouped_opcodes(self, n: int = 3) -> Iterable[list[tuple[str, int, int, int, int]]]: ...
def ratio(self) -> float: ...
def quick_ratio(self) -> float: ...
def real_quick_ratio(self) -> float: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@overload
def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: float = 0.6) -> list[AnyStr]: ...
@overload
def get_close_matches(
word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = 3, cutoff: float = 0.6
) -> list[Sequence[_T]]: ...
class Differ:
def __init__(self, linejunk: Callable[[str], bool] | None = None, charjunk: Callable[[str], bool] | None = None) -> None: ...
def compare(self, a: Sequence[str], b: Sequence[str]) -> Iterator[str]: ...
def IS_LINE_JUNK(line: str, pat: Any = ...) -> bool: ... # pat is undocumented
def IS_CHARACTER_JUNK(ch: str, ws: str = " \t") -> bool: ... # ws is undocumented
def unified_diff(
a: Sequence[str],
b: Sequence[str],
fromfile: str = "",
tofile: str = "",
fromfiledate: str = "",
tofiledate: str = "",
n: int = 3,
lineterm: str = "\n",
) -> Iterator[str]: ...
def context_diff(
a: Sequence[str],
b: Sequence[str],
fromfile: str = "",
tofile: str = "",
fromfiledate: str = "",
tofiledate: str = "",
n: int = 3,
lineterm: str = "\n",
) -> Iterator[str]: ...
def ndiff(
a: Sequence[str],
b: Sequence[str],
linejunk: Callable[[str], bool] | None = None,
charjunk: Callable[[str], bool] | None = ...,
) -> Iterator[str]: ...
class HtmlDiff:
def __init__(
self,
tabsize: int = 8,
wrapcolumn: int | None = None,
linejunk: Callable[[str], bool] | None = None,
charjunk: Callable[[str], bool] | None = ...,
) -> None: ...
def make_file(
self,
fromlines: Sequence[str],
tolines: Sequence[str],
fromdesc: str = "",
todesc: str = "",
context: bool = False,
numlines: int = 5,
*,
charset: str = "utf-8",
) -> str: ...
def make_table(
self,
fromlines: Sequence[str],
tolines: Sequence[str],
fromdesc: str = "",
todesc: str = "",
context: bool = False,
numlines: int = 5,
) -> str: ...
def restore(delta: Iterable[str], which: int) -> Iterator[str]: ...
def diff_bytes(
dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]],
a: Iterable[bytes | bytearray],
b: Iterable[bytes | bytearray],
fromfile: bytes | bytearray = b"",
tofile: bytes | bytearray = b"",
fromfiledate: bytes | bytearray = b"",
tofiledate: bytes | bytearray = b"",
n: int = 3,
lineterm: bytes | bytearray = b"\n",
) -> Iterator[bytes]: ...
|