Typing feature to statically get all subclasses of class

I’m afraid this won’t work because Python’s type system is isn’t closed-world, so type-checkers can’t reliably determine all of the subclasses that exist. One way around this could be by adding support for sealed classes from e.g. Draft PEP: Sealed decorator for static typing, but this proposal seems to have stranded.

3 Likes