-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X
Description
Checks
- [x ] I added a descriptive title to this issue
- [x ] I have searched (google, github) for similar issues and couldn't find anything
- [x ] I have read and followed the docs and still think this is a bug
Bug
When running mypy using create_model_from_typeddict() I get a type error for the input - the code however works as expected. When I run the code below, using mypy myscript.py, I get the following error.
error: Argument 1 to "create_model_from_typeddict" has incompatible type "Type[SomeDict]"; expected "Type[TypedDict]"
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
pydantic version: 1.8.2
pydantic compiled: True
install path: /Users/lewiswolstanholme/.local/share/virtualenvs/drum-shape-
predictor-YZkKhtr_/lib/python3.9/site-packages/pydantic
python version: 3.9.6 (default, Jun 29 2021, 06:20:32) [Clang 12.0.0 (clang-1200.0.32.29)]
platform: macOS-10.15.7-x86_64-i386-64bit
optional deps. installed: ['typing-extensions']
from typing import TypedDict
import pydantic
class SomeDict(TypedDict):
val: int
name: str
# this could be a valid/invalid declaration
obj: SomeDict = {
'val': 12,
'name': 'John',
}
# validate with pydantic
try:
pydantic.create_model_from_typeddict(SomeDict)(**obj)
except pydantic.ValidationError as exc:
print(f"ERROR: Invalid schema: {exc}")Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X