Mercurial > hg
comparison mercurial/cffi/mpatch.py @ 49599:94a797032fc4
typing: add type hints to mpatch implementations
Again, using `merge-pyi` to apply the stubs in cext and then manually type the
private methods. The generated stub without these hints inferred very little,
and the stuff it did was wrong.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 08 Nov 2022 14:17:56 -0500 |
parents | 6000f5b25c9b |
children | ecc3a893979d |
comparison
equal
deleted
inserted
replaced
49598:594fc56c0af7 | 49599:94a797032fc4 |
---|---|
3 # Copyright 2016 Maciej Fijalkowski <fijall@gmail.com> | 3 # Copyright 2016 Maciej Fijalkowski <fijall@gmail.com> |
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 | |
9 from typing import List | |
8 | 10 |
9 from ..pure.mpatch import * | 11 from ..pure.mpatch import * |
10 from ..pure.mpatch import mpatchError # silence pyflakes | 12 from ..pure.mpatch import mpatchError # silence pyflakes |
11 from . import _mpatch # pytype: disable=import-error | 13 from . import _mpatch # pytype: disable=import-error |
12 | 14 |
24 if r < 0: | 26 if r < 0: |
25 return ffi.NULL | 27 return ffi.NULL |
26 return container[0] | 28 return container[0] |
27 | 29 |
28 | 30 |
29 def patches(text, bins): | 31 def patches(text: bytes, bins: List[bytes]) -> bytes: |
30 lgt = len(bins) | 32 lgt = len(bins) |
31 all = [] | 33 all = [] |
32 if not lgt: | 34 if not lgt: |
33 return text | 35 return text |
34 arg = (all, bins) | 36 arg = (all, bins) |