Skip to content

Commit

Permalink
build(deps): Update Pydantic to V2, but use V1 API (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Jan 12, 2024
1 parent a91cf6f commit 892b531
Show file tree
Hide file tree
Showing 46 changed files with 429 additions and 371 deletions.
8 changes: 4 additions & 4 deletions hydrolib/core/basemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
)
from weakref import WeakValueDictionary

from pydantic import BaseModel as PydanticBaseModel
from pydantic import validator
from pydantic.error_wrappers import ErrorWrapper, ValidationError
from pydantic.fields import ModelField, PrivateAttr
from pydantic.v1 import BaseModel as PydanticBaseModel
from pydantic.v1 import validator
from pydantic.v1.error_wrappers import ErrorWrapper, ValidationError
from pydantic.v1.fields import ModelField, PrivateAttr

from hydrolib.core.base import DummmyParser, DummySerializer
from hydrolib.core.utils import (
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseSettings
from pydantic.v1 import BaseSettings


class Settings(BaseSettings):
Expand Down
6 changes: 3 additions & 3 deletions hydrolib/core/dflowfm/bc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from pathlib import Path
from typing import Callable, Dict, Iterator, List, Literal, Optional, Set, Union

from pydantic import Extra
from pydantic.class_validators import root_validator, validator
from pydantic.fields import Field
from pydantic.v1 import Extra
from pydantic.v1.class_validators import root_validator, validator
from pydantic.v1.fields import Field

from hydrolib.core.basemodel import BaseModel, ModelSaveSettings
from hydrolib.core.dflowfm.ini.io_models import Property, Section
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/dflowfm/crosssection/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
from typing import Dict, List, Literal, Optional

from pydantic import Field, root_validator
from pydantic.class_validators import validator
from pydantic.v1 import Field, root_validator
from pydantic.v1.class_validators import validator

from hydrolib.core.dflowfm.friction.models import FrictionType
from hydrolib.core.dflowfm.ini.models import INIBasedModel, INIGeneral, INIModel
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/ext/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from typing import Dict, List, Literal, Optional, Union

from pydantic import Field, root_validator, validator
from pydantic.v1 import Field, root_validator, validator

from hydrolib.core.basemodel import (
DiskOnlyFileModel,
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/extold/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Union

from pydantic import Field, root_validator, validator
from pydantic.v1 import Field, root_validator, validator

from hydrolib.core.basemodel import (
BaseModel,
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/dflowfm/friction/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pathlib import Path
from typing import List, Literal, Optional

from pydantic import Field, NonNegativeInt, PositiveInt
from pydantic.class_validators import validator
from pydantic.v1 import Field, NonNegativeInt, PositiveInt
from pydantic.v1.class_validators import validator

from hydrolib.core.basemodel import (
DiskOnlyFileModel,
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/dflowfm/gui/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import logging
from typing import List, Literal, Optional

from pydantic.class_validators import root_validator, validator
from pydantic.fields import Field
from pydantic.v1.class_validators import root_validator, validator
from pydantic.v1.fields import Field

from hydrolib.core.dflowfm.ini.models import INIBasedModel, INIGeneral, INIModel
from hydrolib.core.dflowfm.ini.util import make_list_validator
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/ini/io_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
from xmlrpc.client import Boolean

from pydantic import Field, validator
from pydantic.v1 import Field, validator

from hydrolib.core.basemodel import BaseModel
from hydrolib.core.utils import to_key
Expand Down
6 changes: 3 additions & 3 deletions hydrolib/core/dflowfm/ini/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from math import isnan
from typing import Any, Callable, List, Literal, Optional, Set, Type, Union

from pydantic import Extra, Field, root_validator
from pydantic.class_validators import validator
from pydantic.fields import ModelField
from pydantic.v1 import Extra, Field, root_validator
from pydantic.v1.class_validators import validator
from pydantic.v1.fields import ModelField

from hydrolib.core import __version__ as version
from hydrolib.core.basemodel import (
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/ini/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path
from typing import Callable, Dict, List, Optional, Tuple, Union

from pydantic import validator
from pydantic.v1 import validator

from hydrolib.core.basemodel import BaseModel
from hydrolib.core.dflowfm.ini.io_models import (
Expand Down
6 changes: 3 additions & 3 deletions hydrolib/core/dflowfm/ini/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from operator import eq
from typing import Any, Callable, Dict, List, Optional, Type

from pydantic.class_validators import root_validator, validator
from pydantic.fields import ModelField
from pydantic.main import BaseModel
from pydantic.v1.class_validators import root_validator, validator
from pydantic.v1.fields import ModelField
from pydantic.v1.main import BaseModel

from hydrolib.core.dflowfm.common.models import LocationType
from hydrolib.core.utils import operator_str, str_is_empty_or_none, to_list
Expand Down
6 changes: 3 additions & 3 deletions hydrolib/core/dflowfm/inifield/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from enum import Enum
from typing import Dict, List, Literal, Optional

from pydantic import Field
from pydantic.class_validators import root_validator, validator
from pydantic.types import NonNegativeFloat, PositiveInt
from pydantic.v1 import Field
from pydantic.v1.class_validators import root_validator, validator
from pydantic.v1.types import NonNegativeFloat, PositiveInt

from hydrolib.core.basemodel import DiskOnlyFileModel
from hydrolib.core.dflowfm.common import LocationType
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/mdu/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from typing import Any, Dict, List, Literal, Optional, Union

from pydantic import Field, validator
from pydantic.v1 import Field, validator

from hydrolib.core.basemodel import (
DiskOnlyFileModel,
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/net/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
import numpy.typing as npt
from meshkernel.py_structures import GeometryList
from pydantic import Field
from pydantic.v1 import Field

from hydrolib.core import __version__
from hydrolib.core.basemodel import (
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/dflowfm/obs/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, List, Literal, Optional

from pydantic.class_validators import root_validator
from pydantic.fields import Field
from pydantic.v1.class_validators import root_validator
from pydantic.v1.fields import Field

from hydrolib.core.dflowfm.common.models import LocationType
from hydrolib.core.dflowfm.ini.models import INIBasedModel, INIGeneral, INIModel
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/dflowfm/obscrosssection/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, List, Literal, Optional

from pydantic.class_validators import root_validator
from pydantic.fields import Field
from pydantic.v1.class_validators import root_validator
from pydantic.v1.fields import Field

from hydrolib.core.dflowfm.ini.models import INIBasedModel, INIGeneral, INIModel
from hydrolib.core.dflowfm.ini.util import (
Expand Down
6 changes: 3 additions & 3 deletions hydrolib/core/dflowfm/onedfield/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
from typing import List, Literal, Optional

from pydantic import Field
from pydantic.class_validators import root_validator
from pydantic.types import NonNegativeInt
from pydantic.v1 import Field
from pydantic.v1.class_validators import root_validator
from pydantic.v1.types import NonNegativeInt

from hydrolib.core.dflowfm.ini.models import INIBasedModel, INIGeneral, INIModel
from hydrolib.core.dflowfm.ini.util import (
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/dflowfm/storagenode/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum
from typing import Dict, List, Literal, Optional

from pydantic.class_validators import root_validator, validator
from pydantic.fields import Field
from pydantic.v1.class_validators import root_validator, validator
from pydantic.v1.fields import Field

from hydrolib.core.dflowfm.ini.models import INIBasedModel, INIGeneral, INIModel
from hydrolib.core.dflowfm.ini.util import (
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/dflowfm/structure/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from operator import gt, ne
from typing import Dict, List, Literal, Optional, Set, Union

from pydantic import Field
from pydantic.class_validators import root_validator, validator
from pydantic.v1 import Field
from pydantic.v1.class_validators import root_validator, validator

from hydrolib.core.basemodel import DiskOnlyFileModel
from hydrolib.core.dflowfm.bc.models import ForcingModel
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/tim/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from typing import Callable, Dict, List

from pydantic.class_validators import validator
from pydantic.v1.class_validators import validator

from hydrolib.core.basemodel import BaseModel, ModelSaveSettings, ParsableFileModel

Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/xyn/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from typing import Callable, Dict, List, Optional

from pydantic import validator
from pydantic.v1 import validator

from hydrolib.core.basemodel import (
BaseModel,
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/xyz/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from typing import Callable, Dict, List, Optional

from pydantic import Field
from pydantic.v1 import Field

from hydrolib.core.basemodel import (
BaseModel,
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dimr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path
from typing import Callable, Dict, List, Literal, Optional, Type, Union

from pydantic import Field, validator
from pydantic.v1 import Field, validator

from hydrolib.core import __version__
from hydrolib.core.basemodel import (
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/rr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pathlib import Path
from typing import Any, Callable, Dict, Iterable, Optional

from pydantic import Field, validator
from pydantic.types import FilePath
from pydantic.v1 import Field, validator
from pydantic.v1.types import FilePath

from hydrolib.core.basemodel import (
DiskOnlyFileModel,
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/rr/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Dict, Iterable, Optional

from pydantic.types import FilePath
from pydantic.v1.types import FilePath


def _strip(lines: Iterable[str]) -> Iterable[str]:
Expand Down
4 changes: 2 additions & 2 deletions hydrolib/core/rr/topology/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from pathlib import Path
from typing import Callable, Dict, List, Optional

from pydantic.class_validators import root_validator
from pydantic.fields import Field
from pydantic.v1.class_validators import root_validator
from pydantic.v1.fields import Field

from hydrolib.core.basemodel import (
BaseModel,
Expand Down
Loading

0 comments on commit 892b531

Please sign in to comment.