Skip to content

Commit 69de468

Browse files
author
Dan Shernicoff
committed
PR feedback
1 parent d9944ce commit 69de468

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

adafruit_atecc/adafruit_atecc.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@
5050
# to have this in a try/except to enable type hinting for the IDEs while
5151
# not breaking the runtime on the controller.
5252
try:
53-
from typing import Any, Sized
53+
from typing import Any, Sized, Optional
54+
from busio import I2C
5455
except ImportError:
5556
pass
5657

5758
from micropython import const
58-
from adafruit_bus_device.i2c_device import I2CDevice, I2C
59+
from adafruit_bus_device.i2c_device import I2CDevice
5960
from adafruit_binascii import hexlify, unhexlify
6061

6162
__version__ = "0.0.0+auto.0"
@@ -260,7 +261,7 @@ def lock_all_zones(self):
260261
self.lock(0)
261262
self.lock(1)
262263

263-
def lock(self, zone: Any):
264+
def lock(self, zone: int):
264265
"""Locks specific ATECC zones.
265266
:param int zone: ATECC zone to lock.
266267
"""
@@ -272,7 +273,7 @@ def lock(self, zone: Any):
272273
assert res[0] == 0x00, "Failed locking ATECC!"
273274
self.idle()
274275

275-
def info(self, mode: int, param: Any = None) -> bytearray:
276+
def info(self, mode: int, param: Optional[Any] = None) -> bytearray:
276277
"""
277278
Returns device state information
278279
@@ -394,7 +395,7 @@ def _random(self, data: bytearray) -> bytearray:
394395
return data
395396

396397
# SHA-256 Commands
397-
def sha_start(self):
398+
def sha_start(self) -> bytearray:
398399
"""
399400
Initializes the SHA-256 calculation engine
400401
and the SHA context in memory.
@@ -409,7 +410,7 @@ def sha_start(self):
409410
self.idle()
410411
return status
411412

412-
def sha_update(self, message: Any) -> bytearray:
413+
def sha_update(self, message: bytes) -> bytearray:
413414
"""
414415
Appends bytes to the message. Can be repeatedly called.
415416
@@ -535,11 +536,11 @@ def _write(self, zone: Any, address: int, buffer: bytearray):
535536
self._get_response(status)
536537
self.idle()
537538

538-
def _read(self, zone: Any, address: int, buffer: bytearray):
539+
def _read(self, zone: int, address: int, buffer: bytearray):
539540
"""
540541
Reads from the I2C
541542
542-
:param Any zone: Zone to read from
543+
:param int zone: Zone to read from
543544
:param int address: The address to read from
544545
:param bytearray buffer: The buffer to read to
545546
"""

adafruit_atecc/adafruit_atecc_asn1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def get_name(name: str, obj_type: int, data: bytearray) -> int:
154154
return len(name) + 11
155155

156156

157-
def get_version(data: bytearray):
157+
def get_version(data: bytearray) -> None:
158158
"""
159159
Appends X.509 version to data.
160160
@@ -165,7 +165,7 @@ def get_version(data: bytearray):
165165
data += b"\x02\x01\x00"
166166

167167

168-
def get_sequence_header(length: int, data: bytearray):
168+
def get_sequence_header(length: int, data: bytearray) -> None:
169169
"""
170170
Appends sequence header to provided data.
171171
@@ -182,7 +182,7 @@ def get_sequence_header(length: int, data: bytearray):
182182
data += length_byte
183183

184184

185-
def get_public_key(data: bytearray, public_key: bytearray):
185+
def get_public_key(data: bytearray, public_key: bytearray) -> None:
186186
"""
187187
Appends public key subject and object identifiers.
188188

adafruit_atecc/adafruit_atecc_cert_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ def __init__(
8181
self._cert = None
8282
self._key = None
8383

84-
def generate_csr(self):
84+
def generate_csr(self) -> bytearray:
8585
"""Generates and returns a certificate signing request."""
8686
self._csr_begin()
8787
csr = self._csr_end()
8888
return csr
8989

90-
def _csr_begin(self):
90+
def _csr_begin(self) -> None:
9191
"""Initializes CSR generation."""
9292
assert 0 <= self._slot <= 4, "Provided slot must be between 0 and 4."
9393
# Create a new key
@@ -97,7 +97,7 @@ def _csr_begin(self):
9797
return
9898
self._atecc.gen_key(self._key, self._slot, self.private_key)
9999

100-
def _csr_end(self):
100+
def _csr_end(self) -> bytearray:
101101
"""Generates and returns
102102
a certificate signing request as a base64 string."""
103103
len_issuer_subject = asn1.issuer_or_subject_length(

0 commit comments

Comments
 (0)