mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
protobuf: drop Optional markers (relying on implicit optional)
and add a conditional import for List
This commit is contained in:
parent
efa0f60493
commit
389f1418ed
@ -84,7 +84,7 @@ def create_init_method(fields):
|
|||||||
yield " def __init__("
|
yield " def __init__("
|
||||||
yield " self,"
|
yield " self,"
|
||||||
for field in fields:
|
for field in fields:
|
||||||
yield " %s: Optional[%s] = None," % (field.name, field.py_type)
|
yield " %s: %s = None," % (field.name, field.py_type)
|
||||||
yield " **kwargs"
|
yield " **kwargs"
|
||||||
yield " ) -> None:"
|
yield " ) -> None:"
|
||||||
for field in fields:
|
for field in fields:
|
||||||
@ -100,9 +100,14 @@ def process_message(descriptor, protobuf_module, msg_id, is_upy):
|
|||||||
|
|
||||||
if is_upy:
|
if is_upy:
|
||||||
yield "import protobuf as p"
|
yield "import protobuf as p"
|
||||||
|
yield "if __debug__:"
|
||||||
|
yield " try:"
|
||||||
|
yield " from typing import List"
|
||||||
|
yield " except ImportError:"
|
||||||
|
yield " List = None"
|
||||||
else:
|
else:
|
||||||
yield "from .. import protobuf as p"
|
yield "from .. import protobuf as p"
|
||||||
yield "from typing import List, Optional"
|
yield "from typing import List"
|
||||||
|
|
||||||
yield from process_message_imports(descriptor)
|
yield from process_message_imports(descriptor)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user