Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ledger_app_clients.ethereum: fix type checking annotation for python #728

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading