feat: Add compatible methods for Pydantic V1.8 and V2 #355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
The goal of this PR is to maintain backward compatibility with Pydanitc V1 and V2 without raising any deprecation warnings.
Description
This PR allows to use both V1.8 and V2 without triggering any deprecation warnings
It also allows to keep the current code for V3 (possibly)
The main edits are done in src/firebolt/model/V1/init.py
It introduces a utility function that gets the desired method based on the current pydantic version:
BaseModel configurations are also handled differently:
Other changes
dict
are changed to the new version-compatible methodmodel_dict
parse_obj
are changed to the new version-compatible methodparse_model
json
are changed to the new version-compatible methodmodel_dump_json
Tests
Tested with
pydantc==1.8.2
andpydantic==2.6
on Python 3.9