Let's say we have a function
def get_attr_wrapper(obj: object, attr: str) -> ???: return getattr(obj, attr)
How can I infer the return type of get_attr_wrapper
based on the parameters given?
Maybe with a generic somehow?
For example, if I passed in
from dataclasses import dataclass@dataclassclass Foo: bar: strfoo = Foo(bar="baz")rv = get_attr_wrapper(foo, "bar")
rv
would be inferred by Python's type checker as being of type string
.