Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

from pydantic import v1 as pydantic #16331

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions changelog.d/16331.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Import via pydantic.v1 so pydantic can be updated to v2.
193 changes: 146 additions & 47 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ ijson = ">=3.1.4"
matrix-common = "^1.3.0"
# We need packaging.requirements.Requirement, added in 16.1.
packaging = ">=16.1"
# This is the most recent version of Pydantic with available on common distros.
# We are currently incompatible with >=2.0.0: (https://github.com/matrix-org/synapse/issues/15858)
pydantic = "^1.7.4"
pydantic = "^2.3.0"

# This is for building the rust components during "poetry install", which
# currently ignores the `build-system.requires` directive (c.f.
Expand Down
10 changes: 8 additions & 2 deletions scripts-dev/check_pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@
from typing import Any, Callable, Dict, Generator, List, Set, Type, TypeVar

from parameterized import parameterized
from pydantic import BaseModel as PydanticBaseModel, conbytes, confloat, conint, constr
from pydantic.typing import get_args
from pydantic.v1 import (
BaseModel as PydanticBaseModel,
conbytes,
confloat,
conint,
constr,
)
from pydantic.v1.typing import get_args
from typing_extensions import ParamSpec

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion synapse/config/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Any, Dict, Type, TypeVar

import jsonschema
from pydantic import BaseModel, ValidationError, parse_obj_as
from pydantic.v1 import BaseModel, ValidationError, parse_obj_as

from synapse.config._base import ConfigError
from synapse.types import JsonDict, StrSequence
Expand Down
2 changes: 1 addition & 1 deletion synapse/config/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from typing import Any, Dict, List, Optional, Union

import attr
from pydantic import BaseModel, Extra, StrictBool, StrictInt, StrictStr
from pydantic.v1 import BaseModel, Extra, StrictBool, StrictInt, StrictStr

from synapse.config._base import (
Config,
Expand Down
2 changes: 1 addition & 1 deletion synapse/events/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import List, Type, Union, cast

import jsonschema
from pydantic import Field, StrictBool, StrictStr
from pydantic.v1 import Field, StrictBool, StrictStr

from synapse.api.constants import (
MAX_ALIAS_LENGTH,
Expand Down
4 changes: 2 additions & 2 deletions synapse/http/servlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
overload,
)

from pydantic import BaseModel, MissingError, PydanticValueError, ValidationError
from pydantic.error_wrappers import ErrorWrapper
from pydantic.v1 import BaseModel, MissingError, PydanticValueError, ValidationError
from pydantic.v1.error_wrappers import ErrorWrapper
from typing_extensions import Literal

from twisted.web.server import Request
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from typing import TYPE_CHECKING, List, Optional, Tuple
from urllib.parse import urlparse

from pydantic import StrictBool, StrictStr, constr
from pydantic.v1 import StrictBool, StrictStr, constr
from typing_extensions import Literal

from twisted.web.server import Request
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from http import HTTPStatus
from typing import TYPE_CHECKING, List, Optional, Tuple

from pydantic import Extra, StrictStr
from pydantic.v1 import Extra, StrictStr

from synapse.api import errors
from synapse.api.errors import NotFoundError, SynapseError, UnrecognizedRequestError
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import logging
from typing import TYPE_CHECKING, List, Optional, Tuple

from pydantic import StrictStr
from pydantic.v1 import StrictStr
from typing_extensions import Literal

from twisted.web.server import Request
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
from typing import TYPE_CHECKING, Dict, Optional

from pydantic import Extra, StrictInt, StrictStr, constr, validator
from pydantic.v1 import Extra, StrictInt, StrictStr, constr, validator

from synapse.rest.models import RequestBodyModel
from synapse.util.threepids import validate_email
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Extra
from pydantic.v1 import BaseModel, Extra


class RequestBodyModel(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/background_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
)

import attr
from pydantic import BaseModel
from pydantic.v1 import BaseModel

from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.storage.engines import PostgresEngine
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
import unittest as stdlib_unittest

from pydantic import BaseModel, ValidationError
from pydantic.v1 import BaseModel, ValidationError
from typing_extensions import Literal

from synapse.rest.client.models import EmailRequestTokenBody
Expand Down