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

core: Fix mypy warnings.

This commit is contained in:
Andrew Kozlik 2019-08-08 16:03:50 +02:00
parent 55f69becff
commit cb7bc8f410
4 changed files with 13 additions and 12 deletions

View File

@ -8,7 +8,7 @@ from micropython import const
from trezor import log from trezor import log
if False: if False:
from typing import Any, Dict, Iterable, List, Tuple from typing import Any, Iterable, List, Tuple
Value = Any Value = Any
@ -146,7 +146,7 @@ def _cbor_decode(cbor: bytes) -> Tuple[Value, bytes]:
return (bytes(data[0:ln]).decode(), data[ln:]) return (bytes(data[0:ln]).decode(), data[ln:])
elif fb_type == _CBOR_ARRAY: elif fb_type == _CBOR_ARRAY:
if fb_aux == _CBOR_VAR_FOLLOWS: if fb_aux == _CBOR_VAR_FOLLOWS:
res = [] res = [] # type: Value
data = cbor[1:] data = cbor[1:]
while True: while True:
item, data = _cbor_decode(data) item, data = _cbor_decode(data)
@ -162,7 +162,7 @@ def _cbor_decode(cbor: bytes) -> Tuple[Value, bytes]:
res.append(item) res.append(item)
return (res, data) return (res, data)
elif fb_type == _CBOR_MAP: elif fb_type == _CBOR_MAP:
res = {} # type: Dict[Value, Value] res = {}
if fb_aux == _CBOR_VAR_FOLLOWS: if fb_aux == _CBOR_VAR_FOLLOWS:
data = cbor[1:] data = cbor[1:]
while True: while True:

View File

@ -34,4 +34,4 @@ _knownapps = {
"demo.yubico.com": "demo.yubico.com", "demo.yubico.com": "demo.yubico.com",
} }
knownapps = {sha256(k).digest(): v for (k, v) in _knownapps.items()} knownapps = {sha256(k.encode()).digest(): v for (k, v) in _knownapps.items()}

View File

@ -10,6 +10,8 @@ if False:
Pos = Tuple[int, int] Pos = Tuple[int, int]
Area = Tuple[int, int, int, int] Area = Tuple[int, int, int, int]
ResultValue = TypeVar("ResultValue")
display = Display() display = Display()
@ -186,10 +188,6 @@ class LayoutCancelled(Exception):
pass pass
if False:
ResultValue = TypeVar("ResultValue")
class Result(Exception): class Result(Exception):
def __init__(self, value: ResultValue) -> None: def __init__(self, value: ResultValue) -> None:
self.value = value self.value = value

View File

@ -3,6 +3,7 @@ from trezor.ui.button import Button, ButtonCancel, ButtonConfirm
from trezor.ui.loader import Loader, LoaderDefault from trezor.ui.loader import Loader, LoaderDefault
if False: if False:
from typing import Optional
from trezor.ui.button import ButtonContent, ButtonStyleType from trezor.ui.button import ButtonContent, ButtonStyleType
from trezor.ui.loader import LoaderStyleType from trezor.ui.loader import LoaderStyleType
@ -19,9 +20,9 @@ class Confirm(ui.Layout):
def __init__( def __init__(
self, self,
content: ui.Control, content: ui.Control,
confirm: ButtonContent = DEFAULT_CONFIRM, confirm: Optional[ButtonContent] = DEFAULT_CONFIRM,
confirm_style: ButtonStyleType = DEFAULT_CONFIRM_STYLE, confirm_style: ButtonStyleType = DEFAULT_CONFIRM_STYLE,
cancel: ButtonContent = DEFAULT_CANCEL, cancel: Optional[ButtonContent] = DEFAULT_CANCEL,
cancel_style: ButtonStyleType = DEFAULT_CANCEL_STYLE, cancel_style: ButtonStyleType = DEFAULT_CANCEL_STYLE,
major_confirm: bool = False, major_confirm: bool = False,
) -> None: ) -> None:
@ -34,7 +35,9 @@ class Confirm(ui.Layout):
area = ui.grid(13, cells_x=2) area = ui.grid(13, cells_x=2)
else: else:
area = ui.grid(9, n_x=2) area = ui.grid(9, n_x=2)
self.confirm = Button(area, confirm, confirm_style) self.confirm = Button(
area, confirm, confirm_style
) # type: Optional[Button]
self.confirm.on_click = self.on_confirm # type: ignore self.confirm.on_click = self.on_confirm # type: ignore
else: else:
self.confirm = None self.confirm = None
@ -46,7 +49,7 @@ class Confirm(ui.Layout):
area = ui.grid(12, cells_x=1) area = ui.grid(12, cells_x=1)
else: else:
area = ui.grid(8, n_x=2) area = ui.grid(8, n_x=2)
self.cancel = Button(area, cancel, cancel_style) self.cancel = Button(area, cancel, cancel_style) # type: Optional[Button]
self.cancel.on_click = self.on_cancel # type: ignore self.cancel.on_click = self.on_cancel # type: ignore
else: else:
self.cancel = None self.cancel = None