1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-16 04:29:08 +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
parent 8b3fbf6469
commit d951101112

View File

@ -32,13 +32,13 @@ class Model(Enum):
D001 = b"D001"
# legacy aliases
ONE = T1B1
T = T2T1
R = T2B1
DISC1 = D001
ONE = b"T1B1"
T = b"T2T1"
R = b"T2B1"
DISC1 = b"D001"
@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):
return hw_model
if hw_model == b"\x00\x00\x00\x00":