From 01117821562bea7cbf810c456f24718895759cd7 Mon Sep 17 00:00:00 2001 From: Sam Neubardt Date: Tue, 8 Apr 2025 14:37:16 -0400 Subject: [PATCH] Fix warnings about the Config class being deprecated in Pydantic 3 Also upgrades a couple of dev dependencies needed to get the build running. --- README.md | 2 +- planetary_computer/sas.py | 9 +++++---- requirements-dev.txt | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5656d1f..fc931f3 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ source env/bin/activate python3 -m pip install -r requirements-dev.txt ## Install locally -pip install -e . +pip install -e .[adlfs,azure,dev] ## Format code ./scripts/format diff --git a/planetary_computer/sas.py b/planetary_computer/sas.py index 0b6f311..05b97f3 100644 --- a/planetary_computer/sas.py +++ b/planetary_computer/sas.py @@ -43,10 +43,11 @@ class SASBase(BaseModel): expiry: datetime = Field(alias="msft:expiry") """RFC339 datetime format of the time this token will expire""" - class Config: - if _PYDANTIC_2_0: - populate_by_name = True - else: + if _PYDANTIC_2_0: + model_config = pydantic.ConfigDict(populate_by_name=True) + else: + + class Config: allow_population_by_field_name = True json_encoders = {datetime: datetime_to_str} diff --git a/requirements-dev.txt b/requirements-dev.txt index 70f407e..c07181e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ black==24.3.0 -flake8==4.0.1 +flake8==7.2.0 ipdb==0.13.9 -mypy==0.961 +mypy==1.15.0 types-requests==2.28.1 setuptools==65.5.1 pytest