1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

core/webauthn: Fix mypy warnings.

This commit is contained in:
Andrew Kozlik 2019-10-09 18:13:25 +02:00
parent 17fa41620e
commit 710866074b
4 changed files with 10 additions and 8 deletions

View File

@ -40,7 +40,7 @@ def gen_core(data):
if use_sign_count is not None:
print(' "use_sign_count": %s,' % use_sign_count)
print(" },")
print("}")
print("} # type: dict")
def gen_mcu(data):

View File

@ -264,7 +264,9 @@ class U2fCredential(Credential):
def app_name(self) -> str:
from apps.webauthn.knownapps import knownapps
app_name = knownapps.get(self.rp_id_hash, {}).get("label", None)
app_name = knownapps.get(self.rp_id_hash, {}).get(
"label", None
) # type: Optional[str]
if app_name is None:
app_name = "%s...%s" % (
hexlify(self.rp_id_hash[:4]).decode(),

View File

@ -23,7 +23,7 @@ if __debug__:
from apps.debug import confirm_signal
if False:
from typing import Any, Coroutine, List, Optional
from typing import Any, Coroutine, List, Optional, Tuple
_CID_BROADCAST = const(0xFFFFFFFF) # broadcast channel id
@ -319,15 +319,15 @@ def resp_cmd_authenticate(siglen: int) -> dict:
}
def overlay_struct(buf, desc):
desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN)
def overlay_struct(buf: bytes, desc: dict) -> Any:
desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN) # type: ignore
if desc_size > len(buf):
raise ValueError("desc is too big (%d > %d)" % (desc_size, len(buf)))
return uctypes.struct(uctypes.addressof(buf), desc, uctypes.BIG_ENDIAN)
def make_struct(desc):
desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN)
def make_struct(desc: dict) -> Tuple[bytearray, Any]:
desc_size = uctypes.sizeof(desc, uctypes.BIG_ENDIAN) # type: ignore
buf = bytearray(desc_size)
return buf, uctypes.struct(uctypes.addressof(buf), desc, uctypes.BIG_ENDIAN)

View File

@ -117,4 +117,4 @@ knownapps = {
b"\xc4l\xef\x82\xad\x1bTdwY\x1d\x00\x8b\x08u\x9e\xc3\xe6\xd2\xec\xb4\xf3\x94t\xbf\xeaii\x92]\x03\xb7": {
"label": "demo.yubico.com"
},
}
} # type: dict