Skip to content

Commit

Permalink
ledger_app_clients.ethereum: fix type checking annotation for python …
Browse files Browse the repository at this point in the history
…< 3.10
  • Loading branch information
fvalette-ledger committed Jan 30, 2025
1 parent 2c1a1cf commit 5566ca0
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 5566ca0

Please sign in to comment.