BaseModel: expose __init__ method arguments and class docstring like dataclasses #2464
tweakimp
started this conversation in
Feature Request
Replies: 1 comment 1 reply
-
AFAIK this isn't possible because all this data is populated by metaclass magic. For pycharm there is a plugin. I wonder if we could get special support in MyPy/Pylance for pydantic classes/dataclasses. MyPy has special support for the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to see the BaseModel parent class to expose the
__init__
method header and the docstring like dataclasses do.This feature reminds me of functools.wraps, which saves the name and the docstring of decorated functions.
Right now, the docstring of the
Inherited
class is missing whenBaseModel
is inherited and the__init__
method is not exposed when writing the initialization of an instance.Open the following code in your IDE (Python 3.7 or higher):
In VSCode it looks like this:
Dataclass completion hint shows
__init__
arguments and typesDataclass hover shows arguments, types and docstring
Inherited completion hint only says
**data
Inherited hover also inherits BaseModel docstring and overwrites class docstring
Beta Was this translation helpful? Give feedback.
All reactions