Skip to content

Conversation

@mwiebe
Copy link
Contributor

@mwiebe mwiebe commented Feb 8, 2025

What was the problem/requirement? (What/Why)

The RFC 0002 proposal https://github.com/OpenJobDescription/openjd-specifications/blob/mainline/rfcs/0002-model-extensions.md
depends on parsing differently based on the contents of the "extensions" field at the root of the document.
Pydantic V1 doesn't provide a way to carry a context to all the validators, while Pydantic V2 does.

What was the solution? (How)

Update job and environment parsing to use Pydantic V2.

What is the impact of this change?

We will be able to implement the extensions RFC. Pydantic V2 is a nice upgrade over Pydantic V1, so
further work in this library can benefit from upstream improvements.

How was this change tested?

  • Have you run the unit tests?

Yes, have run all the tests. In some cases, I found that Pydantic V2 has more strict behavior than V1,
and I updated the tests to accommodate. While I mostly preserved the error message formatting, I
made some small tweaks to the messages being validated in the tests.

Was this change documented?

  • Are relevant docstrings in the code base updated?

Yes, I updated the explainer documentation that included Pydantic V1 details to reflect V2.

Is this a breaking change?

While largely compatible, the underlying implementation uses Pydantic V2 models instead of Pydantic V1
models, and they have incompatible interfaces. Usage of this library that depends on those internal details
will need to be updated.

Does this change impact security?

This change doesn't impact security. Updating to Pydantic V2 will help the library to maintain up-to-date
dependencies.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mwiebe mwiebe requested a review from a team as a code owner February 8, 2025 01:54
@Ahuge
Copy link

Ahuge commented Feb 8, 2025

🎉

crowecawcaw
crowecawcaw previously approved these changes Feb 10, 2025
@epmog
Copy link
Contributor

epmog commented Feb 10, 2025

And the follow-up, it doesn't seem like it's breaking, but because it's such an overhaul underneath we're going to go with a minor version bump? I think I can get behind that.

@mwiebe
Copy link
Contributor Author

mwiebe commented Feb 11, 2025

And the follow-up, it doesn't seem like it's breaking, but because it's such an overhaul underneath we're going to go with a minor version bump? I think I can get behind that.

You mean in OpenJobDescription/openjd-cli#134, right? It seemed reasonable to err that way in an abundance of caution, yes.

Signed-off-by: Mark Wiebe <399551+mwiebe@users.noreply.github.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
14.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@epmog epmog left a comment

Choose a reason for hiding this comment

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

This is exciting - Ship it!

@mwiebe mwiebe enabled auto-merge (rebase) February 11, 2025 04:10
@mwiebe mwiebe merged commit 67b324f into OpenJobDescription:mainline Feb 11, 2025
18 of 19 checks passed
@mwiebe mwiebe deleted the pydantic2 branch February 11, 2025 17:05
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.

4 participants