From 2ff3437a36f86dfd376dba9377e67d780ff47419 Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Wed, 21 Aug 2024 15:04:52 +0100 Subject: [PATCH] Fix warnings displayed in test runs --- darwin/exporter/formats/nifti.py | 2 +- darwin/future/data_objects/dataset.py | 4 ++-- darwin/future/data_objects/release.py | 4 ++-- darwin/future/data_objects/sorting.py | 4 ++-- darwin/future/data_objects/team.py | 4 ++-- darwin/importer/formats/nifti.py | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/darwin/exporter/formats/nifti.py b/darwin/exporter/formats/nifti.py index 447f83731..9a861e8dc 100644 --- a/darwin/exporter/formats/nifti.py +++ b/darwin/exporter/formats/nifti.py @@ -14,7 +14,7 @@ import nibabel as nib from nibabel.orientations import io_orientation, ornt_transform except ImportError: - import_fail_string = """ + import_fail_string = r""" You must install darwin-py with pip install darwin-py\[medical] in order to export using nifti format """ diff --git a/darwin/future/data_objects/dataset.py b/darwin/future/data_objects/dataset.py index 134a50f5a..aff98152f 100644 --- a/darwin/future/data_objects/dataset.py +++ b/darwin/future/data_objects/dataset.py @@ -1,6 +1,6 @@ from typing import List, Optional -from pydantic import PositiveInt, validator +from pydantic import PositiveInt, field_validator from darwin.future.data_objects.release import ReleaseList from darwin.future.data_objects.validators import parse_name @@ -30,7 +30,7 @@ class DatasetCore(DefaultDarwin): releases: Optional[ReleaseList] = None # Data Validation - _name_validator = validator("name", allow_reuse=True)(parse_name) + _name_validator = field_validator("name")(parse_name) DatasetList = List[DatasetCore] diff --git a/darwin/future/data_objects/release.py b/darwin/future/data_objects/release.py index c7e5063e7..2c4b3f68e 100644 --- a/darwin/future/data_objects/release.py +++ b/darwin/future/data_objects/release.py @@ -1,6 +1,6 @@ from typing import List -from pydantic import validator +from pydantic import field_validator from darwin.future.data_objects import validators as darwin_validators from darwin.future.pydantic_base import DefaultDarwin @@ -26,7 +26,7 @@ def __str__(self) -> str: return self.name # Data Validation - _name_validator = validator("name", allow_reuse=True)(darwin_validators.parse_name) + _name_validator = field_validator("name")(darwin_validators.parse_name) ReleaseList = List[ReleaseCore] diff --git a/darwin/future/data_objects/sorting.py b/darwin/future/data_objects/sorting.py index bfb7b9c3a..b7bd8edd4 100644 --- a/darwin/future/data_objects/sorting.py +++ b/darwin/future/data_objects/sorting.py @@ -1,6 +1,6 @@ from typing import Literal, Optional -from pydantic import BaseModel, Field, root_validator +from pydantic import BaseModel, Field, model_validator class SortingMethods(BaseModel): @@ -12,7 +12,7 @@ class SortingMethods(BaseModel): priority: Optional[Literal["asc", "desc"]] = Field(None) updated_at: Optional[Literal["asc", "desc"]] = Field(None) - @root_validator(pre=True) + @model_validator(mode="before") def check_at_least_one_field(cls, values): assert any(value is not None for value in values.values()) return values diff --git a/darwin/future/data_objects/team.py b/darwin/future/data_objects/team.py index e23d1ccce..9c54e0430 100644 --- a/darwin/future/data_objects/team.py +++ b/darwin/future/data_objects/team.py @@ -2,7 +2,7 @@ from typing import List, Optional -from pydantic import validator +from pydantic import field_validator from darwin.future.core.client import ClientCore from darwin.future.core.team.get_raw import get_team_raw @@ -56,7 +56,7 @@ class TeamCore(DefaultDarwin): default_role: TeamMemberRole = TeamMemberRole.USER # Data Validation - _slug_validator = validator("slug", allow_reuse=True)(parse_name) + _slug_validator = field_validator("slug")(parse_name) @staticmethod def from_client(client: ClientCore, team_slug: Optional[str] = None) -> TeamCore: diff --git a/darwin/importer/formats/nifti.py b/darwin/importer/formats/nifti.py index cf4e530d6..e871b2532 100644 --- a/darwin/importer/formats/nifti.py +++ b/darwin/importer/formats/nifti.py @@ -15,7 +15,7 @@ import nibabel as nib from scipy.ndimage import zoom except ImportError: - import_fail_string = """ + import_fail_string = r""" You must install darwin-py with pip install darwin-py\[medical] in order to import using nifti format """