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

Pydantic v2 #235

Merged
merged 3 commits into from
May 26, 2024
Merged

Pydantic v2 #235

merged 3 commits into from
May 26, 2024

Conversation

fabiob
Copy link
Contributor

@fabiob fabiob commented May 25, 2024

Changes

The pydantic.VERSION variable is not a Literal expression, so mypy is unable to assert whether we're in an environment running on Pydantic V2 or V1. This results in mypy trying to follow both paths and failing with a no-redef error, which is silenced by the # type: ignore comment.

This PR improves the code quality by removing the # type: ignore comment and adding a if TYPE_CHECKING block that only imports the latest version (V2).

This was the main intent of the PR. As a bonus, this also updates the example kwarg to examples, as it is expected for Pydantic V2.

One line description for the changelog

Improved Pydantic V2 typechecking support.

  • Tests pass
  • Appropriate changes to README are included in PR (Pydantic is not referenced in the README)

Signed-off-by: Fabio Batista <fabio@atelie.dev.br>
@fabiob fabiob force-pushed the pydantic-v2 branch 2 times, most recently from 205a6a5 to 6aac143 Compare May 25, 2024 01:58
Signed-off-by: Fabio Batista <fabio@atelie.dev.br>
Copy link
Member

@xSAVIKx xSAVIKx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiob LGTM! Thanks for the contribution

@xSAVIKx xSAVIKx merged commit 11520e3 into cloudevents:main May 26, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants