summary refs log tree commit diff
path: root/synapse/config/_util.py
diff options
context:
space:
mode:
authorMaxwell G <maxwell@gtmx.me>2023-09-25 10:19:08 -0500
committerGitHub <noreply@github.com>2023-09-25 15:19:08 +0000
commit12611bfcddfe87e3bad90ef96a648acc2f1cebf3 (patch)
tree9d67371d56f1904f3098e9bf7668db71a8b631cc /synapse/config/_util.py
parentBump cryptography from 41.0.3 to 41.0.4 (#16362) (diff)
downloadsynapse-12611bfcddfe87e3bad90ef96a648acc2f1cebf3.tar.xz
Add support for pydantic v2 via pydantic.v1 compat module (#16332)
While maintaining support with pydantic v1.
Diffstat (limited to 'synapse/config/_util.py')
-rw-r--r--synapse/config/_util.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/config/_util.py b/synapse/config/_util.py
index acccca413b..746838eee3 100644
--- a/synapse/config/_util.py
+++ b/synapse/config/_util.py
@@ -11,10 +11,16 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from typing import Any, Dict, Type, TypeVar
+from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar
 
 import jsonschema
-from pydantic import BaseModel, ValidationError, parse_obj_as
+
+from synapse._pydantic_compat import HAS_PYDANTIC_V2
+
+if TYPE_CHECKING or HAS_PYDANTIC_V2:
+    from pydantic.v1 import BaseModel, ValidationError, parse_obj_as
+else:
+    from pydantic import BaseModel, ValidationError, parse_obj_as
 
 from synapse.config._base import ConfigError
 from synapse.types import JsonDict, StrSequence