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

Bump pydantic to v2 #4053

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lambdas/pkgpush/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# pip-compile
#
annotated-types==0.7.0
# via pydantic
attrs==23.2.0
# via
# jsonschema
Expand Down Expand Up @@ -53,15 +55,17 @@ pkgutil-resolve-name==1.3.10
# via jsonschema
platformdirs==4.2.0
# via quilt3
pydantic==1.10.14
pydantic==2.8.2
# via
# quilt-shared
# t4_lambda_pkgpush (setup.py)
pydantic-core==2.20.1
# via pydantic
python-dateutil==2.8.2
# via botocore
pyyaml==6.0.1
# via quilt3
quilt-shared[boto,pydantic,quilt] @ git+https://github.com/quiltdata/quilt@7c6edd14fbe8a26613bc26b1bbdc0b956132ef8c#subdirectory=py-shared
quilt-shared[boto,pydantic,quilt] @ git+https://github.com/quiltdata/quilt@b56fe52de4590242f998a23401017b3014411306#subdirectory=py-shared
# via t4_lambda_pkgpush (setup.py)
quilt3 @ git+https://github.com/quiltdata/quilt@5c2b79128fe4d5d1e6093ff6a7d11d09d3315843#subdirectory=api/python
# via
Expand Down Expand Up @@ -102,11 +106,13 @@ types-s3transfer==0.10.0
# via boto3-stubs
typing-extensions==4.9.0
# via
# annotated-types
# boto3-stubs
# botocore-stubs
# mypy-boto3-s3
# mypy-boto3-sts
# pydantic
# pydantic-core
# quilt-shared
# types-aiobotocore
# types-aiobotocore-s3
Expand Down
4 changes: 2 additions & 2 deletions lambdas/pkgpush/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
package_dir={"": "src"},
install_requires=[
"boto3 ~= 1.28",
"pydantic ~= 1.10",
"pydantic ~= 2.8",
(
"quilt3 @ git+https://github.com/quiltdata/quilt@"
"5c2b79128fe4d5d1e6093ff6a7d11d09d3315843"
"#subdirectory=api/python"
),
(
"quilt_shared[pydantic,boto,quilt] @ git+https://github.com/quiltdata/quilt@"
"7c6edd14fbe8a26613bc26b1bbdc0b956132ef8c"
"b56fe52de4590242f998a23401017b3014411306"
"#subdirectory=py-shared"
),
],
Expand Down
8 changes: 5 additions & 3 deletions lambdas/pkgpush/tests/test_hash_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ def test_invoke_hash_lambda(lambda_stub: Stubber):
"key": pk.path,
"version": pk.version_id,
},
}
},
separators=(",", ":"),
),
},
)

assert (
t4_lambda_pkgpush.invoke_hash_lambda(pk, CREDENTIALS, SCRATCH_BUCKETS)
== checksum
== Checksum(**checksum)
)


