From 635e71dafc78e6c69506b60e40e8b8bac79c2d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sinclert=20P=C3=A9rez?= Date: Thu, 3 Aug 2023 11:46:59 +0200 Subject: [PATCH] Introduce `@override` from Python 3.12 --- src/job/input/metadata/api.py | 2 ++ src/job/input/metadata/file.py | 2 ++ src/job/parsers/feed.py | 2 ++ src/job/parsers/json.py | 2 ++ src/routines.py | 3 +++ 5 files changed, 11 insertions(+) diff --git a/src/job/input/metadata/api.py b/src/job/input/metadata/api.py index 3ae72e1..9acee1d 100644 --- a/src/job/input/metadata/api.py +++ b/src/job/input/metadata/api.py @@ -3,6 +3,7 @@ import logging from typing import List +from typing import override from dialect_map_io import ArxivAPIHandler from .base import BaseMetadataSource @@ -25,6 +26,7 @@ def __init__(self, handler: ArxivAPIHandler, parser: FeedMetadataParser): self.handler = handler self.parser = parser + @override def get_metadata(self, paper_id: str) -> List[ArxivMetadata]: """ Retrieves the complete metadata of the multiple ArXiv paper versions diff --git a/src/job/input/metadata/file.py b/src/job/input/metadata/file.py index b086663..806c741 100644 --- a/src/job/input/metadata/file.py +++ b/src/job/input/metadata/file.py @@ -3,6 +3,7 @@ import logging from typing import List +from typing import override from dialect_map_io import JSONFileHandler from .base import BaseMetadataSource @@ -36,6 +37,7 @@ def _build_metadata_file(self, file_path: str) -> dict: return {json["id"]: json for json in self.handler.read_items(file_path)} + @override def get_metadata(self, paper_id: str) -> List[ArxivMetadata]: """ Retrieves the complete metadata of the multiple ArXiv paper versions diff --git a/src/job/parsers/feed.py b/src/job/parsers/feed.py index 4578562..0305e07 100644 --- a/src/job/parsers/feed.py +++ b/src/job/parsers/feed.py @@ -4,6 +4,7 @@ import re from typing import List +from typing import override from urllib import parse from feedparser import FeedParserDict @@ -82,6 +83,7 @@ def _extract_doi(self, entry: FeedParserDict) -> str: return paper_doi + @override def parse_body(self, feed: str) -> List[ArxivMetadata]: """ Parses the body section of a given feed API result diff --git a/src/job/parsers/json.py b/src/job/parsers/json.py index 162f846..5e316f2 100644 --- a/src/job/parsers/json.py +++ b/src/job/parsers/json.py @@ -5,6 +5,7 @@ from datetime import datetime from typing import List +from typing import override import pytz @@ -92,6 +93,7 @@ def _extract_doi(self, entry: dict) -> str: return paper_doi + @override def parse_body(self, entry: dict) -> List[ArxivMetadata]: """ Parses the metadata fields of a given metadata JSON entry diff --git a/src/routines.py b/src/routines.py index c6cacd6..4c82ac5 100644 --- a/src/routines.py +++ b/src/routines.py @@ -6,6 +6,7 @@ from abc import ABC from abc import abstractmethod from typing import List +from typing import override from urllib.parse import urlparse from dialect_map_io.handlers import TextFileHandler @@ -48,6 +49,7 @@ def __init__(self, file_iter: FileSystemIterator, pdf_source: PDFCorpusSource): self.file_iter = file_iter self.pdf_source = pdf_source + @override def run(self, destination_path: str) -> None: """ Main routine to extract ArXiv corpus text and store it locally @@ -124,6 +126,7 @@ def add_sources(self, metadata_urls: List[str]) -> None: self.sources.append(source) + @override def run(self, *args) -> None: """ Main routine to extract ArXiv corpus metadata and send it to a REST API