Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
berroar committed Jan 21, 2025
2 parents c84bfee + 0bb1ad7 commit 729a03b
Show file tree
Hide file tree
Showing 27 changed files with 934 additions and 862 deletions.
2 changes: 1 addition & 1 deletion .schemas-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.21.0
v5.22.0
8 changes: 4 additions & 4 deletions app/data_models/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@


class CompletionStatus(StrEnum):
COMPLETED: str = "COMPLETED"
IN_PROGRESS: str = "IN_PROGRESS"
NOT_STARTED: str = "NOT_STARTED"
INDIVIDUAL_RESPONSE_REQUESTED: str = "INDIVIDUAL_RESPONSE_REQUESTED"
COMPLETED = "COMPLETED"
IN_PROGRESS = "IN_PROGRESS"
NOT_STARTED = "NOT_STARTED"
INDIVIDUAL_RESPONSE_REQUESTED = "INDIVIDUAL_RESPONSE_REQUESTED"


class ProgressDict(TypedDict, total=False):
Expand Down
4 changes: 2 additions & 2 deletions app/forms/duration_form.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Callable, Mapping, Type
from typing import Callable, Mapping

from wtforms import Form

Expand Down Expand Up @@ -52,7 +52,7 @@ def data(self) -> dict[str, str | None] | None:

def get_duration_form(
answer: Mapping, error_messages: ErrorMessageType
) -> Type[DurationForm]:
) -> type[DurationForm]:
class CustomDurationForm(DurationForm):
mandatory = answer["mandatory"]
units = answer["units"]
Expand Down
5 changes: 3 additions & 2 deletions app/forms/field_handlers/number_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import cached_property
from typing import Any, Type

from typing import Any

