Show More
@@ -0,0 +1,34 | |||||
|
1 | # modules.py - protocol classes for dynamically loaded modules | |||
|
2 | # | |||
|
3 | # This software may be used and distributed according to the terms of the | |||
|
4 | # GNU General Public License version 2 or any later version. | |||
|
5 | ||||
|
6 | from __future__ import annotations | |||
|
7 | ||||
|
8 | import typing | |||
|
9 | ||||
|
10 | from typing import ( | |||
|
11 | List, | |||
|
12 | Protocol, | |||
|
13 | Tuple, | |||
|
14 | ) | |||
|
15 | ||||
|
16 | if typing.TYPE_CHECKING: | |||
|
17 | BDiffBlock = Tuple[int, int, int, int] | |||
|
18 | """An entry in the list returned by bdiff.blocks().""" | |||
|
19 | ||||
|
20 | ||||
|
21 | class BDiff(Protocol): | |||
|
22 | """A Protocol class for the various bdiff module implementations.""" | |||
|
23 | ||||
|
24 | def splitnewlines(self, text: bytes) -> List[bytes]: | |||
|
25 | """like str.splitlines, but only split on newlines.""" | |||
|
26 | ||||
|
27 | def bdiff(self, a: bytes, b: bytes) -> bytes: | |||
|
28 | ... | |||
|
29 | ||||
|
30 | def blocks(self, a: bytes, b: bytes) -> List[BDiffBlock]: | |||
|
31 | ... | |||
|
32 | ||||
|
33 | def fixws(self, text: bytes, allws: bool) -> bytes: | |||
|
34 | ... |
@@ -20,9 +20,13 from . import ( | |||||
20 | pycompat, |
|
20 | pycompat, | |
21 | util, |
|
21 | util, | |
22 | ) |
|
22 | ) | |
|
23 | from .interfaces import ( | |||
|
24 | modules as intmod, | |||
|
25 | ) | |||
|
26 | ||||
23 | from .utils import dateutil |
|
27 | from .utils import dateutil | |
24 |
|
28 | |||
25 | bdiff = policy.importmod('bdiff') |
|
29 | bdiff: intmod.BDiff = policy.importmod('bdiff') | |
26 | mpatch = policy.importmod('mpatch') |
|
30 | mpatch = policy.importmod('mpatch') | |
27 |
|
31 | |||
28 | blocks = bdiff.blocks |
|
32 | blocks = bdiff.blocks |
General Comments 0
You need to be logged in to leave comments.
Login now