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
return msgspec.msgpack.decode(encoded, type=cls._decode_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 113, in get_class_annotations
mro, typevar_mappings = _get_class_mro_and_typevar_mappings(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 90, in _get_class_mro_and_typevar_mappings
inner(obj, {})
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 88, in inner
inner(b, ...)
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 88, in inner
inner(b, new_scope)
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 88, in inner
inner(b, new_scope)
^^^^^^^^^
UnboundLocalError: cannot access local variable 'new_scope' where it is not associated with a value
Traceback (most recent call last):
File "/Users/.../scratch.py", line 21, in <module>
dec = msgspec.msgpack.decode(enc, type=list[Bug])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 113, in get_class_annotations
mro, typevar_mappings = _get_class_mro_and_typevar_mappings(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 90, in _get_class_mro_and_typevar_mappings
inner(obj, {})
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 88, in inner
inner(b, new_scope)
File "/Users/.../.venv/lib/python3.12/site-packages/msgspec/_utils.py", line 88, in inner
inner(b, new_scope)
^^^^^^^^^
UnboundLocalError: cannot access local variable 'new_scope' where it is not associated with a value
I've since fixed how my classes are structured, but this is still an issue any time a generic class appears both in a parent class and in a child class.
Activity
treykeown commentedon Jan 4, 2024
treykeown commentedon Jan 4, 2024
I've since fixed how my classes are structured, but this is still an issue any time a generic class appears both in a parent class and in a child class.
jcrist commentedon Jan 5, 2024
Thanks for the excellent reproducible issue, this should be fixed by #626.