-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subclass registration with generic decorator subclass fails #595
Comments
Hello, sorry for the delay, I have a baby nowdays. The problem is I don't think I don't really know how to improve the situation. |
Hi! First of all congratulations!! Thanks for the reply and sorry for my late reply. I understand very well, I have two little kids too 😁 🤔 I probably don't understand the mechanics enough, but why is it not possible to just register the generic class with unknown Is the problem, that subclass registration should be closed in itself, i.e. there should be nothing unknown and left undone once it's called? |
Not sure what exactly you're suggesting. The problem here is structuring, unstructuring should work just fine (and this is the error you see - StructureHandlerNotFoundError). The strategy fails because it's attempting to set up both structuring and unstructuring. If you need just unstructuring, we can probably accomodate this. When speaking about structuring, the problem is this: assume the strategy worked, what would You could do something like this: converter = Converter()
converter.register_structure_hook(
Decorated, make_dict_structure_fn(Decorated[Any], converter)
)
include_subclasses(Base, converter)
print(converter.structure({"base": 1}, Base)) This will perform no structuring/validation on the contents of the |
Description
I am using the decorator pattern to generate a decorator class
Decorated
from an abstract base classBase
.Since
Base
has many more subclasses and is widely used as an annotation I want to register all subclasses ofBase
with my converter.This works fine if
Decorated
is not a generic class, but as soon as I make theBase
typed field generic,the subclass registration for
Base
fails withThis happens at registration time, not at (un)structuring time.
Is this expected/intended? Can this be mitigated?
The text was updated successfully, but these errors were encountered: