You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have to use pydantic_extra_types.pendulum_dt.DateTime to use pendulum.DateTime objects in pydantic dataclasses as a workaround, but mypy does not accept a pendulum.DateTime object for a (pydantic) dataclass with a pydantic_extra_types.pendulum_dt.DateTime object. This is not working with the mypy plugin enabled:
pyproject.toml:
[tool.mypy]
plugins = [
"pydantic.mypy"
]
Example Code
importpendulumfrompydantic.dataclassesimportdataclassfrompydantic_extra_types.pendulum_dtimportDateTime@dataclass(config={"strict": True})classExample:
datetime: DateTimeinstance=pendulum.DateTime(1970, 1, 1)
# Works fine, but mypy throws [args-type]Example(datetime=instance)
# scratch.py:14: error: Argument "datetime" to "Example" has incompatible type "pendulum.datetime.DateTime"; expected "pydantic_extra_types.pendulum_dt.DateTime" [arg-type]
Initial Checks
Description
We have to use
pydantic_extra_types.pendulum_dt.DateTime
to use pendulum.DateTime objects in pydantic dataclasses as a workaround, but mypy does not accept apendulum.DateTime
object for a (pydantic) dataclass with apydantic_extra_types.pendulum_dt.DateTime
object. This is not working with the mypy plugin enabled:pyproject.toml:
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: