1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00

fix(python): fix model enum aliases

the previous spelling of "aliases" created completely new enum entries

per Enum documentation:

> However, an enum member can have other names associated with it.
> Given two entries A and B with the same value (and A defined first),
> B is an alias for the member A. By-value lookup of the value of A will
> return the member A. By-name lookup of A will return the member A.
> By-name lookup of B will also return the member A.
This commit is contained in:
matejcik 2024-01-24 12:36:47 +01:00 committed by Jiří Musil
parent 3e14937c8a
commit fd7b94a6e9

View File

@ -34,13 +34,13 @@ class Model(Enum):
D001 = b"D001" D001 = b"D001"
# legacy aliases # legacy aliases
ONE = T1B1 ONE = b"T1B1"
T = T2T1 T = b"T2T1"
R = T2B1 R = b"T2B1"
DISC1 = D001 DISC1 = b"D001"
@classmethod @classmethod
def from_hw_model(cls, hw_model: t.Union["Self", bytes]) -> "Self": def from_hw_model(cls, hw_model: t.Union["Self", bytes]) -> "Model":
if isinstance(hw_model, cls): if isinstance(hw_model, cls):
return hw_model return hw_model
if hw_model == b"\x00\x00\x00\x00": if hw_model == b"\x00\x00\x00\x00":