Skip to content

Commit 7b6db6f

Browse files
authored
Merge pull request #406 from NannyML/fix/py37-pydantic-compatibility
Fix pydantic compatibility with python 3.7
2 parents c87abfe + b14c503 commit 7b6db6f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

nannyml/io/db/entities.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
its results into a specific table.
99
"""
1010

11+
import sys
12+
1113
from datetime import datetime
1214
from typing import List, Optional
1315

@@ -46,7 +48,8 @@ class Run(SQLModel, table=True): # type: ignore[call-arg]
4648
# Ignore clash of `model_id` field name with default protected namespace `model_`
4749
# See: https://github.com/pydantic/pydantic/discussions/7121
4850
# Better solution using `alias` is not possible due to SQLModel issue
49-
model_config = ConfigDict(protected_namespaces=())
51+
if sys.version_info >= (3, 8):
52+
model_config = ConfigDict(protected_namespaces=()) # type: ignore
5053

5154
#: Foreign key in all ``metric`` tables
5255
id: Optional[int] = Field(default=None, primary_key=True)
@@ -70,7 +73,8 @@ class Metric(SQLModel):
7073
# Ignore clash of `model_id` field name with default protected namespace `model_`
7174
# See: https://github.com/pydantic/pydantic/discussions/7121
7275
# Better solution using `alias` is not possible due to SQLModel issue
73-
model_config = ConfigDict(protected_namespaces=())
76+
if sys.version_info >= (3, 8):
77+
model_config = ConfigDict(protected_namespaces=()) # type: ignore
7478

7579
#: The technical identifier for this database row
7680
id: Optional[int] = Field(default=None, primary_key=True)

0 commit comments

Comments
 (0)