Open
Description
Issue
Using python 3.10.7, pydantic 4.3.2, pydantic-partial 0.3.2 and 0.3.3, mypy 0.971
from pydantic import BaseModel
from pydantic_partial import PartialModelMixin
class Foo(PartialModelMixin, BaseModel):
id: int
PartialFoo = Foo.as_partial()
reveal_type(Foo())
reveal_type(PartialFoo())
def something(x: PartialFoo):
return x.dict()
running mypy will return:
tmp/foo.py:10: note: Revealed type is "foo.Foo"
tmp/foo.py:11: note: Revealed type is "foo.Foo"
tmp/foo.py:13: error: Variable "foo.PartialFoo" is not valid as a type
tmp/foo.py:13: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
tmp/foo.py:14: error: PartialFoo? has no attribute "dict"
(revealed type for PartialFoo()
is "Any" in 0.3.2 and "foo.Foo" in 0.3.3).
Question / Request
How to use partials as type annotations? If there's a way to do it, could it be documented?