From 347ff18f254afa1022e8a2a3808e91fd9c3ab944 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 17 Jun 2024 17:03:28 +0300 Subject: [PATCH] Update typing --- .../server/settings/components/common.py | 8 +++----- .../server/settings/components/csp.py | 14 ++++++-------- .../server/settings/components/logging.py | 3 ++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/{{cookiecutter.project_name}}/server/settings/components/common.py b/{{cookiecutter.project_name}}/server/settings/components/common.py index 15ee7975..27282f6a 100644 --- a/{{cookiecutter.project_name}}/server/settings/components/common.py +++ b/{{cookiecutter.project_name}}/server/settings/components/common.py @@ -8,8 +8,6 @@ https://docs.djangoproject.com/en/4.2/ref/settings/ """ -from typing import Dict, List, Tuple, Union - from django.utils.translation import gettext_lazy as _ from server.settings.components import BASE_DIR, config @@ -21,7 +19,7 @@ # Application definition: -INSTALLED_APPS: Tuple[str, ...] = ( +INSTALLED_APPS: tuple[str, ...] = ( # Your apps go here: 'server.apps.main', @@ -48,7 +46,7 @@ 'health_check.storage', ) -MIDDLEWARE: Tuple[str, ...] = ( +MIDDLEWARE: tuple[str, ...] = ( # Logging: 'server.settings.components.logging.LoggingContextVarsMiddleware', @@ -194,7 +192,7 @@ REFERRER_POLICY = 'same-origin' # https://github.com/adamchainz/django-permissions-policy#setting -PERMISSIONS_POLICY: Dict[str, Union[str, List[str]]] = {} # noqa: WPS234 +PERMISSIONS_POLICY: dict[str, str | list[str]] = {} # noqa: WPS234 # Timeouts diff --git a/{{cookiecutter.project_name}}/server/settings/components/csp.py b/{{cookiecutter.project_name}}/server/settings/components/csp.py index 317e3e65..c2a10a5c 100644 --- a/{{cookiecutter.project_name}}/server/settings/components/csp.py +++ b/{{cookiecutter.project_name}}/server/settings/components/csp.py @@ -8,12 +8,10 @@ Docs: https://github.com/mozilla/django-csp """ -from typing import Tuple - # These values might and will be redefined in `development.py` env: -CSP_SCRIPT_SRC: Tuple[str, ...] = ("'self'",) -CSP_IMG_SRC: Tuple[str, ...] = ("'self'",) -CSP_FONT_SRC: Tuple[str, ...] = ("'self'",) -CSP_STYLE_SRC: Tuple[str, ...] = ("'self'",) -CSP_DEFAULT_SRC: Tuple[str, ...] = ("'none'",) -CSP_CONNECT_SRC: Tuple[str, ...] = () +CSP_SCRIPT_SRC: tuple[str, ...] = ("'self'",) +CSP_IMG_SRC: tuple[str, ...] = ("'self'",) +CSP_FONT_SRC: tuple[str, ...] = ("'self'",) +CSP_STYLE_SRC: tuple[str, ...] = ("'self'",) +CSP_DEFAULT_SRC: tuple[str, ...] = ("'none'",) +CSP_CONNECT_SRC: tuple[str, ...] = () diff --git a/{{cookiecutter.project_name}}/server/settings/components/logging.py b/{{cookiecutter.project_name}}/server/settings/components/logging.py index f04defcc..d2977924 100644 --- a/{{cookiecutter.project_name}}/server/settings/components/logging.py +++ b/{{cookiecutter.project_name}}/server/settings/components/logging.py @@ -5,7 +5,8 @@ # 'Do not log' by Nikita Sobolev (@sobolevn) # https://sobolevn.me/2020/03/do-not-log -from typing import TYPE_CHECKING, Callable, final +from collections.abc import Callable +from typing import TYPE_CHECKING, final import structlog