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