-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Improve test coverage for pydantic.type_adapter #5930
New issue
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
Conversation
Deploying with
|
| Latest commit: |
c49276e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0d191e80.pydantic-docs2.pages.dev |
| Branch Preview URL: | https://type-adapter-test.pydantic-docs2.pages.dev |
|
please review |
1705cf8 to
9c1c47a
Compare
pydantic/type_adapter.py
Outdated
| json_schema: dict[str, Any] = {} | ||
| if definitions: | ||
| json_schema['$defs'] = definitions | ||
| json_schema['$defs'] = definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the if definitions condition is always True. So, I did this change to make the coverage 100%
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need t 8000 o readd it... 👀
from pydantic.type_adapter import TypeAdapter
_, top_level_schema = TypeAdapter.json_schemas(
[(int, 'validation', TypeAdapter(int))],
ref_template='#/components/schemas/{model}',
)
print(top_level_schema)
# {}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you are right.
I've made a test from your example 😃
9c1c47a to
65a9bb1
Compare
|
please update |
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Selected Reviewer: @Kludex