diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fcfcef7d..bde7db27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-ast - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black language_version: python3 diff --git a/conda_lock/models/__init__.py b/conda_lock/models/__init__.py index 5d96b5ad..2b74db89 100644 --- a/conda_lock/models/__init__.py +++ b/conda_lock/models/__init__.py @@ -1,11 +1,5 @@ from pydantic import BaseModel -class StrictModel(BaseModel): - """A Pydantic BaseModel forbidding extra fields and encoding frozensets as lists""" - - class Config: - extra = "forbid" - json_encoders = { - frozenset: list, - } +class StrictModel(BaseModel, extra="forbid"): + """A Pydantic BaseModel forbidding extra fields""" diff --git a/conda_lock/models/channel.py b/conda_lock/models/channel.py index 5645c818..5cb3b614 100644 --- a/conda_lock/models/channel.py +++ b/conda_lock/models/channel.py @@ -42,7 +42,7 @@ from typing import FrozenSet, List, Optional, cast from urllib.parse import unquote, urlparse, urlunparse -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field if typing.TYPE_CHECKING: @@ -90,15 +90,14 @@ def __repr_args__(self: BaseModel) -> "ReprArgs": class Channel(ZeroValRepr, BaseModel): + model_config = ConfigDict(frozen=True) # type: ignore + url: str used_env_vars: FrozenSet[str] = Field(default=frozenset()) def __lt__(self, other: "Channel") -> bool: return tuple(self.dict().values()) < tuple(other.dict().values()) - class Config: - frozen = True - @classmethod def from_string(cls, value: str) -> "Channel": if "://" in value: diff --git a/pyproject.toml b/pyproject.toml index a7c71260..e02aa54d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ "ensureconda >=1.3", "gitpython >=3.1.30", "jinja2", - "pydantic >=1.8.1", + "pydantic >=1.10", "pyyaml >= 5.1", "ruamel.yaml", 'tomli; python_version<"3.11"',