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

Commit

Permalink
_pydantic_compat: fix HAS_PYDANTIC_V2 version check
Browse files Browse the repository at this point in the history
Old pydantic v1 versions do not define `__version__`.
  • Loading branch information
gotmax23 committed Sep 19, 2023
1 parent a4289cb commit 1dd3295
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion synapse/_pydantic_compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from packaging.version import Version
from pydantic import __version__ as pydantic_version

try:
from pydantic import __version__ as pydantic_version
except ImportError:
import importlib.metadata

pydantic_version = importlib.metadata.version("pydantic")

HAS_PYDANTIC_V2: bool = Version(pydantic_version).major == 2

Expand Down

0 comments on commit 1dd3295

Please sign in to comment.