Format: application/octet-stream
1 import sys
2 from typing import (
3 Any,
4 AnyStr,
5 Callable,
6 Generic,
7 Iterable,
8 Iterator,
9 List,
10 NamedTuple,
11 Optional,
12 Sequence,
13 Text,
14 Tuple,
15 TypeVar,
16 Union,
17 overload,
18 )
19
20 if sys.version_info >= (3, 9):
21 from types import GenericAlias
22
23 _T = TypeVar("_T")
24
25 if sys.version_info >= (3,):
26 _StrType = Text
27 else:
28 # Aliases can't point to type vars, so we need to redeclare AnyStr
29 _StrType = TypeVar("_StrType", Text, bytes)
30
31 _JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]]
32
33 class Match(NamedTuple):
34 a: int
35 b: int
36 size: int
37
38 class SequenceMatcher(Generic[_T]):
39 def __init__(
40 self, isjunk: Optional[Callable[[_T], bool]] = ..., a: Sequence[_T] = ..., b: Sequence[_T] = ..., autojunk: bool = ...
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 if sys.version_info >= (3, 9):
46 def find_longest_match(
47 self, alo: int = ..., ahi: Optional[int] = ..., blo: int = ..., bhi: Optional[int] = ...
48 ) -> Match: ...
49 else:
50 def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ...
51 def get_matching_blocks(self) -> List[Match]: ...
52 def get_opcodes(self) -> List[Tuple[str, int, int, int, int]]: ...
53 def get_grouped_opcodes(self, n: int = ...) -> Iterable[List[Tuple[str, int, int, int, int]]]: ...
54 def ratio(self) -> float: ...
55 def quick_ratio(self) -> float: ...
56 def real_quick_ratio(self) -> float: ...
57 if sys.version_info >= (3, 9):
58 def __class_getitem__(cls, item: Any) -> GenericAlias: ...
59
60 # mypy thinks the signatures of the overloads overlap, but the types still work fine
61 @overload
62 def get_close_matches( # type: ignore
63 word: AnyStr, possibilities: Iterable[AnyStr], n: int = ..., cutoff: float = ...
64 ) -> List[AnyStr]: ...
65 @overload
66 def get_close_matches(
67 word: Sequence[_T], possibilities: Iterable[Sequence[_T]], n: int = ..., cutoff: float = ...
68 ) -> List[Sequence[_T]]: ...
69
70 class Differ:
71 def __init__(self, linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ...) -> None: ...
72 def compare(self, a: Sequence[_StrType], b: Sequence[_StrType]) -> Iterator[_StrType]: ...
73
74 def IS_LINE_JUNK(line: _StrType, pat: Any = ...) -> bool: ... # pat is undocumented
75 def IS_CHARACTER_JUNK(ch: _StrType, ws: _StrType = ...) -> bool: ... # ws is undocumented
76 def unified_diff(
77 a: Sequence[_StrType],
78 b: Sequence[_StrType],
79 fromfile: _StrType = ...,
80 tofile: _StrType = ...,
81 fromfiledate: _StrType = ...,
82 tofiledate: _StrType = ...,
83 n: int = ...,
84 lineterm: _StrType = ...,
85 ) -> Iterator[_StrType]: ...
86 def context_diff(
87 a: Sequence[_StrType],
88 b: Sequence[_StrType],
89 fromfile: _StrType = ...,
90 tofile: _StrType = ...,
91 fromfiledate: _StrType = ...,
92 tofiledate: _StrType = ...,
93 n: int = ...,
94 lineterm: _StrType = ...,
95 ) -> Iterator[_StrType]: ...
96 def ndiff(
97 a: Sequence[_StrType], b: Sequence[_StrType], linejunk: Optional[_JunkCallback] = ..., charjunk: Optional[_JunkCallback] = ...
98 ) -> Iterator[_StrType]: ...
99
100 class HtmlDiff(object):
101 def __init__(
102 self,
103 tabsize: int = ...,
104 wrapcolumn: Optional[int] = ...,
105 linejunk: Optional[_JunkCallback] = ...,
106 charjunk: Optional[_JunkCallback] = ...,
107 ) -> None: ...
108 if sys.version_info >= (3, 5):
109 def make_file(
110 self,
111 fromlines: Sequence[_StrType],
112 tolines: Sequence[_StrType],
113 fromdesc: _StrType = ...,
114 todesc: _StrType = ...,
115 context: bool = ...,
116 numlines: int = ...,
117 *,
118 charset: str = ...,
119 ) -> _StrType: ...
120 else:
121 def make_file(
122 self,
123 fromlines: Sequence[_StrType],
124 tolines: Sequence[_StrType],
125 fromdesc: _StrType = ...,
126 todesc: _StrType = ...,
127 context: bool = ...,
128 numlines: int = ...,
129 ) -> _StrType: ...
130 def make_table(
131 self,
132 fromlines: Sequence[_StrType],
133 tolines: Sequence[_StrType],
134 fromdesc: _StrType = ...,
135 todesc: _StrType = ...,
136 context: bool = ...,
137 numlines: int = ...,
138 ) -> _StrType: ...
139
140 def restore(delta: Iterable[_StrType], which: int) -> Iterator[_StrType]: ...
141
142 if sys.version_info >= (3, 5):
143 def diff_bytes(
144 dfunc: Callable[[Sequence[str], Sequence[str], str, str, str, str, int, str], Iterator[str]],
145 a: Sequence[bytes],
146 b: Sequence[bytes],
147 fromfile: bytes = ...,
148 tofile: bytes = ...,
149 fromfiledate: bytes = ...,
150 tofiledate: bytes = ...,
151 n: int = ...,
152 lineterm: bytes = ...,
153 ) -> Iterator[bytes]: ...
154