8000 Improve test coverage for pydantic.type_adapter by hramezani · Pull Request #5930 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@hramezani
Copy link
Member
@hramezani hramezani commented May 30, 2023

Selected Reviewer: @Kludex

@cloudflare-workers-and-pages
Copy link
cloudflare-workers-and-pages bot commented May 30, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

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

View logs

@hramezani
Copy link
Member Author

please review

json_schema: dict[str, Any] = {}
if definitions:
json_schema['$defs'] = definitions
json_schema['$defs'] = definitions
Copy link
Member Author

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%

Copy link
Member
@Kludex Kludex May 31, 2023

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)
# {}

Copy link
Member Author

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 😃

@hramezani hramezani force-pushed the type_adapter_test branch from 9c1c47a to 65a9bb1 Compare May 31, 2023 07:26
@Kludex
Copy link
Member
Kludex commented May 31, 2023

please update

@pydantic-hooky pydantic-hooky bot added awaiting author revision awaiting changes from the PR author and removed ready for review labels May 31, 2023
@pydantic-hooky pydantic-hooky bot assigned hramezani and unassigned Kludex May 31, 2023
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
@hramezani hramezani merged commit d91c1ee into main May 31, 2023
@hramezani hramezani deleted the type_adapter_test branch May 31, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author revision awaiting changes from the PR author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0