pyrsistent
pyrsistent copied to clipboard
Type checking tuple type for fields causes infinite recursion
Specifying a tuple type for a field seems to break pyrsistent's type checker.
Pyrsistent version 0.20.0 Python 3.12 Linux (NixOS)
Minimal example test.py
:
from pyrsistent import *
IVec2 = tuple[int, int]
class Mask(PClass):
position = field(type=IVec2)
Load the module:
python -m test.py
Output:
Traceback (most recent call last):
File "<frozen runpy>", line 189, in _run_module_as_main
File "<frozen runpy>", line 112, in _get_module_details
File "/home/cro/aux/Projects/crowpainter/src/crowpainter/test.py", line 5, in <module>
class Mask(PClass):
File "/home/cro/aux/Projects/crowpainter/src/crowpainter/test.py", line 6, in Mask
position = field(type=IVec2)
^^^^^^^^^^^^^^^^^
File "/nix/store/kq39qlgbmj8qib3jc600d1k0pfk1nw3d-python3.12-pyrsistent-0.20.0/lib/python3.12/site-packages/pyrsistent/_field_common.py", line 121, in field
types = set(maybe_parse_user_type(type))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
...
File "/nix/store/kq39qlgbmj8qib3jc600d1k0pfk1nw3d-python3.12-pyrsistent-0.20.0/lib/python3.12/site-packages/pyrsistent/_checked_types.py", line 92, in maybe_parse_user_type
return tuple(e for t in ts for e in maybe_parse_user_type(t))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/kq39qlgbmj8qib3jc600d1k0pfk1nw3d-python3.12-pyrsistent-0.20.0/lib/python3.12/site-packages/pyrsistent/_checked_types.py", line 92, in <genexpr>
return tuple(e for t in ts for e in maybe_parse_user_type(t))
^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/kq39qlgbmj8qib3jc600d1k0pfk1nw3d-python3.12-pyrsistent-0.20.0/lib/python3.12/site-packages/pyrsistent/_checked_types.py", line 81, in maybe_parse_user_type
is_iterable = isinstance(t, Iterable)
^^^^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded