diff --git a/app/support/common/logger.py b/app/support/common/logger.py index e3bd07c..7e3eaba 100644 --- a/app/support/common/logger.py +++ b/app/support/common/logger.py @@ -1,6 +1,6 @@ import logging import os -from typing import List, Union +from typing import List from .misc import ensure_directories_present @@ -97,7 +97,7 @@ def _get_file_handler( def _get_handlers(create_console_stream_handler: bool = True, create_console_file_handler: bool = True, create_debug_file_handler: bool = True - ) -> List[Union[None, logging.Handler]]: + ) -> List[None | logging.Handler]: console_stream_handler, console_file_handler, debug_file_handler = None, None, None if create_console_stream_handler or create_console_file_handler: console_output_formatter = _get_console_output_formatter() @@ -126,11 +126,7 @@ def _get_handlers(create_console_stream_handler: bool = True, def _add_handlers( - handlers: Union[ - None, - List[logging.FileHandler], - List[logging.StreamHandler] - ], + handlers: None | List[logging.FileHandler] | List[logging.StreamHandler], logger: logging.Logger ): for handler in handlers: diff --git a/app/support/data_access_layer/records/abstract_record.py b/app/support/data_access_layer/records/abstract_record.py index 76a6cc9..cccb5e8 100644 --- a/app/support/data_access_layer/records/abstract_record.py +++ b/app/support/data_access_layer/records/abstract_record.py @@ -1,4 +1,4 @@ -from typing import Dict, Union +from typing import Dict from pydantic import ValidationError, BaseModel @@ -33,7 +33,7 @@ def validate_record(self, record: Dict) -> bool: logger.warning(str(e)) return False - def coerce_record_to_valid_state(self, record: Dict) -> Union[None, Dict]: + def coerce_record_to_valid_state(self, record: Dict) -> None | Dict: """Returns None if record cannot be coerced into valid state, else returns newly valid record""" logger.info(f"Received request to coerce record: {record}") diff --git a/app/support/data_access_layer/records/appointment_record.py b/app/support/data_access_layer/records/appointment_record.py index ad13fcc..80a50fc 100644 --- a/app/support/data_access_layer/records/appointment_record.py +++ b/app/support/data_access_layer/records/appointment_record.py @@ -1,5 +1,5 @@ from datetime import datetime, timezone -from typing import Dict, Union +from typing import Dict from decimal import Decimal from app.support.data_access_layer.records.abstract_record import AbstractRecordFactory @@ -21,7 +21,7 @@ def produce_record( pet_name: str, appointment_time: datetime, description: str - ) -> Dict[str, Union[str, Decimal]]: + ) -> Dict[str, str | Decimal]: sort_key = f"{RecordType.APPOINTMENT.value}#{utc_timestamp_now()}" illness_record = { "name": pet_name, diff --git a/app/support/data_access_layer/records/details_record.py b/app/support/data_access_layer/records/details_record.py index 577b762..7dea2cb 100644 --- a/app/support/data_access_layer/records/details_record.py +++ b/app/support/data_access_layer/records/details_record.py @@ -1,4 +1,4 @@ -from typing import Dict, Union +from typing import Dict from datetime import datetime from decimal import Decimal @@ -24,7 +24,7 @@ def produce_record( gender: str, breed: str, microchip_number: int - ) -> Dict[str, Union[str, Decimal]]: + ) -> Dict[str, str | Decimal]: details_record = { "name": pet_name, "sort_key": RecordType.DETAILS.value, diff --git a/app/support/data_access_layer/records/illness_record.py b/app/support/data_access_layer/records/illness_record.py index 9d6576c..60193dd 100644 --- a/app/support/data_access_layer/records/illness_record.py +++ b/app/support/data_access_layer/records/illness_record.py @@ -1,5 +1,5 @@ from datetime import datetime, timezone -from typing import Dict, Union +from typing import Dict from decimal import Decimal from app.support.data_access_layer.records.abstract_record import AbstractRecordFactory @@ -22,7 +22,7 @@ def produce_record( ailment: str, observed_time: datetime, description: str - ) -> Dict[str, Union[str, Decimal]]: + ) -> Dict[str, str | Decimal]: sort_key = f"{RecordType.ILLNESS.value}#{ailment}#{utc_timestamp_now()}" illness_record = { "name": pet_name, diff --git a/app/support/data_access_layer/records/medication_record.py b/app/support/data_access_layer/records/medication_record.py index e06deb8..dbc6aac 100644 --- a/app/support/data_access_layer/records/medication_record.py +++ b/app/support/data_access_layer/records/medication_record.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional, Union +from typing import Dict, Optional from datetime import datetime, timezone from decimal import Decimal @@ -23,7 +23,7 @@ def produce_record( name_of_medicine: str, type_of_medicine: str, next_due: Optional[datetime] - ) -> Dict[str, Union[str, Decimal, bool]]: + ) -> Dict[str, str | Decimal | bool]: sort_key = f"{RecordType.MEDICATION.value}#{type_of_medicine}#{utc_timestamp_now()}" if next_due is None: next_due_section = { diff --git a/app/support/data_access_layer/records/observation_record.py b/app/support/data_access_layer/records/observation_record.py index 46da2ad..2f7d4a3 100644 --- a/app/support/data_access_layer/records/observation_record.py +++ b/app/support/data_access_layer/records/observation_record.py @@ -1,5 +1,5 @@ from datetime import datetime, timezone -from typing import Dict, Union +from typing import Dict from decimal import Decimal from app.support.data_access_layer.records.abstract_record import AbstractRecordFactory @@ -21,7 +21,7 @@ def produce_record( pet_name: str, observed_time: datetime, description: str - ) -> Dict[str, Union[str, Decimal]]: + ) -> Dict[str, str | Decimal]: sort_key = f"{RecordType.OBSERVATION.value}#{utc_timestamp_now()}" illness_record = { "name": pet_name,