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
Running this code results in a ClassValidationError with one sub-exception: a StructureHandlerNotFoundError which says "Unsupported type: Final[float]. Register a structure hook for it.".
Pitch
Final is one of the most basic type annotations in Python. Although I'm not familiar at all with cattrs internals, it shouldn't be too hard to add support for this type hint, as Final attributes should be structured and unstructured in the same way as their non-Finalcounterparts.
A Note About Frozen
attrs provides a frozen attribute (and I'm using that), but it's not the same thing. frozen operates at runtime, while Final can also be used during static analysis.
The text was updated successfully, but these errors were encountered:
dtoniolo
changed the title
Final Primitive Types are not RecognizedFinal Types are not Recognized
Mar 15, 2023
Description
Hi, first of all thanks for the amazing work, I've recently begun using both
attrs
andcattrs
and I find them very useful and elegant.I'm trying to structure some custom classes and all of my type annotations are recognized correctly, except for those using
typing.Final
.What I Did
Here's a minmum example to reproduce the issue:
Running this code results in a
ClassValidationError
with one sub-exception: aStructureHandlerNotFoundError
which says"Unsupported type: Final[float]. Register a structure hook for it."
.Pitch
Final
is one of the most basic type annotations in Python. Although I'm not familiar at all withcattrs
internals, it shouldn't be too hard to add support for this type hint, asFinal
attributes should be structured and unstructured in the same way as their non-Final
counterparts.A Note About Frozen
attrs
provides afrozen
attribute (and I'm using that), but it's not the same thing.frozen
operates at runtime, whileFinal
can also be used during static analysis.The text was updated successfully, but these errors were encountered: