File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from __future__ import annotations
4
4
5
- import typing
6
-
7
5
import re
6
+ import typing
8
7
from collections import OrderedDict , UserList , defaultdict
9
8
from copy import deepcopy
10
9
from dataclasses import Field , dataclass , fields
@@ -433,7 +432,7 @@ def _restore_typed_primitive(
433
432
Returns:
434
433
Union[:const:`Primitive`, CBORSerializable]: A CBOR primitive or a CBORSerializable.
435
434
"""
436
- if t in PRIMITIVE_TYPES and isinstance (v , t ):
435
+ if t is Any or ( t in PRIMITIVE_TYPES and isinstance (v , t ) ):
437
436
return v
438
437
elif isclass (t ) and issubclass (t , CBORSerializable ):
439
438
return t .from_primitive (v )
Original file line number Diff line number Diff line change 1
- from typing import Union
2
-
3
1
from dataclasses import dataclass , field
4
2
from test .pycardano .util import check_two_way_cbor
3
+ from typing import Any , Union
5
4
6
5
import pytest
7
6
@@ -162,3 +161,14 @@ def test_indefinite_list():
162
161
b .remove (5 )
163
162
# remove should remove element and return IndefiniteList
164
163
assert b == IndefiniteList ([4 , 6 , 7 ]) and type (b ) == IndefiniteList
164
+
165
+
166
+ def test_any_type ():
167
+ @dataclass
168
+ class Test1 (MapCBORSerializable ):
169
+ a : str = ""
170
+ b : Any = ""
171
+
172
+ t = Test1 (a = "a" , b = 1 )
173
+
174
+ check_two_way_cbor (t )
You can’t perform that action at this time.
0 commit comments