diff --git a/python/src/trezorlib/_ed25519.py b/python/src/trezorlib/_ed25519.py index f1959ac96a..74c1e2f5f2 100644 --- a/python/src/trezorlib/_ed25519.py +++ b/python/src/trezorlib/_ed25519.py @@ -154,7 +154,7 @@ def scalarmult(P: Point, e: int) -> Point: # Bpow[i] == scalarmult(B, 2**i) -Bpow = [] # type: List[Point] +Bpow: List[Point] = [] def make_Bpow() -> None: diff --git a/python/src/trezorlib/log.py b/python/src/trezorlib/log.py index 5740ecc533..696a150c34 100644 --- a/python/src/trezorlib/log.py +++ b/python/src/trezorlib/log.py @@ -19,7 +19,7 @@ from typing import Optional, Set, Type from . import protobuf -OMITTED_MESSAGES = set() # type: Set[Type[protobuf.MessageType]] +OMITTED_MESSAGES: Set[Type[protobuf.MessageType]] = set() DUMP_BYTES = 5 DUMP_PACKETS = 4 diff --git a/python/src/trezorlib/protobuf.py b/python/src/trezorlib/protobuf.py index 836d991f61..0df86fe80f 100644 --- a/python/src/trezorlib/protobuf.py +++ b/python/src/trezorlib/protobuf.py @@ -584,7 +584,7 @@ def dict_to_proto(message_type: Type[MT], d: Dict[str, Any]) -> MT: value = [value] if isinstance(ftype, type) and issubclass(ftype, MessageType): - function = dict_to_proto # type: Callable[[Any, Any], Any] + function: Callable[[Any, Any], Any] = dict_to_proto else: function = value_to_proto diff --git a/python/src/trezorlib/toif.py b/python/src/trezorlib/toif.py index 82b990ab03..fd464bed5a 100644 --- a/python/src/trezorlib/toif.py +++ b/python/src/trezorlib/toif.py @@ -63,9 +63,9 @@ def _to_grayscale(data: bytes) -> bytes: @attr.s class Toif: - mode = attr.ib() # type: firmware.ToifMode - size = attr.ib() # type: Tuple[int, int] - data = attr.ib() # type: bytes + mode: firmware.ToifMode = attr.ib() + size: Tuple[int, int] = attr.ib() + data: bytes = attr.ib() @data.validator def check_data_size(self, _, value): diff --git a/python/src/trezorlib/transport/__init__.py b/python/src/trezorlib/transport/__init__.py index f71642cc39..6e1e6f178a 100644 --- a/python/src/trezorlib/transport/__init__.py +++ b/python/src/trezorlib/transport/__init__.py @@ -58,7 +58,7 @@ class Transport: a Trezor device to a computer. """ - PATH_PREFIX = None # type: str + PATH_PREFIX: str = None ENABLED = False def __str__(self) -> str: @@ -112,7 +112,7 @@ def all_transports() -> Iterable[Type[Transport]]: def enumerate_devices() -> Iterable[Transport]: - devices = [] # type: List[Transport] + devices: List[Transport] = [] for transport in all_transports(): name = transport.__name__ try: diff --git a/python/src/trezorlib/transport/bridge.py b/python/src/trezorlib/transport/bridge.py index 54e8e53928..df3136f3a9 100644 --- a/python/src/trezorlib/transport/bridge.py +++ b/python/src/trezorlib/transport/bridge.py @@ -76,7 +76,7 @@ class BridgeHandleModern(BridgeHandle): class BridgeHandleLegacy(BridgeHandle): def __init__(self, transport: "BridgeTransport") -> None: super().__init__(transport) - self.request = None # type: Optional[str] + self.request: Optional[str] = None def write_buf(self, buf: bytes) -> None: if self.request is not None: @@ -110,12 +110,12 @@ class BridgeTransport(Transport): raise TransportException("Debugging not supported on legacy Bridge") self.device = device - self.session = None # type: Optional[str] + self.session: Optional[str] = None self.debug = debug self.legacy = legacy if legacy: - self.handle = BridgeHandleLegacy(self) # type: BridgeHandle + self.handle: BridgeHandle = BridgeHandleLegacy(self) else: self.handle = BridgeHandleModern(self) diff --git a/python/src/trezorlib/transport/hid.py b/python/src/trezorlib/transport/hid.py index 97865f3e51..4dd120a50e 100644 --- a/python/src/trezorlib/transport/hid.py +++ b/python/src/trezorlib/transport/hid.py @@ -42,7 +42,7 @@ class HidHandle: ) -> None: self.path = path self.serial = serial - self.handle = None # type: HidDeviceHandle + self.handle: HidDeviceHandle = None self.hid_version = None if probe_hid_version else 2 def open(self) -> None: diff --git a/python/src/trezorlib/transport/udp.py b/python/src/trezorlib/transport/udp.py index e95830f972..447ae24986 100644 --- a/python/src/trezorlib/transport/udp.py +++ b/python/src/trezorlib/transport/udp.py @@ -44,7 +44,7 @@ class UdpTransport(ProtocolBasedTransport): host = devparts[0] port = int(devparts[1]) if len(devparts) > 1 else UdpTransport.DEFAULT_PORT self.device = (host, port) - self.socket = None # type: Optional[socket.socket] + self.socket: Optional[socket.socket] = None super().__init__(protocol=ProtocolV1(self)) diff --git a/python/src/trezorlib/transport/webusb.py b/python/src/trezorlib/transport/webusb.py index 40cd1ea408..ba6db9dc35 100644 --- a/python/src/trezorlib/transport/webusb.py +++ b/python/src/trezorlib/transport/webusb.py @@ -44,7 +44,7 @@ class WebUsbHandle: self.interface = DEBUG_INTERFACE if debug else INTERFACE self.endpoint = DEBUG_ENDPOINT if debug else ENDPOINT self.count = 0 - self.handle = None # type: Optional[usb1.USBDeviceHandle] + self.handle: Optional[usb1.USBDeviceHandle] = None def open(self) -> None: self.handle = self.device.open()