Python. Use object attributes to annotate methods; Dynamically-defined type annotations
Python. Use object attributes to annotate methods; Dynamically-defined type annotations Question: Python pseudocode I want to dynamically annotate returning types for my methods. I want something that looks like this: class Foo: def __init__(model: BaseModel): self.model = model def find_model(query) -> self.model: return db.get(query) And then use it like this: bar = Foo(model=MyModel) # pass …