mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 15:28:10 +00:00
common/protob: fix wrong typing info for Lists
This commit is contained in:
parent
f43652f2ea
commit
101ec1d161
@ -51,6 +51,7 @@ class ProtoField:
|
|||||||
type_name = attr.ib()
|
type_name = attr.ib()
|
||||||
proto_type = attr.ib()
|
proto_type = attr.ib()
|
||||||
py_type = attr.ib()
|
py_type = attr.ib()
|
||||||
|
py_inner_type = attr.ib()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_field(cls, descriptor, field):
|
def from_field(cls, descriptor, field):
|
||||||
@ -73,6 +74,7 @@ class ProtoField:
|
|||||||
"Unknown field type {} for field {}".format(field.type, field.name)
|
"Unknown field type {} for field {}".format(field.type, field.name)
|
||||||
) from None
|
) from None
|
||||||
|
|
||||||
|
py_inner_type = py_type
|
||||||
if repeated:
|
if repeated:
|
||||||
py_type = "List[{}]".format(py_type)
|
py_type = "List[{}]".format(py_type)
|
||||||
|
|
||||||
@ -85,6 +87,7 @@ class ProtoField:
|
|||||||
type_name=type_name,
|
type_name=type_name,
|
||||||
proto_type=proto_type,
|
proto_type=proto_type,
|
||||||
py_type=py_type,
|
py_type=py_type,
|
||||||
|
py_inner_type=py_inner_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -282,12 +285,12 @@ class Descriptor:
|
|||||||
for field in all_enums:
|
for field in all_enums:
|
||||||
allowed_values = self.enum_types[field.type_name]
|
allowed_values = self.enum_types[field.type_name]
|
||||||
valuestr = ", ".join(str(v) for v in sorted(allowed_values))
|
valuestr = ", ".join(str(v) for v in sorted(allowed_values))
|
||||||
yield " {} = Literal[{}]".format(field.py_type, valuestr)
|
yield " {} = Literal[{}]".format(field.py_inner_type, valuestr)
|
||||||
|
|
||||||
yield " except ImportError:"
|
yield " except ImportError:"
|
||||||
yield " Dict, List, Optional = None, None, None # type: ignore"
|
yield " Dict, List, Optional = None, None, None # type: ignore"
|
||||||
for field in all_enums:
|
for field in all_enums:
|
||||||
yield " {} = None # type: ignore".format(field.py_type)
|
yield " {} = None # type: ignore".format(field.py_inner_type)
|
||||||
|
|
||||||
yield ""
|
yield ""
|
||||||
yield ""
|
yield ""
|
||||||
|
Loading…
Reference in New Issue
Block a user