2 from typing import Any, AnyStr, Callable, Generic, Iterable, Iterator, NamedTuple, Sequence, TypeVar, Union, overload
4 if sys.version_info >= (3, 9):
5 from types import GenericAlias
8 _JunkCallback = Union[Callable[[str], bool], Callable[[str], bool]]
10 class Match(NamedTuple):
15 class SequenceMatcher(Generic[_T]):
17 self, isjunk: Callable[[_T], bool] | None = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ...
19 def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ...
20 def set_seq1(self, a: Sequence[_T]) -> None: ...
21 def set_seq2(self, b: Sequence[_T]) -> None: ...
22 if sys.version_info >= (3, 9):
23 def find_longest_match(self, alo: int = ..., ahi: int | None = ..., blo: int = ..., bhi: int | None = ...) -> Match: ...
25 def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ...
26 def get_matching_blocks(self) -> list[Match]: ...
27 def get_opcodes(self) -> list[tuple[str, int, int, int, int]]: ...
28 def get_grouped_opcodes(self, n: int = ...) -> Iterable[list[tuple[str, int, int, int, int]]]: ...
29 def ratio(self) -> float: ...
30 def quick_ratio(self) -> float: ...
31 def real_quick_ratio(self) -> float: ...
32 if sys.version_info >= (3, 9):
33 def __class_getitem__(cls, item: Any) -> GenericAlias: ...
35 # mypy thinks the signatures of the overloads overlap, but the types still work fine
37 def get_close_matches( # type: ignore
38 word: AnyStr, possibilities: Iterable[AnyStr], n: int = ..., cutoff: float = ...
39 ) -> list[AnyStr]: ...
41 def get_close_matches(
42 word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = ..., cutoff: float = ...
43 ) -> list[Sequence[_T]]: ...
46 def __init__(self, linejunk: _JunkCallback | None = ..., charjunk: _JunkCallback | None = ...) -> None: ...
47 def compare(self, a: Sequence[str], b: Sequence[str]) -> Iterator[str]: ...
49 def IS_LINE_JUNK(line: str, pat: Any = ...) -> bool: ... # pat is undocumented
50 def IS_CHARACTER_JUNK(ch: str, ws: str = ...) -> bool: ... # ws is undocumented
56 fromfiledate: str = ...,
57 tofiledate: str = ...,
60 ) -> Iterator[str]: ...
66 fromfiledate: str = ...,
67 tofiledate: str = ...,
70 ) -> Iterator[str]: ...
72 a: Sequence[str], b: Sequence[str], linejunk: _JunkCallback | None = ..., charjunk: _JunkCallback | None = ...
73 ) -> Iterator[str]: ...
75 class HtmlDiff(object):
79 wrapcolumn: int | None = ...,
80 linejunk: _JunkCallback | None = ...,
81 charjunk: _JunkCallback | None = ...,
85 fromlines: Sequence[str],
86 tolines: Sequence[str],
96 fromlines: Sequence[str],
97 tolines: Sequence[str],
104 def restore(delta: Iterable[str], which: int) -> Iterator[str]: ...
106 dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]],
109 fromfile: bytes = ...,
111 fromfiledate: bytes = ...,
112 tofiledate: bytes = ...,
114 lineterm: bytes = ...,
115 ) -> Iterator[bytes]: ...