Expand Down Expand Up @@ -164,7 +165,8 @@ def test_invoke_hash_lambda_error(lambda_stub: Stubber):
"key": pk.path,
"version": pk.version_id,
},
}
},
separators=(",", ":"),
),
},
)
Expand Down
10 changes: 8 additions & 2 deletions lambdas/s3hash/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ aioitertools==0.11.0
# via aiobotocore
aiosignal==1.3.1
# via aiohttp
annotated-types==0.7.0
# via pydantic
async-timeout==4.0.3
# via aiohttp
attrs==23.2.0
Expand Down Expand Up @@ -75,15 +77,17 @@ pkgutil-resolve-name==1.3.10
# via jsonschema
platformdirs==4.2.0
# via quilt3
pydantic==1.10.14
pydantic==2.8.2
# via
# quilt-shared
# t4_lambda_s3hash (setup.py)
pydantic-core==2.20.1
# via pydantic
python-dateutil==2.8.2
# via botocore
pyyaml==6.0.1
# via quilt3
quilt-shared[boto,pydantic,quilt] @ git+https://github.com/quiltdata/quilt@7c6edd14fbe8a26613bc26b1bbdc0b956132ef8c#subdirectory=py-shared
quilt-shared[boto,pydantic,quilt] @ git+https://github.com/quiltdata/quilt@b56fe52de4590242f998a23401017b3014411306#subdirectory=py-shared
# via t4_lambda_s3hash (setup.py)
quilt3==5.4.0
# via quilt-shared
Expand Down Expand Up @@ -125,11 +129,13 @@ types-s3transfer==0.10.0
typing-extensions==4.9.0
# via
# aioitertools
# annotated-types
# boto3-stubs
# botocore-stubs
# mypy-boto3-s3
# mypy-boto3-sts
# pydantic
# pydantic-core
# quilt-shared
# types-aiobotocore
# types-aiobotocore-s3
Expand Down
4 changes: 2 additions & 2 deletions lambdas/s3hash/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
install_requires=[
"aiobotocore ~= 2.11",
"botocore ~= 1.31",
"pydantic ~= 1.10",
"pydantic ~= 2.8",
"types-aiobotocore[s3] ~= 2.11",
(
"quilt_shared[pydantic,boto,quilt] @ git+https://github.com/quiltdata/quilt@"
"7c6edd14fbe8a26613bc26b1bbdc0b956132ef8c"
"b56fe52de4590242f998a23401017b3014411306"
"#subdirectory=py-shared"
),
],
Expand Down
2 changes: 1 addition & 1 deletion lambdas/s3hash/src/t4_lambda_s3hash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def sha256_chunked(cls, value: bytes):
def for_parts(cls, checksums: T.Sequence[bytes]):
return cls.sha256_chunked(hash_parts(checksums))

_EMPTY_HASH = hashlib.sha256().digest()
_EMPTY_HASH: T.ClassVar[bytes] = hashlib.sha256().digest()

@classmethod
def empty(cls):
Expand Down
2 changes: 1 addition & 1 deletion py-shared/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies = [

[project.optional-dependencies]
pydantic = [
"pydantic ~= 1.10",
"pydantic ~= 2.8",
"typing-extensions ~= 4.9",
]
boto = [
Expand Down
6 changes: 2 additions & 4 deletions py-shared/src/quilt_shared/lambdas_large_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import typing as T

import pydantic
import typing_extensions as TX

from . import const

Expand All @@ -15,10 +16,7 @@
from mypy_boto3_s3 import S3Client


class VersionId(pydantic.ConstrainedStr):
strip_whitespace = True
min_length = 1
max_length = 1024
VersionId = TX.Annotated[str, pydantic.StringConstraints(strip_whitespace=True, min_length=1, max_length=1024)]


class RequestTooLarge(Exception):
Expand Down
17 changes: 11 additions & 6 deletions py-shared/src/quilt_shared/pkgpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import typing as T

import pydantic
import typing_extensions as TX

from .aws import AWSCredentials
from .types import NonEmptyStr
Expand All @@ -14,12 +15,16 @@
from quilt3.util import PhysicalKey


class TopHash(pydantic.ConstrainedStr):
min_length = 64
max_length = 64
regex = r"^[0-9a-f]+$"
strip_whitespace = True
to_lower = True
TopHash = TX.Annotated[
str,
pydantic.StringConstraints(
min_length=64,
max_length=64,
pattern=r"^[0-9a-f]+$",
strip_whitespace=True,
to_lower=True,
),
]


class S3ObjectSource(pydantic.BaseModel):
Expand Down
5 changes: 1 addition & 4 deletions py-shared/src/quilt_shared/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import pydantic
import typing_extensions as TX


class NonEmptyStr(pydantic.ConstrainedStr):
min_length = 1
strip_whitespace = True
NonEmptyStr = TX.Annotated[str, pydantic.StringConstraints(min_length=1, strip_whitespace=True)]


ConsParams = TX.ParamSpec("ConsParams")
Expand Down