Open apirogov opened 2 years ago
Given the current state of things, it should be possible, using an approach similar to the make_mandatory decorator and combining it with a type hint traversal to substitute the type.
Main question is to make sure that this also works fine with Partial
and Fields
and the cached type hints.
When subclassing a schema, e.g. to say "use MyPerson instead of Person in all fields"
Otherwise each field must be overridden explicitly, which is error prone or confusing.
Again the question arises: Decorator? Meta-class? this should not be too annoying to use.
Maybe the decorator should look like
and should
In all other cases (not specializing to a subtype) it should remain a manual type hint, otherwise it would be to easy to wreak havoc.