class Foo:
method_type: type
def method(self) -> ???:
# code
# Example use:
class FooStr(Foo):
method_type = str
foo_str = FooStr().method() # should be str according to vscode's intellisense
class FooInt(Foo):
method_type = int
foo_int = FooInt().method() # similarly, this should be int
Note that simply replacing the ???
with method_type
doesn't work as far as I've tested it.
How would I go about doing this?