-
-
Notifications
You must be signed in to change notification settings - Fork 119
include_subclasses fails for classes with generics. AttributeError: __subclasses__. Did you mean: '__subclasscheck__'? #648
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
Comments
I will be happy to work on a fix here, just would like to make sure there is no similar issue/work already ongoing |
Good catch. Feel free to try for a fix. Not sure it should work for |
OK, great. I'll try to fix then. Regarding Child[str] - tried - the same issue. Also I updated the snippet. More typical definition of child is like this, when you have generic parent with not generic child: @attrs.define()
class Parent(
Generic[T],
metaclass=abc.ABCMeta,
):
arg: T
class Child(Parent[str]): ... |
Resolves python-attrs#648 The strategy was using parent_cls.__subclasses__() to get the list of subclasses. In case of generics, this method is unavailable. The fix applies sanitizing the cl and getting its origin class for getting the sublcasses tree. The class itself remains generic in the tree.
@Tinche pls approve the CI workflow |
Uh oh!
There was an error while loading. Please reload this page.
When a parent class with a generics passed to include_subclasses, then:
Quick reproducer:
The text was updated successfully, but these errors were encountered: