Currently, while computing schemas for dataclasses, we keep some thread-local context in _RECURSION_GUARD.seen_classes.
The field_for_schema function does not manage the thread-locals in _RECURSION_GUARD, yet it can (attempt to) use them if called for a type that is or includes a dataclass (or other exotic types). This can cause an exception if field_for_schema is called before the first call to class_schema.
from marshmallow_dataclass import field_for_schema
class A:
x: int
field_for_schema(A) # => AttributeError("'_thread__local' object has not attribute 'seen_classes'")
This bug is fixed by #214 (currently a work-in-progress).
Currently, while computing schemas for dataclasses, we keep some thread-local context in
_RECURSION_GUARD.seen_classes
.The
field_for_schema
function does not manage the thread-locals in _RECURSION_GUARD, yet it can (attempt to) use them if called for a type that is or includes a dataclass (or other exotic types). This can cause an exception iffield_for_schema
is called before the first call toclass_schema
.This bug is fixed by #214 (currently a work-in-progress).