You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a definition of a binary tree type hint BTREE = Union[LEAF, Tuple['BTREE', 'BTREE']], this cause desert schema to end up in an indefinite loop in lib\typing.py. Given that it is stuck in a loop in stdlib, I am not sure if this is a desert issue vs a typing issue or if typing wasn't really designed for recursive type hints like this in the first place.
fromtypingimportOptional, Union, Tupleimportdesertimportattr# Can be any typeLEAF=str# Binary tree definitionBTREE=Union[LEAF, Tuple['BTREE', 'BTREE']]
deftest_btree():
@attr.s(slots=True)classA:
x: BTREE=attr.ib(default='leaf')
a=A()
schema=desert.schema(A)
d=schema.dump(a)
Results in
Traceback (most recent call last):
File "C:\sveinse\tests\test_tree.py", line 19, in test_btree
schema = desert.schema(A)
File "c:\sveinse\venv\lib\site-packages\desert\__init__.py", line 24, in schema
return desert._make.class_schema(cls, meta=meta)(many=many)
File "c:\sveinse\venv\lib\site-packages\desert\_make.py", line 124, in class_schema
field.metadata,
File "c:\sveinse\venv\lib\site-packages\desert\_make.py", line 225, in field_for_schema
if not field and typ in _native_to_marshmallow:
File "C:\Users\sveinse\AppData\Local\Programs\Python\Python37-32\lib\typing.py", line 666, in __hash__
return hash((Union, frozenset(self.__args__)))
File "C:\Users\sveinse\AppData\Local\Programs\Python\Python37-32\lib\typing.py", line 667, in __hash__
return hash((self.__origin__, self.__args__))
File "C:\Users\sveinse\AppData\Local\Programs\Python\Python37-32\lib\typing.py", line 666, in __hash__
return hash((Union, frozenset(self.__args__)))
.... and forever.
The text was updated successfully, but these errors were encountered:
This might be an upstream issue in Python or typing_inspect, or maybe we're just doing it wrong. We could try to figure out a workaround. I've opened #89 to discuss our general situation regarding recursive types and unions.
Given a definition of a binary tree type hint
BTREE = Union[LEAF, Tuple['BTREE', 'BTREE']]
, this cause desert schema to end up in an indefinite loop inlib\typing.py
. Given that it is stuck in a loop in stdlib, I am not sure if this is a desert issue vs a typing issue or if typing wasn't really designed for recursive type hints like this in the first place.Results in
The text was updated successfully, but these errors were encountered: