Skip to content

Commit f597419

Browse files
committed
test type subclass
1 parent 52e41bc commit f597419

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/opengeodeweb_back/data.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
from typing import List, Optional, TYPE_CHECKING
12
from sqlalchemy import String, JSON
3+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
24
from .database import database
35
import uuid
4-
from typing import Type
56

7+
class Base(DeclarativeBase):
8+
pass
69

7-
class Data(database.Model):
10+
if TYPE_CHECKING:
11+
from sqlalchemy.orm import DeclarativeBase
12+
13+
class Data(Base):
814
__tablename__ = "datas"
915

10-
id = database.Column(
16+
id: Mapped[str] = mapped_column(
1117
String, primary_key=True, default=lambda: str(uuid.uuid4()).replace("-", "")
1218
)
1319
name = database.Column(String, nullable=False)
@@ -24,7 +30,7 @@ def create(
2430
geode_object: str,
2531
input_file: str,
2632
additional_files: list[str]
27-
) -> Type["Data"]:
33+
) -> "Data":
2834
if input_file is None:
2935
input_file = []
3036
if additional_files is None:
@@ -37,7 +43,7 @@ def create(
3743
additional_files=additional_files,
3844
native_file_name="",
3945
viewable_file_name="",
40-
light_viewable="",
46+
light_viewable=None,
4147
)
4248

4349
database.session.add(data_entry)

0 commit comments

Comments
 (0)