Christian Heimes added the comment:
My feature request has been around for 8 years without any progress. I don't
even recall why I needed the feature in the first place.
--
resolution: -> rejected
stage: patch review -> resolved
status: open -> closed
___
Antoine Pitrou added the comment:
> I like to do something similar to marker interfaces [1] with ABCs.
> For introspection and documentation I need a way to get all
> non-abstract classes that are implemented by an ABC.
You mean that implement an ABC? But you also need to return real
subclasses
Christian Heimes added the comment:
I like to do something similar to marker interfaces [1] with ABCs. For
introspection and documentation I need a way to get all non-abstract classes
that are implemented by an ABC.
How about I change the implementation to get_subclasses(direct=False) to retur
Antoine Pitrou added the comment:
> It's called get_VIRTUAL_subclasses() for a reason. You can get the
> real subclasses of an ABC with standard tool, e.g. recurse into
> __subclasses__().
What use case are you trying to solve? If I want to find out all classes
which implement an ABC, I don't ca
Christian Heimes added the comment:
It's called get_VIRTUAL_subclasses() for a reason. You can get the real
subclasses of an ABC with standard tool, e.g. recurse into __subclasses__().
For virtual subclasses you have to deal with the internals like _abc_registry.
I could implement all four cas
Antoine Pitrou added the comment:
Another problem is what happens when an implementation uses non-"virtual"
inheritance:
>>> issubclass(collections.UserDict, collections.abc.Mapping)
True
>>> collections.UserDict in collections.abc.Mapping.get_virtual_subclasses(True)
False
IOW, I think this g
Antoine Pitrou added the comment:
I'm not sure "recurse" is a relevant distinction here. A subclass of a subclass
is still a subclass. "Virtual" subclasses should not be different.
At the very least, if "recurse" is kept, I would expect it to be True by
default.
--
nosy: +pitrou
New submission from Christian Heimes:
ABCs are missing one important introspection feature. They have no API to get
registered virtual subclasses. The patch implements a new method
get_virtual_subclasses(recurse=False).
ABC.get_virtual_subclasses() returns the direct virtual subclasses of an A