from wtforms import DecimalField, IntegerField
from wtforms.fields.core import UnboundField
Expand Down Expand Up @@ -58,7 +59,7 @@ def max_decimals(self) -> int:
@property
def _field_type(
self,
) -> Type[DecimalFieldWithSeparator | IntegerFieldWithSeparator]:
) -> type[DecimalFieldWithSeparator | IntegerFieldWithSeparator]:
return (
DecimalFieldWithSeparator
if self.max_decimals > 0
Expand Down
4 changes: 2 additions & 2 deletions app/forms/fields/date_field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from functools import cached_property
from typing import Any, Callable, Sequence, Type
from typing import Any, Callable, Sequence

from werkzeug.datastructures import MultiDict
from wtforms import Form, FormField, StringField
Expand All @@ -11,7 +11,7 @@
logger = logging.getLogger(__name__)


def get_form_class(validators: Sequence[DateValidatorType]) -> Type[Form]:
def get_form_class(validators: Sequence[DateValidatorType]) -> type[Form]:
class DateForm(Form):
# Validation is only ever added to the 1 field that shows in all 3 variants
# This is to prevent an error message for each input box
Expand Down
4 changes: 2 additions & 2 deletions app/forms/fields/month_year_date_field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from functools import cached_property
from typing import Any, Callable, Sequence, Type
from typing import Any, Callable, Sequence

from werkzeug.datastructures import MultiDict
from wtforms import Form, FormField, StringField
Expand All @@ -11,7 +11,7 @@
logger = logging.getLogger(__name__)


def get_form_class(validators: Sequence[DateValidatorType]) -> Type[Form]:
def get_form_class(validators: Sequence[DateValidatorType]) -> type[Form]:
class YearMonthDateForm(Form):
year = StringField(validators=validators)
month = StringField()
Expand Down
4 changes: 2 additions & 2 deletions app/forms/fields/year_date_field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from functools import cached_property
from typing import Any, Callable, Sequence, Type
from typing import Any, Callable, Sequence

from werkzeug.datastructures import MultiDict
from wtforms import Form, FormField, StringField
Expand All @@ -11,7 +11,7 @@
logger = logging.getLogger(__name__)


def get_form_class(validators: Sequence[DateValidatorType]) -> Type[Form]:
def get_form_class(validators: Sequence[DateValidatorType]) -> type[Form]:
class YearDateForm(Form):
year = StringField(validators=validators)

Expand Down
5 changes: 3 additions & 2 deletions app/forms/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import re
from datetime import datetime, timezone
from decimal import Decimal, InvalidOperation
from typing import TYPE_CHECKING, Iterable, List, Mapping, Sequence
from typing import TYPE_CHECKING, Iterable, Mapping, Sequence


import flask_babel
from babel import numbers
Expand Down Expand Up @@ -415,7 +416,7 @@ def __init__(self, messages: OptionalMessage = None, currency: str | None = None
def __call__(
self,
form: QuestionnaireForm,
conditions: List[str],
conditions: list[str],
total: Decimal | int,
target_total: Decimal | float | int,
decimal_limit: int | None = None,
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from app.helpers.url_safe_serializer import url_safe_serializer

__all__ = [
"get_address_lookup_api_auth_token",
"get_span_and_trace",
"url_safe_serializer",
"get_address_lookup_api_auth_token",
]
4 changes: 2 additions & 2 deletions app/helpers/template_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import cached_property, lru_cache
from typing import Any, Type
from typing import Any

from flask import current_app
from flask import render_template as flask_render_template
Expand Down Expand Up @@ -171,7 +171,7 @@ def _footer_warning(self) -> str | None:
def survey_config_mapping(
*, theme: SurveyType, language: str, base_url: str, schema: QuestionnaireSchema
) -> SurveyConfig:
survey_type_to_config: dict[SurveyType, Type[SurveyConfig]] = {
survey_type_to_config: dict[SurveyType, type[SurveyConfig]] = {
SurveyType.DEFAULT: BusinessSurveyConfig,
SurveyType.BUSINESS: BusinessSurveyConfig,
SurveyType.HEALTH: SocialSurveyConfig,
Expand Down
2 changes: 1 addition & 1 deletion app/publisher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from app.publisher.publisher import LogPublisher, PubSubPublisher

__all__ = ["PubSubPublisher", "LogPublisher"]
__all__ = ["LogPublisher", "PubSubPublisher"]
2 changes: 1 addition & 1 deletion app/questionnaire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
QuestionSchemaType,
)

__all__ = ["QuestionnaireSchema", "Location", "QuestionSchemaType"]
__all__ = ["Location", "QuestionSchemaType", "QuestionnaireSchema"]
4 changes: 1 addition & 3 deletions app/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from copy import deepcopy
from typing import Dict
from uuid import uuid4

import boto3
Expand Down Expand Up @@ -256,7 +255,7 @@ def setup_jinja_env(application):
application.jinja_env.add_extension("jinja2.ext.do")


def _add_cdn_url_to_csp_policy(cdn_url) -> Dict:
def _add_cdn_url_to_csp_policy(cdn_url) -> dict:
csp_policy = deepcopy(CSP_POLICY)
for directive in csp_policy:
if directive not in ["frame-src", "object-src", "base-uri"]:
Expand Down Expand Up @@ -285,7 +284,6 @@ def setup_secure_headers(application):
strict_transport_security=True,
strict_transport_security_max_age=31536000,
frame_options="DENY",
x_xss_protection=True,
)


Expand Down
4 changes: 1 addition & 3 deletions app/storage/datastore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Type

from google.api_core.retry import Retry
from google.cloud import datastore
from google.cloud.datastore import Entity
Expand Down Expand Up @@ -36,7 +34,7 @@ def put(self, model: ModelTypes, overwrite: bool = True) -> bool:
return True

@Retry()
def get(self, model_type: Type[ModelTypes], key_value: str) -> ModelTypes | None:
def get(self, model_type: type[ModelTypes], key_value: str) -> ModelTypes | None:
storage_model = StorageModel(model_type=model_type)
key = self.client.key(storage_model.table_name, key_value)

Expand Down
4 changes: 1 addition & 3 deletions app/storage/dynamodb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Type

import boto3
from botocore.exceptions import ClientError

Expand Down Expand Up @@ -33,7 +31,7 @@ def put(self, model: ModelTypes, overwrite: bool = True) -> bool:

raise # pragma: no cover

def get(self, model_type: Type[ModelTypes], key_value: str) -> ModelTypes | None:
def get(self, model_type: type[ModelTypes], key_value: str) -> ModelTypes | None:
storage_model = StorageModel(model_type=model_type)
table = self.client.Table(storage_model.table_name)
key = {storage_model.key_field: key_value}
Expand Down
3 changes: 1 addition & 2 deletions app/storage/redis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime, timezone
from typing import Type

import redis
from redis.exceptions import ConnectionError as RedisConnectionError
Expand Down Expand Up @@ -56,7 +55,7 @@ def put(self, model: ModelTypes, overwrite: bool = True) -> bool:

return True

def get(self, model_type: Type[ModelTypes], key_value: str) -> ModelTypes | None:
def get(self, model_type: type[ModelTypes], key_value: str) -> ModelTypes | None:
storage_model = StorageModel(model_type=model_type)
try:
item = self.client.get(key_value)
Expand Down
10 changes: 5 additions & 5 deletions app/storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import ABC, abstractmethod
from functools import cached_property
from typing import Any, Type, TypedDict
from typing import Any, TypedDict

from flask import current_app
from google.cloud import datastore
Expand All @@ -23,13 +23,13 @@
class TableConfig(TypedDict, total=False):
key_field: str
table_name_key: str
schema: Type[ModelSchemaTypes]
schema: type[ModelSchemaTypes]
expiry_field: str
index_fields: list[str]


class StorageModel:
TABLE_CONFIG_BY_TYPE: dict[Type[ModelTypes], TableConfig] = {
TABLE_CONFIG_BY_TYPE: dict[type[ModelTypes], TableConfig] = {
app_models.QuestionnaireState: {
"key_field": "user_id",
"table_name_key": "EQ_QUESTIONNAIRE_STATE_TABLE_NAME",
Expand All @@ -51,7 +51,7 @@ class StorageModel:
},
}

def __init__(self, model_type: Type[ModelTypes]) -> None:
def __init__(self, model_type: type[ModelTypes]) -> None:
self._model_type = model_type

if self._model_type not in self.TABLE_CONFIG_BY_TYPE:
Expand Down Expand Up @@ -95,7 +95,7 @@ def put(self, model: ModelTypes, overwrite: bool = True) -> bool:
pass # pragma: no cover

@abstractmethod
def get(self, model_type: Type[ModelTypes], key_value: str) -> ModelTypes | None:
def get(self, model_type: type[ModelTypes], key_value: str) -> ModelTypes | None:
pass # pragma: no cover

@abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions app/submitter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
)

__all__ = [
"GCSFeedbackSubmitter",
"GCSSubmitter",
"LogFeedbackSubmitter",
"LogSubmitter",
"RabbitMQSubmitter",
"GCSFeedbackSubmitter",
"LogFeedbackSubmitter",
]
14 changes: 7 additions & 7 deletions app/survey_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
from app.survey_config.survey_config import SurveyConfig

__all__ = [
"ONSNHSSocialSurveyConfig",
"SocialSurveyConfig",
"UKHSAONSSocialSurveyConfig",
"SurveyConfig",
"BusinessSurveyConfig",
"NIBusinessSurveyConfig",
"DBTBusinessSurveyConfig",
"DBTNIBusinessSurveyConfig",
"DBTDSITBusinessSurveyConfig",
"DBTDSITNIBusinessSurveyConfig",
"ORRBusinessSurveyConfig",
"DBTNIBusinessSurveyConfig",
"DESNZBusinessSurveyConfig",
"DESNZNIBusinessSurveyConfig",
"Link",
"NIBusinessSurveyConfig",
"ONSNHSSocialSurveyConfig",
"ORRBusinessSurveyConfig",
"SocialSurveyConfig",
"SurveyConfig",
"UKHSAONSSocialSurveyConfig",
]
4 changes: 2 additions & 2 deletions app/views/contexts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

__all__ = [
"CalculatedSummaryContext",
"GrandCalculatedSummaryContext",
"Context",
"SubmitQuestionnaireContext",
"GrandCalculatedSummaryContext",
"HubContext",
"ListContext",
"SectionSummaryContext",
"SubmitQuestionnaireContext",
]
4 changes: 2 additions & 2 deletions app/views/contexts/calculated_summary_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Iterable, Mapping, Tuple
from typing import Callable, Iterable, Mapping

from werkzeug.datastructures import ImmutableDict

Expand Down Expand Up @@ -246,7 +246,7 @@ def _get_formatted_total(

return self._format_total(answer_format=answer_format, total=calculated_total)

def _get_answer_format(self, groups: Iterable[Mapping]) -> Tuple[dict, list]:
def _get_answer_format(self, groups: Iterable[Mapping]) -> tuple[dict, list]:
values_to_calculate: list = []
answer_format: dict = {"type": None}
decimal_limits: list[int] = []
Expand Down
4 changes: 2 additions & 2 deletions app/views/contexts/summary/group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, Mapping, Type
from typing import Iterable, Mapping

from werkzeug.datastructures import ImmutableDict

Expand Down Expand Up @@ -86,7 +86,7 @@ def _build_blocks_and_links(
if parent_list_collector_block_id not in routing_path_block_ids:
continue

list_collector_block_class: Type[
list_collector_block_class: type[
ListCollectorBlock | ListCollectorContentBlock
] = (
ListCollectorBlock
Expand Down
4 changes: 1 addition & 3 deletions app/views/handlers/calculation_summary.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from typing import Type

from app.views.contexts import GrandCalculatedSummaryContext
from app.views.contexts.calculated_summary_context import CalculatedSummaryContext
from app.views.handlers.content import Content


class _SummaryWithCalculation(Content):
summary_class: Type[CalculatedSummaryContext] | Type[GrandCalculatedSummaryContext]
summary_class: type[CalculatedSummaryContext] | type[GrandCalculatedSummaryContext]

def get_context(self) -> dict[str, dict]:
summary_context = self.summary_class(
Expand Down
Loading

0 comments on commit 729a03b

Please sign in to comment.