Skip to content
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

Feature: Support pydantic v2 #45

Merged
merged 6 commits into from
Sep 8, 2023
Merged

Feature: Support pydantic v2 #45

merged 6 commits into from
Sep 8, 2023

Conversation

sudosubin
Copy link
Contributor

Related Issues

Description

  • Migrate pydantic v1 to v2
    • Updated pyproject.toml, poetry.lock
    • Updated deprecated functions/methods into v2 functions/methods (codegen, githubkit)
    • Actually I wanted to make githubkit support both pydantic v1 and v2, but it was too complex and required so many changes
  • Added SetSchema, because List with unique_items was deprecated, and recommended to use Set
  • Updated to use Annotated for pydantic models
    • I only checked Missing, but there is a need to check if the same applies to Union required.

@yanyongyu yanyongyu added the enhancement New feature or request label Sep 7, 2023
@yanyongyu
Copy link
Owner

I'm not sure that set is a good way to replace the unique list since the set type does not contain order information. But i find an other way to impl this in the pydantic issue pydantic/pydantic-core#820 (comment). If we don't need to keep the order information, the set type is recommended.

@sudosubin
Copy link
Contributor Author

Thank you for the feedback. I applied your comment :D

GitHub's OpenAPI does not yet have a schema with uniqueItems=True, but if one exists in the future, it will be safer to keep the order.

@yanyongyu
Copy link
Owner

Thanks foryour great help with this feature. I still need to investigate how to make it compatible with pydantic v1 and v2 after this pr is merged. The codegen part should be rewrited to support features including compatibility layer, lazy loading logic and api versioning. This may take a long time before release since i do not have too much free time.

githubkit/graphql/models.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@yanyongyu yanyongyu merged commit e7a96da into yanyongyu:master Sep 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Pydantic v2
2 participants