Skip to content

Commit

Permalink
Merge pull request #728 from LedgerHQ/fix-eth-client-package-error-be…
Browse files Browse the repository at this point in the history
…fore-py310

ledger_app_clients.ethereum: fix type checking annotation for python
  • Loading branch information
fvalette-ledger authored Jan 30, 2025
2 parents bfe91b6 + 5566ca0 commit 3e94afb
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions client/src/ledger_app_clients/ethereum/gcs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, TYPE_CHECKING
from enum import IntEnum
import struct

Expand Down Expand Up @@ -171,14 +171,18 @@ def serialize(self) -> bytes:
return payload


PathElement = PathTuple | PathArray | PathRef | PathLeaf | PathSlice
# XXX:
# Only defined while type checking in progress as this requires py3.10+
# and package available from py3.7 and upward.
if TYPE_CHECKING:
PathElement = PathTuple | PathArray | PathRef | PathLeaf | PathSlice


class DataPath:
version: int
path: list[PathElement]
path: list["PathElement"]

def __init__(self, version: int, path: list[PathElement]):
def __init__(self, version: int, path: list["PathElement"]):
self.version = version
self.path = path

Expand Down Expand Up @@ -445,24 +449,28 @@ def serialize(self) -> bytes:
return payload


ParamUnion = ParamRaw | \
ParamAmount | \
ParamTokenAmount | \
ParamNFT | \
ParamDatetime | \
ParamDuration | \
ParamUnit | \
ParamTrustedName | \
ParamEnum
# XXX:
# Only defined while type checking in progress as this requires py3.10+
# and package available from py3.7 and upward.
if TYPE_CHECKING:
ParamUnion = ParamRaw | \
ParamAmount | \
ParamTokenAmount | \
ParamNFT | \
ParamDatetime | \
ParamDuration | \
ParamUnit | \
ParamTrustedName | \
ParamEnum


class Field:
version: int
name: str
param_type: ParamType
param: ParamUnion
param: "ParamUnion"

def __init__(self, version: int, name: str, param_type: ParamType, param: ParamUnion):
def __init__(self, version: int, name: str, param_type: ParamType, param: "ParamUnion"):
self.version = version
self.name = name
self.param_type = param_type
Expand Down

0 comments on commit 3e94afb

Please sign in to comment.