Created
June 19, 2024 21:23
-
-
Save AliciaMoses/ada842cc915264ab3ee4a340c9568245 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo: | |
a = 1 | |
class Bar(Foo): | |
b = 2 | |
class Baz(Foo): | |
c = 3 | |
class Spam: | |
foo_subclasses_types = Foo.__subclasses__() | |
foo_subclass_objects = [subclass() for subclass in foo_subclasses_types] # Mutable class attributes should be annotated with `typing.ClassVar` | |
def spam_method(self) -> list[Foo]: | |
foo_subclasses_types = Foo.__subclasses__() | |
foo_subclass_objects = [subclass() for subclass in foo_subclasses_types] | |
return foo_subclass_objects |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment