Skip to content

Commit c6b8532

Browse files
committed
do a way with "Optional"
1 parent 4c5a0f7 commit c6b8532

3 files changed

Lines changed: 87 additions & 94 deletions

File tree

cabotage/server/models/auth.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import annotations
2+
13
import datetime
24
import uuid
3-
from typing import TYPE_CHECKING, Optional
5+
from typing import TYPE_CHECKING
46

57
from flask_security.models.fsqla_v3 import (
68
FsModels,
@@ -50,8 +52,8 @@ class Role(Model, FsRoleMixin):
5052
server_default=text("gen_random_uuid()"),
5153
primary_key=True,
5254
)
53-
name: Mapped[Optional[str]] = mapped_column(String(80), unique=True)
54-
description: Mapped[Optional[str]] = mapped_column(String(255))
55+
name: Mapped[str | None] = mapped_column(String(80), unique=True)
56+
description: Mapped[str | None] = mapped_column(String(255))
5557

5658
def __str__(self):
5759
return self.name
@@ -117,7 +119,7 @@ class GitHubIdentity(Model):
117119
)
118120
github_id: Mapped[int] = mapped_column(BigInteger, unique=True)
119121
github_username: Mapped[str] = mapped_column(String(255))
120-
github_access_token: Mapped[Optional[str]] = mapped_column(String(255))
122+
github_access_token: Mapped[str | None] = mapped_column(String(255))
121123
created_at: Mapped[datetime.datetime] = mapped_column(
122124
DateTime, default=datetime.datetime.now
123125
)
@@ -156,11 +158,11 @@ class TailscaleIntegration(Model):
156158
index=True,
157159
)
158160
client_id: Mapped[str] = mapped_column(String(255))
159-
client_secret_vault_path: Mapped[Optional[str]] = mapped_column(String(512))
160-
tailnet: Mapped[Optional[str]] = mapped_column(String(255))
161-
default_tags: Mapped[Optional[str]] = mapped_column(String(512))
161+
client_secret_vault_path: Mapped[str | None] = mapped_column(String(512))
162+
tailnet: Mapped[str | None] = mapped_column(String(255))
163+
default_tags: Mapped[str | None] = mapped_column(String(512))
162164
operator_state: Mapped[str] = mapped_column(String(32), default="pending")
163-
operator_version: Mapped[Optional[str]] = mapped_column(String(64))
165+
operator_version: Mapped[str | None] = mapped_column(String(64))
164166
created_at: Mapped[datetime.datetime] = mapped_column(
165167
DateTime, default=datetime.datetime.now
166168
)
@@ -197,9 +199,7 @@ def __init__(self, *args, **kwargs):
197199
name: Mapped[str] = mapped_column(Text())
198200
slug: Mapped[str] = mapped_column(postgresql.CITEXT(), unique=True)
199201
k8s_identifier: Mapped[str] = mapped_column(String(64), unique=True)
200-
deleted_at: Mapped[Optional[datetime.datetime]] = mapped_column(
201-
DateTime, index=True
202-
)
202+
deleted_at: Mapped[datetime.datetime | None] = mapped_column(DateTime, index=True)
203203

204204
members: Mapped[list["OrganizationMember"]] = relationship(
205205
back_populates="organization"

0 commit comments

Comments
 (0)