Typing feature to statically get all subclasses of class
Discussions on Python.org
Typing feature to statically get all subclasses of class
I sometimes find myself with this problem: class Base: # Possibly an ABC ... class SubA(Base): ... class SubB(Base): ... For example with custom exceptions, base ast nodes and so on. Now I often want to use exhaustive pattern matching while excluding the base class, since it is often abstract. In this case, I often find myself missing some way to describe “all subclasses of a type”. In this case, I would usually have to do: ... # Code from before type AllSubclassesT = Sub...
0 comments
No comments yet.