Hey,
We are using custom pydantic dataclass that wrapped original pydantic dataclass. It contains some helper serializing function etc. as extra. And generally behaving as pydantic dataclass (same arguments, same return types).
And we import directly our dataclass decorator like below;
from my_package import dataclass
@dataclass
class MyModel:
name : str
# it's warning as 'Unexpected Arguments'
my_model = MyModel(name='Tom')
As workaround we can import as below and get rid of warning.
if TYPE_CHECKING:
from pydantic.dataclasses import dataclass
else:
from my_package import dataclass
But it should be same file with file that defined of model class. I want to add one time this conditional statement and centralized location for example __init__.py
file of custom packege like below.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pydantic.dataclasses import dataclass
else:
from .dataclass import dataclass
__all__ = [
"dataclass",
]
I guess plugin examine only import on file which model defined. I think not important structure of new dataclass because also if we import original dataclass in different module and then import this module and use dataclass like chain, again plugin not recognize pydantic dataclass. It can be supported? Or can you give a new workaround tip for centrailzed importations.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too