I would like to implement a decorator or base class that obtains the list of fields in the declared class and adds to it a constructor that takes arguments corresponding to these fields. Similar to how @dataclass or SQLAlchemy's declarative_base works.
My question is - how do I get PyCharm and other IDEs to recognize and suggest autocompletion for this constructor.
For example, if I write this code:
@dataclass
class Foo:
bar: int
baz: str
Foo([caret is here])
and press command-P (Parameter Info), PyCharm will show a tooltip with bar:int, baz:str. Additionally, if I make a mistake in the parameter name, it will warn me. So basically, it seems that PyCharm "knows" that the @dataclass decorator adds an __init__ method and its exact signature.
How do I get it to do that for my decorator?