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
It appears that when you have attr classes that are in a file with from __future__ import annotations, cattrs does not work when trying to structure a simple type to your attrs class. This is because attrs uses __annotations__ to get the type annotations and with PEP-563, these are now strings instead of the actual type, see python-attrs/attrs#288 (comment) for a description
This little script below demonstrates the problem. If you comment out the first line, the from __future__ import annotations, it works, but if you put it back, you get a ValueError because the type that cattr passed to functools.singledispatch is a string of the type, not the type itself.
Description
It appears that when you have
attr
classes that are in a file withfrom __future__ import annotations
, cattrs does not work when trying tostructure
a simple type to your attrs class. This is because attrs uses__annotations__
to get the type annotations and with PEP-563, these are now strings instead of the actual type, see python-attrs/attrs#288 (comment) for a descriptionThis little script below demonstrates the problem. If you comment out the first line, the
from __future__ import annotations
, it works, but if you put it back, you get aValueError
because the type thatcattr
passed tofunctools.singledispatch
is a string of the type, not the type itself.The text was updated successfully, but these errors were encountered: