We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In BaseModel.model_dump, context has the type annotation Any | None:
BaseModel.model_dump
context
Any | None
pydantic/pydantic/main.py
Line 427 in d6f00d6
but in TypeAdapter.dump_python, context has the type annotation dict[str, Any] | None (passing something that is not a dict seems to work):
TypeAdapter.dump_python
dict[str, Any] | None
dict
pydantic/pydantic/type_adapter.py
Line 548 in d6f00d6
In the example in the docs, context is a dict: https://docs.pydantic.dev/latest/concepts/serialization/#serialization-context so I'd assume that the context parameter of BaseModel.model_dump should also be dict[str, Any]?
dict[str, Any]
pydantic version: 2.10.6 pydantic-core version: 2.27.2 pydantic-core build: profile=release pgo=false install path: <project>/.venv/lib/python3.12/site-packages/pydantic python version: 3.12.8 (main, Jan 14 2025, 22:49:14) [Clang 19.1.6 ] platform: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.40 related packages: typing_extensions-4.12.2 mypy-1.14.1 commit: unknown
The text was updated successfully, but these errors were encountered:
I think we should type hint as Any. I'll probably handle this as part of pydantic/pydantic-core#1686.
Any
Sorry, something went wrong.
Viicos
No branches or pull requests
Initial Checks
Description
In
BaseModel.model_dump
,context
has the type annotationAny | None
:pydantic/pydantic/main.py
Line 427 in d6f00d6
but in
TypeAdapter.dump_python
,context
has the type annotationdict[str, Any] | None
(passing something that is not adict
seems to work):pydantic/pydantic/type_adapter.py
Line 548 in d6f00d6
In the example in the docs,
context
is adict
: https://docs.pydantic.dev/latest/concepts/serialization/#serialization-context so I'd assume that the context parameter ofBaseModel.model_dump
should also bedict[str, Any]
?Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: