diff mercurial/cffi/bdiff.py @ 49598:594fc56c0af7

typing: add type hints to bdiff implementations Not super important code, but this was an exercise in using `merge-pyi` to fold type stubs back into the code on something small. The cext stubs don't seem to be getting used (at least the only thing in `.pytype/pyi/mercurial/cext` after a run generating the stubs is `__init__.pyi`), so maybe this will help some.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 08 Nov 2022 13:59:16 -0500
parents b2666e767029
children ecc3a893979d
line wrap: on
line diff
--- a/mercurial/cffi/bdiff.py	Tue Nov 08 13:52:46 2022 -0500
+++ b/mercurial/cffi/bdiff.py	Tue Nov 08 13:59:16 2022 -0500
@@ -8,6 +8,11 @@
 
 import struct
 
+from typing import (
+    List,
+    Tuple,
+)
+
 from ..pure.bdiff import *
 from . import _bdiff  # pytype: disable=import-error
 
@@ -15,7 +20,7 @@
 lib = _bdiff.lib
 
 
-def blocks(sa, sb):
+def blocks(sa: bytes, sb: bytes) -> List[Tuple[int, int, int, int]]:
     a = ffi.new(b"struct bdiff_line**")
     b = ffi.new(b"struct bdiff_line**")
     ac = ffi.new(b"char[]", str(sa))
@@ -43,7 +48,7 @@
     return rl
 
 
-def bdiff(sa, sb):
+def bdiff(sa: bytes, sb: bytes) -> bytes:
     a = ffi.new(b"struct bdiff_line**")
     b = ffi.new(b"struct bdiff_line**")
     ac = ffi.new(b"char[]", str(sa))