From bd1f034bb00b177da0d0b9f4f48c33c47acb2918 Mon Sep 17 00:00:00 2001 From: Michael Van de Steene Date: Wed, 10 Jul 2024 11:25:08 +0200 Subject: [PATCH 1/2] Skip sqlmodel config for py37 --- nannyml/io/db/entities.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nannyml/io/db/entities.py b/nannyml/io/db/entities.py index 7800beac..0959749f 100644 --- a/nannyml/io/db/entities.py +++ b/nannyml/io/db/entities.py @@ -8,6 +8,8 @@ its results into a specific table. """ +import sys + from datetime import datetime from typing import List, Optional @@ -46,7 +48,8 @@ class Run(SQLModel, table=True): # type: ignore[call-arg] # Ignore clash of `model_id` field name with default protected namespace `model_` # See: https://github.com/pydantic/pydantic/discussions/7121 # Better solution using `alias` is not possible due to SQLModel issue - model_config = ConfigDict(protected_namespaces=()) + if sys.version_info >= (3, 8): + model_config = ConfigDict(protected_namespaces=()) #: Foreign key in all ``metric`` tables id: Optional[int] = Field(default=None, primary_key=True) @@ -70,7 +73,8 @@ class Metric(SQLModel): # Ignore clash of `model_id` field name with default protected namespace `model_` # See: https://github.com/pydantic/pydantic/discussions/7121 # Better solution using `alias` is not possible due to SQLModel issue - model_config = ConfigDict(protected_namespaces=()) + if sys.version_info >= (3, 8): + model_config = ConfigDict(protected_namespaces=()) #: The technical identifier for this database row id: Optional[int] = Field(default=None, primary_key=True) From b14c5035214c0d1b12de2d4ec162c46ff5763134 Mon Sep 17 00:00:00 2001 From: Michael Van de Steene Date: Wed, 10 Jul 2024 12:01:36 +0200 Subject: [PATCH 2/2] Suppress mypy error for sqlmodel pydantic config --- nannyml/io/db/entities.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nannyml/io/db/entities.py b/nannyml/io/db/entities.py index 0959749f..1d1b5d73 100644 --- a/nannyml/io/db/entities.py +++ b/nannyml/io/db/entities.py @@ -49,7 +49,7 @@ class Run(SQLModel, table=True): # type: ignore[call-arg] # See: https://github.com/pydantic/pydantic/discussions/7121 # Better solution using `alias` is not possible due to SQLModel issue if sys.version_info >= (3, 8): - model_config = ConfigDict(protected_namespaces=()) + model_config = ConfigDict(protected_namespaces=()) # type: ignore #: Foreign key in all ``metric`` tables id: Optional[int] = Field(default=None, primary_key=True) @@ -74,7 +74,7 @@ class Metric(SQLModel): # See: https://github.com/pydantic/pydantic/discussions/7121 # Better solution using `alias` is not possible due to SQLModel issue if sys.version_info >= (3, 8): - model_config = ConfigDict(protected_namespaces=()) + model_config = ConfigDict(protected_namespaces=()) # type: ignore #: The technical identifier for this database row id: Optional[int] = Field(default=None, primary_key=True)