From 4125d6dbcc70a85db54ca2fe2a7fd7fd02b6c9f4 Mon Sep 17 00:00:00 2001 From: Tobias Messner Date: Fri, 29 Nov 2024 12:15:00 +0100 Subject: [PATCH] fix: Convert invariant List to Sequence This makes a new version of mypy happy. --- .../settings/configuration/models.py | 61 ++++++++++--------- backend/capellacollab/tools/models.py | 6 +- .../guacamole-connection-method-input.ts | 9 +-- .../guacamole-connection-method-output.ts | 9 +-- .../model/http-connection-method-input.ts | 9 +-- .../model/http-connection-method-output.ts | 9 +-- ...-session-connection-input-methods-inner.ts | 10 +-- ...session-connection-output-methods-inner.ts | 10 +-- 8 files changed, 39 insertions(+), 84 deletions(-) diff --git a/backend/capellacollab/settings/configuration/models.py b/backend/capellacollab/settings/configuration/models.py index 5dbb91d2c9..c1cbc1d03f 100644 --- a/backend/capellacollab/settings/configuration/models.py +++ b/backend/capellacollab/settings/configuration/models.py @@ -5,6 +5,7 @@ import enum import typing as t import zoneinfo +from collections import abc as collections_abc import pydantic from croniter import croniter @@ -69,40 +70,40 @@ class CustomNavbarLink(NavbarLink): class NavbarConfiguration(core_pydantic.BaseModelStrict): - external_links: list[BuiltInNavbarLink | CustomNavbarLink] = ( - pydantic.Field( - default=( + external_links: collections_abc.Sequence[ + BuiltInNavbarLink | CustomNavbarLink + ] = pydantic.Field( + default=( + [ + BuiltInNavbarLink( + name="Grafana", + service=BuiltInLinkItem.GRAFANA, + role=users_models.Role.ADMIN, + ), + BuiltInNavbarLink( + name="Prometheus", + service=BuiltInLinkItem.PROMETHEUS, + role=users_models.Role.ADMIN, + ), + BuiltInNavbarLink( + name="Documentation", + service=BuiltInLinkItem.DOCUMENTATION, + role=users_models.Role.USER, + ), + ] + + ( [ BuiltInNavbarLink( - name="Grafana", - service=BuiltInLinkItem.GRAFANA, - role=users_models.Role.ADMIN, - ), - BuiltInNavbarLink( - name="Prometheus", - service=BuiltInLinkItem.PROMETHEUS, - role=users_models.Role.ADMIN, - ), - BuiltInNavbarLink( - name="Documentation", - service=BuiltInLinkItem.DOCUMENTATION, + name="SMTP Mock", + service=BuiltInLinkItem.SMTP_MOCK, role=users_models.Role.USER, - ), + ) ] - + ( - [ - BuiltInNavbarLink( - name="SMTP Mock", - service=BuiltInLinkItem.SMTP_MOCK, - role=users_models.Role.USER, - ) - ] - if core.DEVELOPMENT_MODE - else [] - ) - ), - description="Links to display in the navigation bar.", - ) + if core.DEVELOPMENT_MODE + else [] + ) + ), + description="Links to display in the navigation bar.", ) diff --git a/backend/capellacollab/tools/models.py b/backend/capellacollab/tools/models.py index b45a12a579..a9dc9fb73b 100644 --- a/backend/capellacollab/tools/models.py +++ b/backend/capellacollab/tools/models.py @@ -64,15 +64,13 @@ class ToolSessionEnvironment(core_pydantic.BaseModel): ), ) value: str = pydantic.Field( - default={"RMT_PASSWORD": "{CAPELLACOLLAB_SESSION_TOKEN}"}, + default="{CAPELLACOLLAB_SESSION_TOKEN}", description=( "Environment variables, which are mounted into session containers. " "You can use f-strings to reference other environment variables in the value. " ), examples=[ - { - "MY_TOOL_USERNAME_WITH_PREFIX": "test_{CAPELLACOLLAB_SESSION_REQUESTER_USERNAME}", - } + "test_{CAPELLACOLLAB_SESSION_REQUESTER_USERNAME}", ], ) diff --git a/frontend/src/app/openapi/model/guacamole-connection-method-input.ts b/frontend/src/app/openapi/model/guacamole-connection-method-input.ts index 2149f07d7c..aa784f6a10 100644 --- a/frontend/src/app/openapi/model/guacamole-connection-method-input.ts +++ b/frontend/src/app/openapi/model/guacamole-connection-method-input.ts @@ -16,7 +16,7 @@ import { RDPPortsInput } from './rdp-ports-input'; export interface GuacamoleConnectionMethodInput { id?: string; - type?: GuacamoleConnectionMethodInput.TypeEnum; + type?: string; name?: string; description?: string; ports?: RDPPortsInput; @@ -26,11 +26,4 @@ export interface GuacamoleConnectionMethodInput { environment?: { [key: string]: EnvironmentValue; }; sharing?: ToolSessionSharingConfigurationInput; } -export namespace GuacamoleConnectionMethodInput { - export type TypeEnum = 'guacamole'; - export const TypeEnum = { - Guacamole: 'guacamole' as TypeEnum - }; -} - diff --git a/frontend/src/app/openapi/model/guacamole-connection-method-output.ts b/frontend/src/app/openapi/model/guacamole-connection-method-output.ts index 77faae7408..893b1a3bf5 100644 --- a/frontend/src/app/openapi/model/guacamole-connection-method-output.ts +++ b/frontend/src/app/openapi/model/guacamole-connection-method-output.ts @@ -16,7 +16,7 @@ import { EnvironmentValue1 } from './environment-value1'; export interface GuacamoleConnectionMethodOutput { id: string; - type: GuacamoleConnectionMethodOutput.TypeEnum; + type: string; name: string; description: string; ports: RDPPortsOutput; @@ -26,11 +26,4 @@ export interface GuacamoleConnectionMethodOutput { environment: { [key: string]: EnvironmentValue1; }; sharing: ToolSessionSharingConfigurationOutput; } -export namespace GuacamoleConnectionMethodOutput { - export type TypeEnum = 'guacamole'; - export const TypeEnum = { - Guacamole: 'guacamole' as TypeEnum - }; -} - diff --git a/frontend/src/app/openapi/model/http-connection-method-input.ts b/frontend/src/app/openapi/model/http-connection-method-input.ts index 3288c623b7..d2f8ea9f79 100644 --- a/frontend/src/app/openapi/model/http-connection-method-input.ts +++ b/frontend/src/app/openapi/model/http-connection-method-input.ts @@ -16,7 +16,7 @@ import { HTTPPortsInput } from './http-ports-input'; export interface HTTPConnectionMethodInput { id?: string; - type?: HTTPConnectionMethodInput.TypeEnum; + type?: string; name?: string; description?: string; ports?: HTTPPortsInput; @@ -31,11 +31,4 @@ export interface HTTPConnectionMethodInput { */ cookies?: { [key: string]: string; }; } -export namespace HTTPConnectionMethodInput { - export type TypeEnum = 'http'; - export const TypeEnum = { - Http: 'http' as TypeEnum - }; -} - diff --git a/frontend/src/app/openapi/model/http-connection-method-output.ts b/frontend/src/app/openapi/model/http-connection-method-output.ts index 2264c081a0..075bdd218d 100644 --- a/frontend/src/app/openapi/model/http-connection-method-output.ts +++ b/frontend/src/app/openapi/model/http-connection-method-output.ts @@ -16,7 +16,7 @@ import { EnvironmentValue1 } from './environment-value1'; export interface HTTPConnectionMethodOutput { id: string; - type: HTTPConnectionMethodOutput.TypeEnum; + type: string; name: string; description: string; ports: HTTPPortsOutput; @@ -31,11 +31,4 @@ export interface HTTPConnectionMethodOutput { */ cookies: { [key: string]: string; }; } -export namespace HTTPConnectionMethodOutput { - export type TypeEnum = 'http'; - export const TypeEnum = { - Http: 'http' as TypeEnum - }; -} - diff --git a/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts b/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts index 2cd98e1f51..24f6f199cb 100644 --- a/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts +++ b/frontend/src/app/openapi/model/tool-session-connection-input-methods-inner.ts @@ -18,7 +18,7 @@ import { HTTPPortsInput } from './http-ports-input'; export interface ToolSessionConnectionInputMethodsInner { id?: string; - type?: ToolSessionConnectionInputMethodsInner.TypeEnum; + type?: string; name?: string; description?: string; ports?: HTTPPortsInput; @@ -33,12 +33,4 @@ export interface ToolSessionConnectionInputMethodsInner { */ cookies?: { [key: string]: string; }; } -export namespace ToolSessionConnectionInputMethodsInner { - export type TypeEnum = 'guacamole' | 'http'; - export const TypeEnum = { - Guacamole: 'guacamole' as TypeEnum, - Http: 'http' as TypeEnum - }; -} - diff --git a/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts b/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts index aee12f9fa7..e31d5889b7 100644 --- a/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts +++ b/frontend/src/app/openapi/model/tool-session-connection-output-methods-inner.ts @@ -18,7 +18,7 @@ import { EnvironmentValue1 } from './environment-value1'; export interface ToolSessionConnectionOutputMethodsInner { id: string; - type: ToolSessionConnectionOutputMethodsInner.TypeEnum; + type: string; name: string; description: string; ports: HTTPPortsOutput; @@ -33,12 +33,4 @@ export interface ToolSessionConnectionOutputMethodsInner { */ cookies: { [key: string]: string; }; } -export namespace ToolSessionConnectionOutputMethodsInner { - export type TypeEnum = 'guacamole' | 'http'; - export const TypeEnum = { - Guacamole: 'guacamole' as TypeEnum, - Http: 'http' as TypeEnum - }; -} -