Skip to content

Commit 9924fde

Browse files
committed
refactor: use Final for application keys to ensure immutability
1 parent b072fcf commit 9924fde

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

services/web/server/src/simcore_service_webserver/application_keys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""web.AppKey definitions for simcore_service_webserver"""
22

3-
from typing import TYPE_CHECKING
3+
from typing import TYPE_CHECKING, Final
44

55
from aiohttp import web
66
from servicelib.aiohttp.application_keys import (
@@ -14,11 +14,11 @@
1414
# Application settings key - defined here to avoid circular imports
1515
from .application_settings import ApplicationSettings
1616

17-
APP_SETTINGS_KEY: web.AppKey[ApplicationSettings] = web.AppKey(
17+
APP_SETTINGS_KEY: Final[web.AppKey[ApplicationSettings]] = web.AppKey(
1818
"APP_SETTINGS_KEY", ApplicationSettings
1919
)
2020
else:
21-
APP_SETTINGS_KEY: web.AppKey = web.AppKey("APP_SETTINGS_KEY", None)
21+
APP_SETTINGS_KEY: Final[web.AppKey] = web.AppKey("APP_SETTINGS_KEY", None)
2222

2323

2424
__all__: tuple[str, ...] = (

services/web/server/src/simcore_service_webserver/director_v2/_director_v2_abc_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from abc import ABC, abstractmethod
2+
from typing import Final
23

34
from aiohttp import web
45
from models_library.projects import CommitID, ProjectID
@@ -40,7 +41,9 @@ async def get_or_create_runnable_projects(
4041
) -> tuple[list[ProjectID], list[CommitID]]: ...
4142

4243

43-
_PROJECT_RUN_POLICY_APPKEY = web.AppKey("PROJECT_RUN_POLICY", AbstractProjectRunPolicy)
44+
_PROJECT_RUN_POLICY_APPKEY: Final = web.AppKey(
45+
"PROJECT_RUN_POLICY", AbstractProjectRunPolicy
46+
)
4447

4548

4649
def get_project_run_policy(app: web.Application) -> AbstractProjectRunPolicy | None:

services/web/server/src/simcore_service_webserver/products/_web_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
_logger = logging.getLogger(__name__)
1414

15-
PRODUCTS_TEMPLATES_DIR_APPKEY = web.AppKey("PRODUCTS_TEMPLATES_DIR", Path)
15+
PRODUCTS_TEMPLATES_DIR_APPKEY: Final = web.AppKey("PRODUCTS_TEMPLATES_DIR", Path)
1616

1717

1818
async def _auto_create_products_groups(app: web.Application) -> None:

services/web/server/src/simcore_service_webserver/scicrunch/service_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import logging
8+
from typing import Final
89

910
from aiohttp import ClientSession, client_exceptions, web
1011
from pydantic import HttpUrl, TypeAdapter, ValidationError
@@ -173,4 +174,4 @@ async def search_resource(self, name_as: str) -> list[ResourceHit]:
173174
return hits.root
174175

175176

176-
_SCICRUNCH_APPKEY: web.AppKey = web.AppKey(SciCrunch.__name__, SciCrunch)
177+
_SCICRUNCH_APPKEY: Final = web.AppKey(SciCrunch.__name__, SciCrunch)

0 commit comments

Comments
 (0)