Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Introduce @override from Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinclert committed Oct 3, 2023
1 parent 91f3f6c commit 01970ff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/job/input/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from abc import ABC
from abc import abstractmethod
from typing import List
from typing import override

from dialect_map_gcp import DiffMessage
from dialect_map_gcp import PubSubQueueHandler
Expand Down Expand Up @@ -66,11 +67,13 @@ def _parse_message(self, message: object) -> DiffMessage:
else:
return data_diff

@override
def close(self) -> None:
"""Closes the Pub/Sub connection"""

self.queue_handler.close()

@override
def get_messages(self, num_messages: int) -> List[DiffMessage]:
"""
Retrieve parsed diff messages from a Pub/Sub subscription
Expand Down
2 changes: 2 additions & 0 deletions src/job/mapping/record_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from abc import ABC
from abc import abstractmethod
from typing import List
from typing import override

from dialect_map_schemas import APIRoute
from dialect_map_schemas import SchemaError
Expand Down Expand Up @@ -37,6 +38,7 @@ def __init__(self, routes: List[APIRoute]):

self.routes = routes

@override
def infer_route(self, record: dict) -> APIRoute:
"""
Infers the corresponding API route from a given data record
Expand Down
3 changes: 3 additions & 0 deletions src/job/output/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from abc import ABC
from abc import abstractmethod
from typing import override

from dialect_map_io import DialectMapAPIHandler
from dialect_map_schemas import APIRoute
Expand Down Expand Up @@ -74,6 +75,7 @@ def _archive(self, api_path: str, record_id: str) -> None:
logger.error(f"Error: {error}")
raise

@override
def create_record(self, record_route: APIRoute, record_data: dict) -> None:
"""
Performs the creation of a record on a REST API
Expand All @@ -89,6 +91,7 @@ def create_record(self, record_route: APIRoute, record_data: dict) -> None:
record_schema.dump(record_data),
)

@override
def archive_record(self, record_route: APIRoute, record_data: dict) -> None:
"""
Performs the archival of a record on a REST API
Expand Down
2 changes: 2 additions & 0 deletions src/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from abc import ABC
from abc import abstractmethod
from typing import override

from job.input import BasePubSubSource
from job.mapping import BaseRecordMapper
Expand Down Expand Up @@ -77,6 +78,7 @@ def get_mapper(self, file_name: str) -> BaseRecordMapper:
logger.error(f"Invalid message source file: {file_name}")
raise

@override
def run(self, batch_size: int = 10) -> None:
"""
Main routine to move messages from a Pub/Sub topic to a REST API
Expand Down

0 comments on commit 01970ff

Please sign in to comment.