-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[MAINTENANCE] Pydantic 2.0 support #8604
Changes from all commits
f6071ee
260913e
36ae081
d8c9f3a
bf5d390
43ea3a9
10f3433
ab0eacf
c8b57bf
d5bb4ee
16205b0
1d3c8a8
f860670
0ceaf9a
0bd3cdc
080019c
e8812be
06f473f
f0e9f84
9767e1b
f006a0f
329139e
c80ce4b
b32cf30
c41687b
fe07ce5
46519ee
f778423
c0b8cfa
ec2e6f7
0bd7462
f4d776e
9bb8a5e
8fe9a31
ee24f78
4d80172
80eab95
0670e34
35f4025
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,13 +57,12 @@ jobs: | |
run: pip install -r requirements-types.txt -r reqs/requirements-dev-contrib.txt | ||
- run: invoke lint --no-fmt | ||
- run: invoke fmt --check | ||
- name: Marker-coverage-check | ||
run: | | ||
invoke marker-coverage | ||
- name: Type-check | ||
run: | | ||
invoke type-check --ci --pretty | ||
invoke type-check --ci --pretty --check-stub-sources | ||
- name: Marker-coverage-check | ||
run: invoke marker-coverage | ||
|
||
docs-changes: | ||
# check whether docs were changed | ||
|
@@ -405,6 +404,24 @@ jobs: | |
- name: Run the tests | ||
run: invoke ci-tests -m unit --xdist --slowest=10 --timeout=2.0 | ||
|
||
pydantic-v1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test for our min version of pydantic now that the other tests will be installing v2 |
||
needs: [unit-tests, static-analysis] | ||
if: github.event.pull_request.draft == false | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.8" | ||
cache: "pip" | ||
cache-dependency-path: reqs/requirements-dev-test.txt | ||
- name: Install dependencies | ||
run: pip install . -c ci/constraints-test/pydantic-v1-install.txt -r reqs/requirements-dev-test.txt | ||
- name: Run the tests | ||
run: invoke ci-tests -m unit --xdist --slowest=10 --timeout=2.0 | ||
|
||
airflow220-min-versions: | ||
needs: [unit-tests, static-analysis] | ||
runs-on: ubuntu-latest | ||
|
@@ -481,6 +498,7 @@ jobs: | |
py39-min-versions, | ||
py310-min-versions, | ||
py311-min-versions, | ||
pydantic-v1, | ||
airflow220-min-versions, | ||
import_gx, | ||
usage_stats_integration | ||
|
@@ -528,6 +546,7 @@ jobs: | |
py39-min-versions, | ||
py310-min-versions, | ||
py311-min-versions, | ||
pydantic-v1, | ||
airflow220-min-versions, | ||
import_gx, | ||
usage_stats_integration, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# this is higher than our min version but is the earliest version that actually works | ||
# TODO: update our min version or fix gx for our current min version | ||
pydantic==1.10.8 | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our min version of pydantic in our requirements file is I will create followup tickets for taking the action here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ black[jupyter]==23.3.0 # Linting / code style | |
Click>=7.1.2 # CLI tooling | ||
cookiecutter==2.1.1 # Project templating | ||
mypy==1.5.1 # Type checker | ||
pydantic>=1.0,<2.0 # Needed for mypy plugin | ||
pydantic>=1.0 # Needed for mypy plugin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should make me 1.10.8? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I don't understand why we have this entry in cli/requirements at all. |
||
pytest>=5.3.5 # Test framework | ||
ruff==0.0.284 # Linting / code style | ||
twine==3.7.1 # Packaging | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pydantic | ||
|
||
from great_expectations.compatibility.not_imported import ( | ||
is_version_greater_or_equal, | ||
) | ||
|
||
if is_version_greater_or_equal(version=pydantic.VERSION, compare_version="2.0.0"): | ||
# TODO: don't use star imports | ||
from pydantic.v1 import * # noqa: F403 | ||
from pydantic.v1 import ( | ||
AnyUrl, | ||
UrlError, | ||
error_wrappers, | ||
errors, | ||
fields, | ||
generics, | ||
json, | ||
networks, | ||
schema, | ||
typing, | ||
) | ||
Comment on lines
+10
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does it work if I'm creating a V2 Base Model and I want to use one of these classes? I guess we can cross that bridge when we get there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That won't be possible yet, without some conditional imports. We would need some kind of |
||
from pydantic.v1.generics import GenericModel | ||
from pydantic.v1.main import ModelMetaclass | ||
|
||
else: | ||
# TODO: don't use star imports | ||
from pydantic import * # type: ignore[assignment,no-redef] # noqa: F403 | ||
from pydantic import ( # type: ignore[no-redef] | ||
AnyUrl, | ||
UrlError, | ||
error_wrappers, | ||
errors, | ||
fields, | ||
generics, | ||
json, | ||
networks, | ||
schema, | ||
typing, | ||
) | ||
from pydantic.generics import GenericModel # type: ignore[no-redef] | ||
from pydantic.main import ModelMetaclass # type: ignore[no-redef] | ||
|
||
__all__ = [ | ||
"AnyUrl", | ||
"error_wrappers", | ||
"errors", | ||
"fields", | ||
"GenericModel", | ||
"generics", | ||
"json", | ||
"ModelMetaclass", | ||
"networks", | ||
"schema", | ||
"typing", | ||
"UrlError", | ||
] | ||
NathanFarmer marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I swapped the order of these to get faster feedback on typing issues