Skip to content

Commit

Permalink
swapping typing.Union for '|' because we can
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-Derner committed Mar 27, 2024
1 parent 9e824cc commit 77925d5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
10 changes: 3 additions & 7 deletions app/support/common/logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import os
from typing import List, Union
from typing import List
from .misc import ensure_directories_present


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions app/support/data_access_layer/records/abstract_record.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Union
from typing import Dict

from pydantic import ValidationError, BaseModel

Expand Down Expand Up @@ -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}")
Expand Down
4 changes: 2 additions & 2 deletions app/support/data_access_layer/records/appointment_record.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/support/data_access_layer/records/details_record.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Union
from typing import Dict
from datetime import datetime
from decimal import Decimal

Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/support/data_access_layer/records/illness_record.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/support/data_access_layer/records/medication_record.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Optional, Union
from typing import Dict, Optional
from datetime import datetime, timezone
from decimal import Decimal

Expand All @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions app/support/data_access_layer/records/observation_record.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 77925d5

Please sign in to comment.