Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/build-wheel-tree.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- main
tags:
- '**'
- "**"
pull_request:

concurrency:
Expand All @@ -25,7 +25,7 @@ jobs:
fetch-depth: 0

- name: Create venv
run: /opt/python/cp38-cp38/bin/python3 -m venv venv
run: /opt/python/cp310-cp310/bin/python3 -m venv venv

- name: Create Wheels
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fetch-depth: 0

- name: Create venv
run: /opt/python/cp38-cp38/bin/python3 -m venv venv
run: /opt/python/cp310-cp310/bin/python3 -m venv venv

- name: Create Wheel
run: |
Expand Down
5 changes: 4 additions & 1 deletion hsms/clvm_serde/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import is_dataclass, fields, MISSING
from dataclasses import MISSING, fields, is_dataclass
from types import UnionType
from typing import Any, Callable, Optional, Tuple, Type, Union, get_type_hints

from chia_base.meta.type_tree import ArgsType, CompoundLookup, OriginArgsType, TypeTree
Expand Down Expand Up @@ -115,6 +116,7 @@ def ser(item):
tuple: serialize_for_tuple,
tuple_frugal: ser_for_tuple_frugal,
Union: serialize_for_optional,
UnionType: serialize_for_optional,
}


Expand Down Expand Up @@ -342,6 +344,7 @@ def deserialize_optional(p: Program):
tuple: deser_for_tuple,
tuple_frugal: de_for_tuple_frugal,
Union: deser_for_optional,
UnionType: deser_for_optional,
}


Expand Down
29 changes: 22 additions & 7 deletions tests/test_clvm_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
from .legacy.unsigned_spend import UnsignedSpend as LegacyUS


def test_ser():
@pytest.mark.parametrize("pep604", [True, False])
def test_ser(pep604: bool):
tpb = to_program_for_type(bytes)
fpb = from_program_for_type(bytes)
tps = to_program_for_type(str)
Expand Down Expand Up @@ -134,9 +135,16 @@ class Foo:
f1 = fp(p)
assert f1 == foo

@dataclass
class Foo:
a: Optional[int] = field(metadata=dict(key="a"))
if pep604:

@dataclass
class Foo:
a: int | None = field(metadata=dict(key="a"))
else:

@dataclass
class Foo:
a: Optional[int] = field(metadata=dict(key="a"))

tp = to_program_for_type(Foo)
fp = from_program_for_type(Foo)
Expand All @@ -151,9 +159,16 @@ class Foo:
p1 = tp(foo)
assert p1 == p

@dataclass
class Foo:
a: Optional[List[int]] = field(metadata=dict(key="a"))
if pep604:

@dataclass
class Foo:
a: List[int] | None = field(metadata=dict(key="a"))
else:

@dataclass
class Foo:
a: Optional[List[int]] = field(metadata=dict(key="a"))

tp = to_program_for_type(Foo)
fp = from_program_for_type(Foo)
Expand Down
Loading