Skip to content

Commit 395e970

Browse files
authored
Merge pull request #13 from tekktrik/feature/add-typing
Add type hints
2 parents 12064ad + 3b10fd8 commit 395e970

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

adafruit_binascii.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Error(Exception):
6363

6464
if not "unhexlify" in globals():
6565
# pylint: disable=function-redefined
66-
def unhexlify(hexstr):
66+
def unhexlify(hexstr: str) -> bytes:
6767
"""Return the binary data represented by hexstr.
6868
:param str hexstr: Hexadecimal string.
6969
@@ -76,7 +76,7 @@ def unhexlify(hexstr):
7676

7777
if not "hexlify" in globals():
7878
# pylint: disable=function-redefined
79-
def hexlify(data):
79+
def hexlify(data: bytes) -> bytes:
8080
"""Return the hexadecimal representation of the
8181
binary data. Every byte of data is converted into
8282
the corresponding 2-digit hex representation.
@@ -96,7 +96,7 @@ def hexlify(data):
9696
A2B_HEX = unhexlify
9797

9898

99-
def _transform(n):
99+
def _transform(n: int) -> str:
100100
if n == -1:
101101
return "\xff"
102102
return chr(n)
@@ -106,7 +106,7 @@ def _transform(n):
106106
assert len(TABLE_A2B_B64) == 256
107107

108108

109-
def a2b_base64(b64_data):
109+
def a2b_base64(b64_data: str) -> bytes:
110110
"""Convert a block of base64 data back to binary and return the binary data.
111111
112112
:param str b64_data: Base64 data.
@@ -148,7 +148,7 @@ def a2b_base64(b64_data):
148148
return b"".join(res)
149149

150150

151-
def b2a_base64(bin_data):
151+
def b2a_base64(bin_data: str) -> bytes:
152152
"""Convert binary data to a line of ASCII characters in base64 coding.
153153
154154
:param str bin_data: Binary data string, as bytes

0 commit comments

Comments
 (0)