diff --git a/analysis/career_stage/career_stage_analysis.py b/analysis/career_stage/career_stage_analysis.py index 2a7ca930..93bfecd8 100644 --- a/analysis/career_stage/career_stage_analysis.py +++ b/analysis/career_stage/career_stage_analysis.py @@ -5,7 +5,6 @@ from typing import Any from openalex_client import get_all_author_works - BASE_DIR = Path(__file__).resolve().parent INPUT_FILE = BASE_DIR / "career_stage_sample.csv" OUTPUT_FILE = BASE_DIR / "career_stage_results.csv" diff --git a/analysis/career_stage/career_stage_visualization.py b/analysis/career_stage/career_stage_visualization.py index ddd8a134..6ac73ab1 100644 --- a/analysis/career_stage/career_stage_visualization.py +++ b/analysis/career_stage/career_stage_visualization.py @@ -1,10 +1,10 @@ +from collections.abc import Callable from pathlib import Path -from typing import Callable, Literal +from typing import Literal import matplotlib.pyplot as plt import pandas as pd - BASE_DIR = Path(__file__).resolve().parent INPUT_FILE = BASE_DIR / "career_stage_results.csv" PLOTS_DIR = BASE_DIR / "plots" diff --git a/analysis/career_stage/openalex_client.py b/analysis/career_stage/openalex_client.py index a71d1250..bfecd72d 100644 --- a/analysis/career_stage/openalex_client.py +++ b/analysis/career_stage/openalex_client.py @@ -4,7 +4,6 @@ from urllib.error import HTTPError, URLError from urllib.parse import urlencode from urllib.request import Request, urlopen - OPENALEX_WORKS_URL = "https://api.openalex.org/works" REQUEST_TIMEOUT_SECONDS = 30 PER_PAGE = 200 diff --git a/background-jobs/app/elastic/client.py b/background-jobs/app/elastic/client.py index 1ef0c6dc..da07f59f 100644 --- a/background-jobs/app/elastic/client.py +++ b/background-jobs/app/elastic/client.py @@ -1,8 +1,9 @@ import os -import requests -from requests.adapters import HTTPAdapter from urllib.parse import quote + +import requests from dotenv import load_dotenv +from requests.adapters import HTTPAdapter load_dotenv() diff --git a/background-jobs/app/llm/client.py b/background-jobs/app/llm/client.py index e798d14c..1adcc7ce 100644 --- a/background-jobs/app/llm/client.py +++ b/background-jobs/app/llm/client.py @@ -1,7 +1,7 @@ import os -import requests -from openai import OpenAI, APIConnectionError + from dotenv import load_dotenv +from openai import APIConnectionError, OpenAI load_dotenv() diff --git a/background-jobs/app/sync.py b/background-jobs/app/sync.py index 7c1fed29..24222646 100644 --- a/background-jobs/app/sync.py +++ b/background-jobs/app/sync.py @@ -1,12 +1,13 @@ -import elastic.client as es_client -import llm.client as llm_client -import json import argparse -import time +import json import logging import threading +import time from concurrent.futures import ThreadPoolExecutor, as_completed +import elastic.client as es_client +import llm.client as llm_client + logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s") logger = logging.getLogger(__name__) diff --git a/llm_evaluations/AD_CD_llm/154203/old_test_outputs/test2.py b/llm_evaluations/AD_CD_llm/154203/old_test_outputs/test2.py index f485151a..1e871d97 100644 --- a/llm_evaluations/AD_CD_llm/154203/old_test_outputs/test2.py +++ b/llm_evaluations/AD_CD_llm/154203/old_test_outputs/test2.py @@ -3,7 +3,6 @@ from pathlib import Path from llama_parse import LlamaParse - BASE_DIR = Path(__file__).resolve().parent AD_PATH = BASE_DIR / "AD.pdf" diff --git a/llm_evaluations/AD_CD_llm/188274/old_test_outputs/test2.py b/llm_evaluations/AD_CD_llm/188274/old_test_outputs/test2.py index a5e6f4b9..a0f9bf37 100644 --- a/llm_evaluations/AD_CD_llm/188274/old_test_outputs/test2.py +++ b/llm_evaluations/AD_CD_llm/188274/old_test_outputs/test2.py @@ -1,7 +1,7 @@ import pymupdf4llm -AD_PATH = "188274\AD.pdf" -CD_PATH = "188274\СD.pdf" +AD_PATH = r"188274\AD.pdf" +CD_PATH = r"188274\СD.pdf" ad_md = pymupdf4llm.to_markdown(AD_PATH) cd_md = pymupdf4llm.to_markdown(CD_PATH) diff --git a/llm_evaluations/AD_CD_llm/AD_to_llm.py b/llm_evaluations/AD_CD_llm/AD_to_llm.py index af501da4..dfd898af 100644 --- a/llm_evaluations/AD_CD_llm/AD_to_llm.py +++ b/llm_evaluations/AD_CD_llm/AD_to_llm.py @@ -1,7 +1,7 @@ -from pathlib import Path import getpass import json import os +from pathlib import Path import pymupdf import requests @@ -206,7 +206,7 @@ def make_debug_data( ) -> dict: choice = {} - if "choices" in data and data["choices"]: + if data.get("choices"): choice = data["choices"][0] message = choice.get("message", {}) diff --git a/llm_evaluations/AD_CD_llm/CD_to_llm.py b/llm_evaluations/AD_CD_llm/CD_to_llm.py index 738dc954..d3faf679 100644 --- a/llm_evaluations/AD_CD_llm/CD_to_llm.py +++ b/llm_evaluations/AD_CD_llm/CD_to_llm.py @@ -1,7 +1,7 @@ -from pathlib import Path import getpass import json import os +from pathlib import Path import requests @@ -181,7 +181,7 @@ def make_debug_data( ): choice = {} - if "choices" in data and data["choices"]: + if data.get("choices"): choice = data["choices"][0] message = choice.get("message", {}) diff --git a/llm_evaluations/AD_CD_llm/evaluate_against_gold.py b/llm_evaluations/AD_CD_llm/evaluate_against_gold.py index 2f69ccf0..7f23dd40 100644 --- a/llm_evaluations/AD_CD_llm/evaluate_against_gold.py +++ b/llm_evaluations/AD_CD_llm/evaluate_against_gold.py @@ -1,5 +1,5 @@ -from pathlib import Path import json +from pathlib import Path SCRIPT_DIR = Path(__file__).resolve().parent ROOT_DIR = SCRIPT_DIR diff --git a/llm_evaluations/AD_CD_llm/extract_cd_relevant_tables.py b/llm_evaluations/AD_CD_llm/extract_cd_relevant_tables.py index 6fab884d..d2ac3951 100644 --- a/llm_evaluations/AD_CD_llm/extract_cd_relevant_tables.py +++ b/llm_evaluations/AD_CD_llm/extract_cd_relevant_tables.py @@ -1,5 +1,5 @@ -from pathlib import Path import re +from pathlib import Path import pymupdf diff --git a/llm_evaluations/AD_CD_llm/test_output_formats.py b/llm_evaluations/AD_CD_llm/test_output_formats.py index 36143def..35df02d9 100644 --- a/llm_evaluations/AD_CD_llm/test_output_formats.py +++ b/llm_evaluations/AD_CD_llm/test_output_formats.py @@ -1,4 +1,5 @@ from pathlib import Path + import pymupdf # PyMuPDF try: @@ -7,7 +8,7 @@ except ImportError: MarkItDown = None -AD_PATH = Path("154115\AD.pdf") +AD_PATH = Path(r"154115\AD.pdf") OUT_DIR = Path("ad_extraction_outputs3") OUT_DIR.mkdir(exist_ok=True) diff --git a/llm_evaluations/basic_applied_experimental/audit_work_classifications_summary.py b/llm_evaluations/basic_applied_experimental/audit_work_classifications_summary.py index bd157572..02c4a9f8 100644 --- a/llm_evaluations/basic_applied_experimental/audit_work_classifications_summary.py +++ b/llm_evaluations/basic_applied_experimental/audit_work_classifications_summary.py @@ -3,9 +3,9 @@ from __future__ import annotations import argparse import json from collections import Counter -from statistics import mean, median from datetime import datetime, timezone from pathlib import Path +from statistics import mean, median from typing import Any import requests diff --git a/llm_evaluations/basic_applied_experimental/classify_ude_works_to_index.py b/llm_evaluations/basic_applied_experimental/classify_ude_works_to_index.py index d006ed68..37a85b55 100644 --- a/llm_evaluations/basic_applied_experimental/classify_ude_works_to_index.py +++ b/llm_evaluations/basic_applied_experimental/classify_ude_works_to_index.py @@ -17,7 +17,7 @@ SERVICE_SOURCE_ROOT = ROOT.parents[1] / "service" / "src" / "main" if str(SERVICE_SOURCE_ROOT) not in sys.path: sys.path.insert(0, str(SERVICE_SOURCE_ROOT)) -from inse.authors.institution_membership_query import ( # noqa: E402 +from inse.authors.institution_membership_query import ( build_institution_membership_query, current_affiliation_year_cutoff, ) @@ -852,9 +852,7 @@ def validate(result: dict[str, Any]) -> list[str]: if score is None: errors.append("basic_research_score_missing") elif score_is_usable: - if quadrant == "pure_basic" and not 0 <= score <= 30: - errors.append("basic_research_quadrant_score_mismatch") - elif quadrant == "use_inspired_basic" and not 25 <= score <= 45: + if quadrant == "pure_basic" and not 0 <= score <= 30 or quadrant == "use_inspired_basic" and not 25 <= score <= 45: errors.append("basic_research_quadrant_score_mismatch") if quadrant not in {"pure_basic", "use_inspired_basic"}: errors.append("basic_research_quadrant_mismatch") diff --git a/llm_evaluations/basic_applied_experimental/compare_author_publication_counts.py b/llm_evaluations/basic_applied_experimental/compare_author_publication_counts.py index 43ed54f7..d39239b0 100644 --- a/llm_evaluations/basic_applied_experimental/compare_author_publication_counts.py +++ b/llm_evaluations/basic_applied_experimental/compare_author_publication_counts.py @@ -26,12 +26,12 @@ import json import os import sys from collections import defaultdict +from collections.abc import Iterable from pathlib import Path -from typing import Any, Iterable +from typing import Any import requests - DEFAULT_AUTHOR_ID = "A5034365278" DEFAULT_WORK_YEAR_GTE = 1950 SOURCE_INDEX = "openalex-works*" diff --git a/llm_evaluations/basic_applied_experimental/evaluate_candidate_against_consensus.py b/llm_evaluations/basic_applied_experimental/evaluate_candidate_against_consensus.py index 05ebb276..9beab892 100644 --- a/llm_evaluations/basic_applied_experimental/evaluate_candidate_against_consensus.py +++ b/llm_evaluations/basic_applied_experimental/evaluate_candidate_against_consensus.py @@ -373,8 +373,8 @@ def interval_distance(value: float, minimum: float, maximum: float) -> float: def safe_rate( - numerator: int | float, - denominator: int | float, + numerator: float, + denominator: float, ) -> float | None: if not denominator: return None diff --git a/llm_evaluations/basic_applied_experimental/evaluation/test_new_prompt_against_consensus50.py b/llm_evaluations/basic_applied_experimental/evaluation/test_new_prompt_against_consensus50.py index 12ba8151..c0f65bd7 100644 --- a/llm_evaluations/basic_applied_experimental/evaluation/test_new_prompt_against_consensus50.py +++ b/llm_evaluations/basic_applied_experimental/evaluation/test_new_prompt_against_consensus50.py @@ -13,7 +13,6 @@ from typing import Any from openai import OpenAI - ROOT = Path(__file__).resolve().parent PROMPT_FILE = ROOT.parent / "prompt_frascati_hard_ranges_v2.txt" CONSENSUS_FILE = ROOT / "consensus_reference.json" @@ -282,7 +281,7 @@ def interval_distance(value: float, minimum: float, maximum: float) -> float: return 0.0 -def safe_rate(numerator: int | float, denominator: int | float) -> float | None: +def safe_rate(numerator: float, denominator: float) -> float | None: if not denominator: return None return numerator / denominator diff --git a/llm_evaluations/basic_applied_experimental/report_ude_author_classification_coverage.py b/llm_evaluations/basic_applied_experimental/report_ude_author_classification_coverage.py index d8d16cd2..41f51697 100644 --- a/llm_evaluations/basic_applied_experimental/report_ude_author_classification_coverage.py +++ b/llm_evaluations/basic_applied_experimental/report_ude_author_classification_coverage.py @@ -3,13 +3,13 @@ from __future__ import annotations import argparse import json from collections import Counter +from collections.abc import Callable, Iterable from datetime import datetime, timezone from pathlib import Path -from typing import Any, Callable, Iterable +from typing import Any import requests - ROOT = Path(__file__).resolve().parent ES_BASE_URL = "https://project.nes.uni-due.de/elastic" diff --git a/llm_evaluations/bio_generation/benchmarks/ollama_benchmark.py b/llm_evaluations/bio_generation/benchmarks/ollama_benchmark.py index 4f2726cc..97932ff3 100644 --- a/llm_evaluations/bio_generation/benchmarks/ollama_benchmark.py +++ b/llm_evaluations/bio_generation/benchmarks/ollama_benchmark.py @@ -8,7 +8,6 @@ from concurrent.futures import ThreadPoolExecutor, as_completed from ollama import Client - ENDPOINT = os.environ.get("OLLAMA_HOST", "https://project.nes.uni-due.de/llm2/") MODEL = os.environ.get("OLLAMA_MODEL", "gemma4:e4b-it-bf16") DATA_FOLDER = "data" diff --git a/llm_evaluations/bio_generation/compare_parameter.py b/llm_evaluations/bio_generation/compare_parameter.py index 8a54d181..14d99c4d 100644 --- a/llm_evaluations/bio_generation/compare_parameter.py +++ b/llm_evaluations/bio_generation/compare_parameter.py @@ -1,9 +1,9 @@ -import os import json +import os from concurrent.futures import ThreadPoolExecutor from time import time -from openai import OpenAI, APIConnectionError +from openai import APIConnectionError, OpenAI DATA_FOLDER = "data2" BATCH_SIZE = 6 diff --git a/llm_evaluations/bio_generation/get_data.py b/llm_evaluations/bio_generation/get_data.py index 0633baba..b2eb3f5d 100644 --- a/llm_evaluations/bio_generation/get_data.py +++ b/llm_evaluations/bio_generation/get_data.py @@ -1,5 +1,7 @@ -import requests, json +import json + import helpers +import requests AUTHOR_OPEN_ALEXID = helpers.get_all_author_ids_from_specific_university("University of Duisburg-Essen") #AUTHOR_OPEN_ALEXID = ["A5047117780"] diff --git a/llm_evaluations/bio_generation/get_data_2.py b/llm_evaluations/bio_generation/get_data_2.py index 7da2e4ec..8523cc2d 100644 --- a/llm_evaluations/bio_generation/get_data_2.py +++ b/llm_evaluations/bio_generation/get_data_2.py @@ -1,5 +1,7 @@ -import requests, json +import json + import helpers +import requests AUTHOR_OPEN_ALEXID = helpers.get_all_author_ids_from_specific_university("University of Duisburg-Essen") #AUTHOR_OPEN_ALEXID = ["A5093075883", "A5047117780", "A5007170803"] diff --git a/llm_evaluations/bio_generation/helpers.py b/llm_evaluations/bio_generation/helpers.py index 97e15528..a97cc4e1 100644 --- a/llm_evaluations/bio_generation/helpers.py +++ b/llm_evaluations/bio_generation/helpers.py @@ -1,4 +1,5 @@ import os + import requests ELASTICSEARCH_URL = os.environ.get("ELASTICSEARCH_URL", "https://project.nes.uni-due.de/elastic") diff --git a/llm_evaluations/bio_generation/vllm.py b/llm_evaluations/bio_generation/vllm.py index e81a7b0a..0e76def4 100644 --- a/llm_evaluations/bio_generation/vllm.py +++ b/llm_evaluations/bio_generation/vllm.py @@ -2,8 +2,8 @@ import os from concurrent.futures import ThreadPoolExecutor from time import time -from openai import OpenAI, APIConnectionError import helpers +from openai import APIConnectionError, OpenAI DATA_FOLDER = "data2" BATCH_SIZE = 6 diff --git a/llm_evaluations/eu_to_epo_uspto_patents_matching/analyze_matches.py b/llm_evaluations/eu_to_epo_uspto_patents_matching/analyze_matches.py index 7c2621a4..2b1e3872 100644 --- a/llm_evaluations/eu_to_epo_uspto_patents_matching/analyze_matches.py +++ b/llm_evaluations/eu_to_epo_uspto_patents_matching/analyze_matches.py @@ -1,9 +1,11 @@ -from typing import Any, Iterator -from elasticsearch import Elasticsearch -from collections import defaultdict import json +from collections import defaultdict +from collections.abc import Iterator from pathlib import Path -from elasticsearch import NotFoundError +from typing import Any + +from elasticsearch import Elasticsearch, NotFoundError + # elasticseach library required. Here used elasticsearch==8.0.0 # estimated execution time: 3-5 Minutes diff --git a/llm_evaluations/news_ident_person/benchmark_prompts.py b/llm_evaluations/news_ident_person/benchmark_prompts.py index cc7f91db..7a929e08 100644 --- a/llm_evaluations/news_ident_person/benchmark_prompts.py +++ b/llm_evaluations/news_ident_person/benchmark_prompts.py @@ -1,5 +1,5 @@ -import os import json +import os from time import time from llm_classify_news import call, parse_label, parse_persons diff --git a/llm_evaluations/news_ident_person/build_viewer.py b/llm_evaluations/news_ident_person/build_viewer.py index 538615b9..9351a55b 100644 --- a/llm_evaluations/news_ident_person/build_viewer.py +++ b/llm_evaluations/news_ident_person/build_viewer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ Baut aus den JSON-Dateien in data2/ eine eigenstaendige viewer.html. @@ -8,8 +7,8 @@ mit Vor/Zurueck durch die News blaettern. Oben stehen _id, llm_label und llm_persons, darunter der full_content als reiner Text (kein Parsing). """ -import os import json +import os DATA_FOLDER = "validation_data" OUTPUT_FILE = "viewer.html" diff --git a/llm_evaluations/news_ident_person/fetch_news.py b/llm_evaluations/news_ident_person/fetch_news.py index bbd30ac8..01eefcab 100644 --- a/llm_evaluations/news_ident_person/fetch_news.py +++ b/llm_evaluations/news_ident_person/fetch_news.py @@ -1,5 +1,5 @@ -import os import json +import os import random import requests diff --git a/llm_evaluations/news_ident_person/llm_classify_news.py b/llm_evaluations/news_ident_person/llm_classify_news.py index 8b4cb4b9..d36ec527 100644 --- a/llm_evaluations/news_ident_person/llm_classify_news.py +++ b/llm_evaluations/news_ident_person/llm_classify_news.py @@ -1,10 +1,9 @@ -import os import json +import os import random import requests -from openai import OpenAI, APIConnectionError - +from openai import APIConnectionError, OpenAI INSE_URL = "https://inse.nes.uni-due.de/elastic" INDEX_URL = f"{INSE_URL}/aktuell" diff --git a/llm_evaluations/news_ident_person/read_news.py b/llm_evaluations/news_ident_person/read_news.py index 8c5e9667..68c61d16 100644 --- a/llm_evaluations/news_ident_person/read_news.py +++ b/llm_evaluations/news_ident_person/read_news.py @@ -1,5 +1,5 @@ -import os import json +import os DATA_FOLDER = "data2" diff --git a/llm_evaluations/news_ident_person/results.py b/llm_evaluations/news_ident_person/results.py index 73cea0cc..ca483b10 100644 --- a/llm_evaluations/news_ident_person/results.py +++ b/llm_evaluations/news_ident_person/results.py @@ -1,4 +1,5 @@ import json + from tabulate import tabulate result_files = [ diff --git a/llm_evaluations/news_ident_person/sync/elastic/client.py b/llm_evaluations/news_ident_person/sync/elastic/client.py index aaf72bf4..1a64f7be 100644 --- a/llm_evaluations/news_ident_person/sync/elastic/client.py +++ b/llm_evaluations/news_ident_person/sync/elastic/client.py @@ -1,6 +1,7 @@ +from urllib.parse import quote + import requests from requests.adapters import HTTPAdapter -from urllib.parse import quote INSE_URL = "https://inse.nes.uni-due.de/elastic" INSE_API_KEY = "bG1NSWc1NEJPZ3FnTGZCZXRSSEg6VnJXRFd5SnpSTTNWc1VPT01FMEhMZw==" diff --git a/llm_evaluations/news_ident_person/sync/llm/client.py b/llm_evaluations/news_ident_person/sync/llm/client.py index ea4a4453..b8852475 100644 --- a/llm_evaluations/news_ident_person/sync/llm/client.py +++ b/llm_evaluations/news_ident_person/sync/llm/client.py @@ -1,5 +1,4 @@ -import requests -from openai import OpenAI, APIConnectionError +from openai import APIConnectionError, OpenAI LLM_BASE_URL = "https://project.nes.uni-due.de/llm2/v1/" LLM_API_KEY = "c2d5e7ccf7a4760dd3d19bed2caed9d85ff7437400e0ea82a6d6f912ebc2f212" diff --git a/llm_evaluations/news_ident_person/sync/sync.py b/llm_evaluations/news_ident_person/sync/sync.py index 17a8ded5..0318a200 100644 --- a/llm_evaluations/news_ident_person/sync/sync.py +++ b/llm_evaluations/news_ident_person/sync/sync.py @@ -1,10 +1,12 @@ +import argparse +import json +import threading +import time +from concurrent.futures import ThreadPoolExecutor, as_completed + import elastic.client as es_client import llm.client as llm_client -import json -import argparse -import time -import threading -from concurrent.futures import ThreadPoolExecutor, as_completed + def print_pretty_json(data): print(json.dumps(data, indent=2)) diff --git a/llm_evaluations/sentence_transformer/eval latency of hybrid, key, semantic.py b/llm_evaluations/sentence_transformer/eval latency of hybrid, key, semantic.py index 2be33d26..eb64187e 100644 --- a/llm_evaluations/sentence_transformer/eval latency of hybrid, key, semantic.py +++ b/llm_evaluations/sentence_transformer/eval latency of hybrid, key, semantic.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 -import os -import sys -import json -import time import asyncio +import json +import sys +import time from pathlib import Path + import httpx import numpy as np @@ -14,6 +14,7 @@ project_root = current_dir.parent.parent.resolve() env_path = project_root / "service" / "src" / "main" / "inse" / ".env" from dotenv import load_dotenv + load_dotenv(dotenv_path=env_path) sys.path.append(str(project_root / "service" / "src" / "main")) @@ -311,7 +312,7 @@ async def evaluate(): try: resp = client.post(f"{ELASTIC_URL}topicvectors/_search", json=payload, headers=headers) resp.raise_for_status() - except Exception as exc: + except Exception: # Log error but don't crash pass t1 = time.perf_counter() diff --git a/llm_evaluations/sentence_transformer/eval_models.py b/llm_evaluations/sentence_transformer/eval_models.py index b09722f5..6fb4c03a 100644 --- a/llm_evaluations/sentence_transformer/eval_models.py +++ b/llm_evaluations/sentence_transformer/eval_models.py @@ -4,15 +4,14 @@ Professional evaluation pipeline to benchmark different Sentence Transformer mod on the OpenAlex topics dataset. Measures Information Retrieval (IR) metrics, Taxonomy Clustering metrics, and operational performance metrics. """ -import os -import sys -import json -import time import argparse +import json import random +import sys +import time from pathlib import Path + import httpx -import numpy as np from dotenv import load_dotenv # Add service/src/main to python path to load settings @@ -30,8 +29,8 @@ API_KEY = settings.elasticsearch_api_key # Import evaluation libraries from sentence_transformers import SentenceTransformer from sentence_transformers.evaluation import InformationRetrievalEvaluator -from sklearn.cluster import KMeans from sklearn import metrics +from sklearn.cluster import KMeans DEFAULT_MODELS = [ "paraphrase-multilingual-mpnet-base-v2", @@ -161,9 +160,9 @@ def evaluate_model(model_name, data, output_dir): model_safe_name = model_name.replace("/", "_").replace("-", "_") report_file = output_dir / f"model_report_{model_safe_name}.json" - print(f"\n==================================================") + print("\n==================================================") print(f"Evaluating Model: '{model_name}'") - print(f"==================================================") + print("==================================================") start_load = time.time() try: diff --git a/service/scripts/demo/demo.py b/service/scripts/demo/demo.py index 5e505495..1b35fc43 100644 --- a/service/scripts/demo/demo.py +++ b/service/scripts/demo/demo.py @@ -1,6 +1,6 @@ +import logging import sys import time -import logging logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s") logger = logging.getLogger(__name__) diff --git a/service/scripts/news/topic_mapper/map_news_topics.py b/service/scripts/news/topic_mapper/map_news_topics.py index f34dc42e..50011f6b 100644 --- a/service/scripts/news/topic_mapper/map_news_topics.py +++ b/service/scripts/news/topic_mapper/map_news_topics.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + """ map_news_topics.py — Map news keywords to OpenAlex topics. @@ -37,7 +37,7 @@ import json import logging import os import sys -from datetime import datetime, timezone +from datetime import UTC, datetime from pathlib import Path from dotenv import load_dotenv @@ -121,7 +121,7 @@ async def fetch_source_entries(cluster: str, max_docs: int | None) -> dict[str, async def run(args: argparse.Namespace) -> None: - built_at = datetime.now(timezone.utc).isoformat() + built_at = datetime.now(UTC).isoformat() model_name = os.getenv("SENTENCE_TRANSFORMERS_MODEL_NAME") await base.check_backend(args.api_base_url) diff --git a/service/scripts/news/ude/aktuell/aktuell/middlewares.py b/service/scripts/news/ude/aktuell/aktuell/middlewares.py index 46127f51..27804ec8 100644 --- a/service/scripts/news/ude/aktuell/aktuell/middlewares.py +++ b/service/scripts/news/ude/aktuell/aktuell/middlewares.py @@ -3,10 +3,8 @@ # See documentation in: # https://docs.scrapy.org/en/latest/topics/spider-middleware.html -from scrapy import signals - # useful for handling different item types with a single interface -from itemadapter import is_item, ItemAdapter +from scrapy import signals class AktuellSpiderMiddleware: diff --git a/service/scripts/news/ude/aktuell/aktuell/pipelines.py b/service/scripts/news/ude/aktuell/aktuell/pipelines.py index 2270b2d0..7095d2e0 100644 --- a/service/scripts/news/ude/aktuell/aktuell/pipelines.py +++ b/service/scripts/news/ude/aktuell/aktuell/pipelines.py @@ -5,7 +5,6 @@ # useful for handling different item types with a single interface -from itemadapter import ItemAdapter class AktuellPipeline: diff --git a/service/scripts/news/ude/aktuell/aktuell/spiders/links.py b/service/scripts/news/ude/aktuell/aktuell/spiders/links.py index 02589ae0..18363493 100644 --- a/service/scripts/news/ude/aktuell/aktuell/spiders/links.py +++ b/service/scripts/news/ude/aktuell/aktuell/spiders/links.py @@ -1,5 +1,6 @@ import scrapy + class LinksCrawler(scrapy.Spider): name = "aktuell-links" diff --git a/service/scripts/news/ude/aktuell/aktuell/spiders/meta.py b/service/scripts/news/ude/aktuell/aktuell/spiders/meta.py index c29c38cf..b03cff17 100644 --- a/service/scripts/news/ude/aktuell/aktuell/spiders/meta.py +++ b/service/scripts/news/ude/aktuell/aktuell/spiders/meta.py @@ -1,8 +1,10 @@ -import scrapy import json -from scrapy.linkextractors import LinkExtractor import os +import scrapy +from scrapy.linkextractors import LinkExtractor + + class MetaDataCrawler(scrapy.Spider): name = "aktuell-metadata" diff --git a/service/scripts/news/ude/legacy/aktuell_archiv.py b/service/scripts/news/ude/legacy/aktuell_archiv.py index f302dfe9..25aa6b3b 100644 --- a/service/scripts/news/ude/legacy/aktuell_archiv.py +++ b/service/scripts/news/ude/legacy/aktuell_archiv.py @@ -1,11 +1,12 @@ -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.common.exceptions import NoSuchElementException -from selenium.webdriver.firefox.options import Options -from random import randint -import time import sys +import time +from random import randint + from elasticsearch import Elasticsearch +from selenium import webdriver +from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.by import By +from selenium.webdriver.firefox.options import Options es = Elasticsearch() @@ -32,7 +33,7 @@ def getLinks(link, driver): elem = driver.find_element(By.XPATH, "/html/body/main/div[2]/div/div/div/div/div/div/div[" + str(counter) + "]/b").text if elem == "Zurück zum Gesamtüberblick": break - except NoSuchElementException as nsee: + except NoSuchElementException: break # get date @@ -45,7 +46,7 @@ def getLinks(link, driver): link = "" try: link = driver.find_element(By.XPATH, "/html/body/main/div[2]/div/div/div/div/div/div/div[" + str(counter) + "]/b/a").get_attribute('href') - except NoSuchElementException as nsee: + except NoSuchElementException: continue links.append(link) @@ -67,17 +68,17 @@ def getData(driver, link, date, date_year, date_num): subtitle = "" try: subtitle = driver.find_element(By.XPATH, "/html/body/main/div[3]/div/div/div/div[1]/div[1]/div/hgroup/h3").text - except NoSuchElementException as nsee: + except NoSuchElementException: pass maintitle = "" try: maintitle = driver.find_element(By.XPATH, "/html/body/main/div[3]/div/div/div/div[1]/div[1]/div/hgroup/h2").text - except NoSuchElementException as nsee: + except NoSuchElementException: pass redaktion = "" try: redaktion = driver.find_element(By.XPATH, "/html/body/main/div[3]/div/div/div/div[1]/div[1]/div/p[2]").text - except NoSuchElementException as nsee: + except NoSuchElementException: pass author = "" if redaktion != "": @@ -86,7 +87,7 @@ def getData(driver, link, date, date_year, date_num): main_content = "" try: main_content = driver.find_element(By.XPATH, "/html/body/main/div[3]/div/div/div/div[1]/div[1]/div/p[1]").text - except NoSuchElementException as nsee: + except NoSuchElementException: pass full_content = main_content diff --git a/service/scripts/news/ude/run_pipeline.py b/service/scripts/news/ude/run_pipeline.py index 5f54229c..b3644c92 100644 --- a/service/scripts/news/ude/run_pipeline.py +++ b/service/scripts/news/ude/run_pipeline.py @@ -1,10 +1,10 @@ -import subprocess -import sys -import os -import shutil -import time import argparse import logging +import os +import shutil +import subprocess +import sys +import time logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s") logger = logging.getLogger(__name__) diff --git a/service/scripts/news/ude/upload_aktuell.py b/service/scripts/news/ude/upload_aktuell.py index c97bcb3e..6a8ed207 100644 --- a/service/scripts/news/ude/upload_aktuell.py +++ b/service/scripts/news/ude/upload_aktuell.py @@ -1,8 +1,8 @@ -import sys -import os import json -import time import logging +import os +import sys +import time from urllib.parse import quote import requests diff --git a/service/scripts/patents/build_patents_openalex_keywords.py b/service/scripts/patents/build_patents_openalex_keywords.py index 606660a3..b49125f1 100644 --- a/service/scripts/patents/build_patents_openalex_keywords.py +++ b/service/scripts/patents/build_patents_openalex_keywords.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + """ build_patents_openalex_keywords.py — Build IPC/CPC → OpenAlex topic/keyword matches. diff --git a/service/scripts/patents/evaluate_keyword_patent_search.py b/service/scripts/patents/evaluate_keyword_patent_search.py index 550876db..5c174bbf 100644 --- a/service/scripts/patents/evaluate_keyword_patent_search.py +++ b/service/scripts/patents/evaluate_keyword_patent_search.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + """ evaluate_keyword_patent_search.py — Systematic evaluation for keyword → patent search. @@ -23,14 +23,14 @@ import asyncio import json import logging import sys -from datetime import datetime, timezone +from datetime import UTC, datetime from pathlib import Path from typing import Any current_dir = Path(__file__).resolve().parent sys.path.insert(0, str(current_dir.parent.parent / "src" / "main")) -from inse.patents.keywords.eval_metrics import ( # noqa: E402 +from inse.patents.keywords.eval_metrics import ( analyze_family_duplicates_in_top_k, average_precision, ipc_prefix_hit_rate, @@ -43,13 +43,13 @@ from inse.patents.keywords.eval_metrics import ( # noqa: E402 recall_at_k, unique_family_precision_at_k, ) -from inse.patents.keywords.logic import ( # noqa: E402 +from inse.patents.keywords.logic import ( _DEFAULT_SCORE_WEIGHTS, _MAX_PATENTS, _compute_final_score, get_patents_by_keywords, ) -from inse.patents.keywords.model import ( # noqa: E402 +from inse.patents.keywords.model import ( KeywordPatentMatch, KeywordPatentSearchDiagnostics, KeywordPatentSearchItem, @@ -721,9 +721,7 @@ def _load_prior_candidate_grades( if existing is None: bucket[patent_id] = dict(candidate) continue - if existing.get("grade") is None and grade is not None: - bucket[patent_id] = dict(candidate) - elif existing.get("grade") is None: + if existing.get("grade") is None and grade is not None or existing.get("grade") is None: bucket[patent_id] = dict(candidate) return by_case @@ -884,7 +882,7 @@ async def cmd_bootstrap(args: argparse.Namespace) -> int: } ) - stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ") + stamp = datetime.now(UTC).strftime("%Y%m%dT%H%M%SZ") labeling_path = out_dir / f"labeling_{stamp}.json" report_path = out_dir / f"bootstrap_report_{stamp}.json" @@ -979,7 +977,7 @@ async def cmd_eval(args: argparse.Namespace) -> int: if presentation else _aggregate(case_reports, ks) ) - stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ") + stamp = datetime.now(UTC).strftime("%Y%m%dT%H%M%SZ") report_name = "presentation_eval_report" if presentation else "eval_report" report_path = Path(args.out_dir) / f"{report_name}_{stamp}.json" _write_json( @@ -1071,7 +1069,7 @@ async def cmd_ablation(args: argparse.Namespace) -> int: f"P@10={p10}" ) - stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ") + stamp = datetime.now(UTC).strftime("%Y%m%dT%H%M%SZ") report_path = Path(args.out_dir) / f"ablation_report_{stamp}.json" _write_json( report_path, diff --git a/service/scripts/patents/index_org_patents.py b/service/scripts/patents/index_org_patents.py index f7c5b469..d6da7874 100644 --- a/service/scripts/patents/index_org_patents.py +++ b/service/scripts/patents/index_org_patents.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + """ index_org_patents.py — Build the org_patents Elasticsearch index for one institution. diff --git a/service/scripts/projects/bund/gpc.data.py b/service/scripts/projects/bund/gpc.data.py index 2d538982..5169a0ae 100644 --- a/service/scripts/projects/bund/gpc.data.py +++ b/service/scripts/projects/bund/gpc.data.py @@ -1,23 +1,21 @@ +import argparse +import hashlib +import json +import logging +import math +import os +import time +from datetime import datetime + +import pandas as pd +import requests from selenium import webdriver -from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.alert import Alert -from random import randint -import time -import pandas as pd -import json -from datetime import datetime -import sys -import os -import math -import requests -import hashlib -import argparse -import logging +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s") logger = logging.getLogger(__name__) diff --git a/service/scripts/projects/topic_mapper/map_project_topics.py b/service/scripts/projects/topic_mapper/map_project_topics.py index 89c6f099..13125a5c 100644 --- a/service/scripts/projects/topic_mapper/map_project_topics.py +++ b/service/scripts/projects/topic_mapper/map_project_topics.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + """ map_project_topics.py — Map project keywords to OpenAlex topics. @@ -52,9 +52,10 @@ import json import logging import os import sys -from datetime import datetime, timezone +from collections.abc import AsyncIterator +from datetime import UTC, datetime from pathlib import Path -from typing import Any, AsyncIterator +from typing import Any import httpx from dotenv import load_dotenv @@ -396,7 +397,7 @@ async def bulk_index(index: str, cluster: str, documents: list[tuple[str, dict]] async def run(args: argparse.Namespace) -> None: - built_at = datetime.now(timezone.utc).isoformat() + built_at = datetime.now(UTC).isoformat() model_name = os.getenv("SENTENCE_TRANSFORMERS_MODEL_NAME") await check_backend(args.api_base_url) diff --git a/service/scripts/test_keywords_matching.py b/service/scripts/test_keywords_matching.py index dec27c95..61bf501d 100644 --- a/service/scripts/test_keywords_matching.py +++ b/service/scripts/test_keywords_matching.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + """ test_keywords_matching.py diff --git a/service/sentence_transformer/download_model.py b/service/sentence_transformer/download_model.py index cef45c27..77cbd56c 100644 --- a/service/sentence_transformer/download_model.py +++ b/service/sentence_transformer/download_model.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 + """ Download the sentence-transformers model to the default cache directory so it is available for local runs or testing. diff --git a/service/sentence_transformer/index_topics.py b/service/sentence_transformer/index_topics.py index b340ee30..39c6616f 100644 --- a/service/sentence_transformer/index_topics.py +++ b/service/sentence_transformer/index_topics.py @@ -1,12 +1,13 @@ -#!/usr/bin/env python3 + """ Script to fetch all topics from 'openalex-topics', vectorize display names, full descriptions, and individual keywords using the sentence-transformers model, and push them to the 'topicvectors' index with multi-vector mapping. """ -import sys import json +import sys from pathlib import Path + import httpx from dotenv import load_dotenv @@ -26,7 +27,6 @@ API_KEY = settings.elasticsearch_api_key MODEL_NAME = settings.sentence_transformers_model_name # Import sentence-transformers -from sentence_transformers import SentenceTransformer headers = { "Authorization": f"ApiKey {API_KEY}", diff --git a/service/src/main/inse/account_management/model.py b/service/src/main/inse/account_management/model.py index dd6a11c6..a9c0d9d0 100644 --- a/service/src/main/inse/account_management/model.py +++ b/service/src/main/inse/account_management/model.py @@ -1,5 +1,4 @@ import uuid -from typing import List, Optional from pydantic import BaseModel, Field, model_validator @@ -9,14 +8,14 @@ from inse.auth.model import UserRole, normalize_roles class OrganizationProfile(BaseModel): id: uuid.UUID name: str - openalex_institution_id: Optional[str] = None + openalex_institution_id: str | None = None class AccountProfile(BaseModel): id: uuid.UUID email: str name: str - roles: List[UserRole] + roles: list[UserRole] organization_id: uuid.UUID organization_name: str deleted: bool @@ -27,7 +26,7 @@ class AccountProfile(BaseModel): class AccountPage(BaseModel): - items: List[AccountProfile] + items: list[AccountProfile] total: int page: int page_size: int @@ -43,10 +42,10 @@ class CreateAccountRequest(BaseModel): email: str = Field(min_length=3) name: str = Field(min_length=1) - roles: List[UserRole] = Field(default_factory=lambda: [UserRole.USER]) + roles: list[UserRole] = Field(default_factory=lambda: [UserRole.USER]) organization_id: uuid.UUID password: str = Field(min_length=8) - openalex_person_id: Optional[str] = None + openalex_person_id: str | None = None @model_validator(mode="after") def _normalize_roles(self): @@ -62,14 +61,14 @@ class UpdateAccountRequest(BaseModel): values = {**values, "roles": [values["role"]]} return values - email: Optional[str] = Field(default=None, min_length=3) - name: Optional[str] = Field(default=None, min_length=1) - roles: Optional[List[UserRole]] = None - organization_id: Optional[uuid.UUID] = None - password: Optional[str] = Field(default=None, min_length=8) - openalex_person_id: Optional[str] = None - deleted: Optional[bool] = None - activated: Optional[bool] = None + email: str | None = Field(default=None, min_length=3) + name: str | None = Field(default=None, min_length=1) + roles: list[UserRole] | None = None + organization_id: uuid.UUID | None = None + password: str | None = Field(default=None, min_length=8) + openalex_person_id: str | None = None + deleted: bool | None = None + activated: bool | None = None @model_validator(mode="after") def _normalize_roles(self): diff --git a/service/src/main/inse/account_management/router.py b/service/src/main/inse/account_management/router.py index 81b22593..8388ebf2 100644 --- a/service/src/main/inse/account_management/router.py +++ b/service/src/main/inse/account_management/router.py @@ -1,5 +1,5 @@ import uuid -from typing import Annotated, Optional +from typing import Annotated from fastapi import APIRouter, Query, Response, status @@ -40,8 +40,8 @@ async def list_accounts( page: Annotated[int, Query(ge=0)] = 0, page_size: Annotated[int, Query(ge=1, le=100)] = 10, offset: Annotated[int, Query(ge=0)] = 0, - search: Annotated[Optional[str], Query()] = None, - organization_id: Annotated[Optional[uuid.UUID], Query()] = None, + search: Annotated[str | None, Query()] = None, + organization_id: Annotated[uuid.UUID | None, Query()] = None, access_token: AccessTokenMetadata = auth_service.CurrentUserAccessTokenPayloadDep, ) -> AccountPage: return service.list_accounts( diff --git a/service/src/main/inse/account_management/service.py b/service/src/main/inse/account_management/service.py index 2c4510bd..915ec248 100644 --- a/service/src/main/inse/account_management/service.py +++ b/service/src/main/inse/account_management/service.py @@ -1,5 +1,4 @@ import uuid -from typing import Optional from fastapi import HTTPException, status from sqlmodel import Session, func, or_, select @@ -84,7 +83,7 @@ def _ensure_account_in_editor_scope(account: Account, token: AccessTokenMetadata def _ensure_email_available( session: Session, email: str, - excluded_account_id: Optional[uuid.UUID] = None, + excluded_account_id: uuid.UUID | None = None, ) -> None: normalized_email = email.lower().strip() if "@" not in normalized_email or "." not in normalized_email.rsplit("@", 1)[-1]: @@ -115,9 +114,9 @@ def list_accounts( access_token: AccessTokenMetadata, page: int, page_size: int, - offset: Optional[int] = None, - search: Optional[str] = None, - organization_id: Optional[uuid.UUID] = None, + offset: int | None = None, + search: str | None = None, + organization_id: uuid.UUID | None = None, ) -> AccountPage: if access_token.effective_role not in { UserRole.SUPER_ADMIN, diff --git a/service/src/main/inse/auth/model.py b/service/src/main/inse/auth/model.py index 3b211935..d78caf5b 100644 --- a/service/src/main/inse/auth/model.py +++ b/service/src/main/inse/auth/model.py @@ -1,7 +1,6 @@ import uuid from datetime import datetime from enum import StrEnum -from typing import List from pydantic import BaseModel, model_validator from sqlalchemy import JSON, Column, UniqueConstraint @@ -24,8 +23,8 @@ ROLE_PRIORITY = { def normalize_roles( - roles: List[UserRole] | List[str] | UserRole | str | None, -) -> List[UserRole]: + roles: list[UserRole] | list[str] | UserRole | str | None, +) -> list[UserRole]: if roles is None: return [UserRole.USER] if isinstance(roles, (str, UserRole)): @@ -43,7 +42,7 @@ def normalize_roles( def effective_role_for_roles( - roles: List[UserRole] | List[str] | UserRole | str | None, + roles: list[UserRole] | list[str] | UserRole | str | None, ) -> UserRole: return normalize_roles(roles)[0] @@ -86,7 +85,7 @@ class Organization(Durable, table=True): description="The OpenAlex ID of the institution associated with the organization.", ) - accounts: List["Account"] = Relationship(back_populates="organization") + accounts: list["Account"] = Relationship(back_populates="organization") class Account(Durable, table=True): @@ -141,7 +140,7 @@ class Account(Durable, table=True): nullable=False, description="The unique identifier of the organization strictly associated with this account.", ) - roles: List[UserRole] = Field( + roles: list[UserRole] = Field( default_factory=lambda: [UserRole.USER], sa_column=Column(JSON, nullable=False, default=lambda: [UserRole.USER.value]), description="The roles this account holds within its organization.", @@ -249,7 +248,7 @@ class AccessTokenMetadata(BaseTokenData): default=UserRole.USER, description="The specific role this access token grants within its organization.", ) - effective_roles: List[UserRole] = Field( + effective_roles: list[UserRole] = Field( default_factory=lambda: [UserRole.USER], description="The roles this access token grants within its organization.", ) @@ -300,7 +299,7 @@ class RefreshTokenMetadata(BaseTokenData): default=UserRole.USER, description="The specific role this access token grants within its organization.", ) - effective_roles: List[UserRole] = Field( + effective_roles: list[UserRole] = Field( default_factory=lambda: [UserRole.USER], description="The roles this access token grants within its organization.", ) diff --git a/service/src/main/inse/auth/router.py b/service/src/main/inse/auth/router.py index 581d714b..9bf5d85a 100644 --- a/service/src/main/inse/auth/router.py +++ b/service/src/main/inse/auth/router.py @@ -1,14 +1,11 @@ import logging -from typing import Annotated import uuid +from typing import Annotated from fastapi import APIRouter, Body, Depends, Response, status from sqlmodel import Session -from inse.tags import Tags - import inse.auth.service as auth_service -from inse.database import SessionDep, get_session from inse.auth.model import ( AccessResponse, AccessToken, @@ -18,6 +15,8 @@ from inse.auth.model import ( OtkResponse, RefreshTokenMetadata, ) +from inse.database import SessionDep, get_session +from inse.tags import Tags logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/auth/service.py b/service/src/main/inse/auth/service.py index 39855a14..9ce83f9c 100644 --- a/service/src/main/inse/auth/service.py +++ b/service/src/main/inse/auth/service.py @@ -4,7 +4,7 @@ import json import logging import secrets import uuid -from typing import Annotated, Any, Dict, Optional +from typing import Annotated, Any import jwt from argon2 import PasswordHasher @@ -95,7 +95,7 @@ def create_predefined_accounts(session: Session, file_path: str): try: with open(file_path, "r") as file: - data: Dict[str, Any] = json.loads(file.read()) + data: dict[str, Any] = json.loads(file.read()) for organization_data in data.get("organizations", []): organization_id = organization_data.get("id") if organization_id is not None: @@ -215,7 +215,7 @@ def request_otk(session: Session, email: str, password: str): account = session.exec( select(Account).where( Account.email == email, - Account.deleted == False, # noqa: E712 + Account.deleted == False, ) ).first() @@ -254,7 +254,7 @@ def request_otk(session: Session, email: str, password: str): ) ).first() - expires_at = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( + expires_at = datetime.datetime.now(datetime.UTC) + datetime.timedelta( minutes=OTK_EXPIRATION_MINUTES ) @@ -293,19 +293,19 @@ def request_otk(session: Session, email: str, password: str): return OtkResponse(status="success", account_id=account.id) -def request_password_reset(session: Session, email: str) -> Dict[str, Any]: +def request_password_reset(session: Session, email: str) -> dict[str, Any]: """Requests a one-time password reset link for the given email address. For security reasons, this function always returns a successful response and does not reveal whether the email address belongs to an active account. """ email = email.lower().strip() - now = datetime.datetime.now(datetime.timezone.utc) + now = datetime.datetime.now(datetime.UTC) account = session.exec( select(Account).where( Account.email == email, - Account.deleted == False, # noqa: E712 + Account.deleted == False, ) ).first() @@ -328,9 +328,7 @@ def request_password_reset(session: Session, email: str) -> Dict[str, Any]: if secret.request_window_started_at is not None: window_started_at = secret.request_window_started_at if getattr(window_started_at, "tzinfo", None) is None: - window_started_at = window_started_at.replace( - tzinfo=datetime.timezone.utc - ) + window_started_at = window_started_at.replace(tzinfo=datetime.UTC) window_ends_at = window_started_at + datetime.timedelta( minutes=PASSWORD_RESET_RATE_LIMIT_WINDOW_MINUTES @@ -435,7 +433,7 @@ def reset_password( session: Session, reset_token: str, new_password: str, -) -> Dict[str, str]: +) -> dict[str, str]: """Resets an account password using a one-time password reset token. Args: @@ -449,7 +447,7 @@ def reset_password( Returns: Dict[str, str]: A status response. """ - now = datetime.datetime.now(datetime.timezone.utc) + now = datetime.datetime.now(datetime.UTC) reset_token_hash = _hash_reset_token(reset_token.strip()) secret = session.exec( @@ -467,7 +465,7 @@ def reset_password( secret_expires = secret.expires_at if getattr(secret_expires, "tzinfo", None) is None: - secret_expires = secret_expires.replace(tzinfo=datetime.timezone.utc) + secret_expires = secret_expires.replace(tzinfo=datetime.UTC) if secret_expires <= now: session.delete(secret) @@ -515,7 +513,7 @@ def login( Returns: LoginResponse: The response containing the ID token issued upon successful login. """ - now = datetime.datetime.now(datetime.timezone.utc) + now = datetime.datetime.now(datetime.UTC) secret = session.exec( select(Secret).where( @@ -536,7 +534,7 @@ def login( secret_expires = secret.expires_at if getattr(secret_expires, "tzinfo", None) is None: - secret_expires = secret_expires.replace(tzinfo=datetime.timezone.utc) + secret_expires = secret_expires.replace(tzinfo=datetime.UTC) if secret_expires <= now: logger.warning("Login failed: invalid or expired code %s", email_code) @@ -611,7 +609,7 @@ def _get_current_user_access_token_payload( real_account_id=uuid.UUID(access_token_payload[REAL_ACCOUNT_ID_KEY]), effective_account_id=uuid.UUID(access_token_payload[EFFECTIVE_ACCOUNT_ID_KEY]), expires_at=datetime.datetime.fromtimestamp( - access_token_payload["exp"], tz=datetime.timezone.utc + access_token_payload["exp"], tz=datetime.UTC ), epoch=access_token_payload[EPOCH_KEY], effective_role=UserRole(access_token_payload[EFFECTIVE_ROLE_KEY]), @@ -657,7 +655,7 @@ def _get_current_user_refresh_token_payload( real_account_id=uuid.UUID(refresh_token_payload[REAL_ACCOUNT_ID_KEY]), effective_account_id=uuid.UUID(refresh_token_payload[EFFECTIVE_ACCOUNT_ID_KEY]), expires_at=datetime.datetime.fromtimestamp( - refresh_token_payload["exp"], tz=datetime.timezone.utc + refresh_token_payload["exp"], tz=datetime.UTC ), epoch=refresh_token_payload[EPOCH_KEY], effective_role=UserRole(refresh_token_payload[EFFECTIVE_ROLE_KEY]), @@ -708,7 +706,7 @@ def _get_current_user_id_token_payload( return IdTokenMetadata( real_account_id=uuid.UUID(id_token_payload[REAL_ACCOUNT_ID_KEY]), expires_at=datetime.datetime.fromtimestamp( - id_token_payload["exp"], tz=datetime.timezone.utc + id_token_payload["exp"], tz=datetime.UTC ), epoch=id_token_payload[EPOCH_KEY], ) @@ -784,9 +782,7 @@ def _get_account_organization(session: Session, account_id: uuid.UUID) -> uuid.U return account.organization_id -def _get_account_institution_id( - session: Session, account_id: uuid.UUID -) -> Optional[str]: +def _get_account_institution_id(session: Session, account_id: uuid.UUID) -> str | None: """Retrieves the OpenAlex institution ID for the given account ID. Args: @@ -872,7 +868,7 @@ def get_access_token( session: Session, id_token: IdTokenMetadata, real_account_id: uuid.UUID, - effective_account_id: Optional[uuid.UUID] = None, + effective_account_id: uuid.UUID | None = None, ) -> AccessResponse: # IMPORTANT: The ID token has already been verified by the dependency injection system, so we can trust its payload here. @@ -1054,7 +1050,7 @@ def _build_id_token( Returns: IdToken: The generated ID token object. """ - expires_at = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( + expires_at = datetime.datetime.now(datetime.UTC) + datetime.timedelta( minutes=ID_TOKEN_EXPIRATION_MINUTES ) payload = { @@ -1082,7 +1078,7 @@ def _set_refresh_token( effective_organization_id: uuid.UUID, epoch: int, effective_roles: list[UserRole] | None = None, - effective_institution_id: Optional[str] = None, + effective_institution_id: str | None = None, ) -> RefreshTokenMetadata: """Builds a refresh token for the specified account IDs, role, organization ID, epoch, and fingerprint hash. @@ -1098,7 +1094,7 @@ def _set_refresh_token( Returns: RefreshTokenMetadata: The generated refresh token object. """ - expires_at = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( + expires_at = datetime.datetime.now(datetime.UTC) + datetime.timedelta( minutes=REFRESH_TOKEN_EXPIRATION_MINUTES ) effective_roles = normalize_roles(effective_roles or effective_role) @@ -1137,7 +1133,7 @@ def _build_access_token( epoch: int, user_fingerprint_hash: str, effective_roles: list[UserRole] | None = None, - effective_institution_id: Optional[str] = None, + effective_institution_id: str | None = None, ) -> AccessToken: """Builds an access token for the specified account IDs, role, organization ID, epoch, and fingerprint hash. @@ -1153,7 +1149,7 @@ def _build_access_token( Returns: AccessToken: The generated access token object. """ - expires_at = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta( + expires_at = datetime.datetime.now(datetime.UTC) + datetime.timedelta( minutes=ACCESS_TOKEN_EXPIRATION_MINUTES ) effective_roles = normalize_roles(effective_roles or effective_role) @@ -1189,7 +1185,7 @@ def _build_access_token( def _build_token( - payload: Dict[str, Any], + payload: dict[str, Any], expiration_datetime: datetime.datetime, token_type: TokenType, ) -> str: @@ -1203,7 +1199,7 @@ def _build_token( Returns: str: The encoded JWT token. """ - now = datetime.datetime.now(datetime.timezone.utc) + now = datetime.datetime.now(datetime.UTC) payload.update( { "exp": expiration_datetime, @@ -1219,7 +1215,7 @@ def _build_token( return token -def _verify_id_token(raw_id_token: str, session: Session) -> Dict[str, Any]: +def _verify_id_token(raw_id_token: str, session: Session) -> dict[str, Any]: """Verifies the provided ID token and returns the decoded payload if valid. Args: @@ -1239,7 +1235,7 @@ def _verify_id_token(raw_id_token: str, session: Session) -> Dict[str, Any]: return payload -def _verify_refresh_token(raw_refresh_token: str, session: Session) -> Dict[str, Any]: +def _verify_refresh_token(raw_refresh_token: str, session: Session) -> dict[str, Any]: """Verifies the provided refresh token and returns the decoded payload if valid. Args: @@ -1263,7 +1259,7 @@ def _verify_access_token_fp( secure_fgp: str, raw_access_token: str, session: Session, -) -> Dict[str, Any]: +) -> dict[str, Any]: """Verifies the provided accesstoken against the fingerprint stored in the specified cookie and returns the decoded payload if valid. Args: @@ -1381,7 +1377,7 @@ def _get_active_account(session: Session, account_id: uuid.UUID) -> Account: return account -def logout(session: Session, access_token: AccessTokenMetadata) -> Dict[str, str]: +def logout(session: Session, access_token: AccessTokenMetadata) -> dict[str, str]: """Logout the user by incrementing the epoch of the account associated with the provided access token, effectively invalidating all existing tokens for that account. Args: @@ -1408,7 +1404,7 @@ def change_password( access_token: AccessTokenMetadata, current_password: str, new_password: str, -) -> Dict[str, str]: +) -> dict[str, str]: """Change the password for the user associated with the provided access token. Args: diff --git a/service/src/main/inse/auth/test_auth_service.py b/service/src/main/inse/auth/test_auth_service.py index 17521871..1b5c92cb 100644 --- a/service/src/main/inse/auth/test_auth_service.py +++ b/service/src/main/inse/auth/test_auth_service.py @@ -1,24 +1,22 @@ -import inse.config as config_module -import uuid - -import pytest -from sqlmodel import Session, SQLModel, create_engine, select - - -from fastapi import Response, HTTPException import datetime as _dt +import uuid from datetime import timedelta +import pytest +from fastapi import HTTPException, Response +from sqlmodel import Session, SQLModel, create_engine, select + +import inse.config as config_module from inse.auth import service as auth_service from inse.auth.model import ( + AccessToken, + AccessTokenMetadata, Account, + IdTokenMetadata, Organization, + RefreshTokenMetadata, Secret, SecretPurpose, - AccessToken, - IdTokenMetadata, - AccessTokenMetadata, - RefreshTokenMetadata, UserRole, ) @@ -188,7 +186,7 @@ def test_access_and_refresh_token_flow(in_memory_session, settings_backup): refresh_payload[auth_service.EFFECTIVE_ACCOUNT_ID_KEY] ), expires_at=_dt.datetime.fromtimestamp( - refresh_payload["exp"], tz=_dt.timezone.utc + refresh_payload["exp"], tz=_dt.UTC ), epoch=refresh_payload[auth_service.EPOCH_KEY], effective_role=UserRole(refresh_payload[auth_service.EFFECTIVE_ROLE_KEY]), @@ -346,7 +344,7 @@ def test_login_with_expired_secret(in_memory_session, settings_backup): org, acc = create_org_and_account(in_memory_session, email, password) assert acc.id is not None - expired_at = _dt.datetime.now(_dt.timezone.utc) - timedelta(minutes=10) + expired_at = _dt.datetime.now(_dt.UTC) - timedelta(minutes=10) secret = Secret( account_id=acc.id, purpose=SecretPurpose.LOGIN_OTK, @@ -593,7 +591,7 @@ def test_expired_jwt_token_raises(in_memory_session, settings_backup): assert acc.id is not None response = Response() - past = _dt.datetime.now(_dt.timezone.utc) - timedelta(minutes=5) + past = _dt.datetime.now(_dt.UTC) - timedelta(minutes=5) access_fingerprint_hash = auth_service._set_access_fp_cookie(response) payload = { auth_service.REAL_ACCOUNT_ID_KEY: str(acc.id), @@ -624,7 +622,7 @@ def test_missing_hmac_key_raises_value_error(settings_backup): with pytest.raises(ValueError): auth_service._build_token( payload={}, - expiration_datetime=_dt.datetime.now(_dt.timezone.utc), + expiration_datetime=_dt.datetime.now(_dt.UTC), token_type=auth_service.TokenType.ID_TOKEN, ) config_module.settings.token_hmac_key = saved @@ -715,7 +713,7 @@ def test_reset_password_changes_password_and_increments_epoch(in_memory_session) account_id=acc.id, purpose=SecretPurpose.PASSWORD_RESET, secret_value=auth_service._hash_reset_token(reset_token), - expires_at=_dt.datetime.now(_dt.timezone.utc) + timedelta(minutes=5), + expires_at=_dt.datetime.now(_dt.UTC) + timedelta(minutes=5), ) in_memory_session.add(secret) in_memory_session.commit() @@ -753,7 +751,7 @@ def test_reset_password_rejects_reused_token(in_memory_session): account_id=acc.id, purpose=SecretPurpose.PASSWORD_RESET, secret_value=auth_service._hash_reset_token(reset_token), - expires_at=_dt.datetime.now(_dt.timezone.utc) + timedelta(minutes=5), + expires_at=_dt.datetime.now(_dt.UTC) + timedelta(minutes=5), ) in_memory_session.add(secret) in_memory_session.commit() @@ -792,7 +790,7 @@ def test_reset_password_rejects_expired_token(in_memory_session): account_id=acc.id, purpose=SecretPurpose.PASSWORD_RESET, secret_value=auth_service._hash_reset_token(reset_token), - expires_at=_dt.datetime.now(_dt.timezone.utc) - timedelta(minutes=1), + expires_at=_dt.datetime.now(_dt.UTC) - timedelta(minutes=1), ) in_memory_session.add(secret) in_memory_session.commit() diff --git a/service/src/main/inse/authors/institution_membership_query.py b/service/src/main/inse/authors/institution_membership_query.py index f3910965..e10928ae 100644 --- a/service/src/main/inse/authors/institution_membership_query.py +++ b/service/src/main/inse/authors/institution_membership_query.py @@ -1,10 +1,9 @@ from __future__ import annotations from collections.abc import Iterable -from datetime import datetime, timezone +from datetime import UTC, datetime from typing import Any, Literal - AFFILIATION_LOOKBACK_YEARS = 2 OPENALEX_ID_PREFIX = "https://openalex.org/" AffiliationYearMode = Literal["all", "in", "from", "between"] @@ -21,7 +20,7 @@ def current_affiliation_year_cutoff( when needed. """ - current_time = reference_time or datetime.now(timezone.utc) + current_time = reference_time or datetime.now(UTC) return current_time.year - AFFILIATION_LOOKBACK_YEARS diff --git a/service/src/main/inse/authors/v2/collaboration_graph_jobs.py b/service/src/main/inse/authors/v2/collaboration_graph_jobs.py index 10498e92..75882772 100644 --- a/service/src/main/inse/authors/v2/collaboration_graph_jobs.py +++ b/service/src/main/inse/authors/v2/collaboration_graph_jobs.py @@ -65,7 +65,7 @@ def mark_collaboration_graph_job_completed( return job.status = CollaborationGraphStatus.COMPLETED job.set_result(result) - job.updated_at = datetime.datetime.now(datetime.timezone.utc) + job.updated_at = datetime.datetime.now(datetime.UTC) session.add(job) session.commit() @@ -86,7 +86,7 @@ def mark_collaboration_graph_job_failed( return job.status = CollaborationGraphStatus.FAILED job.error_message = error_message - job.updated_at = datetime.datetime.now(datetime.timezone.utc) + job.updated_at = datetime.datetime.now(datetime.UTC) session.add(job) session.commit() @@ -103,7 +103,7 @@ def cleanup_old_collaboration_graph_jobs( Returns: int: The number of stale jobs that were cleaned up. """ - cutoff_time = datetime.datetime.now(datetime.timezone.utc) - max_age + cutoff_time = datetime.datetime.now(datetime.UTC) - max_age statement = select(CollaborationGraphJob).where( CollaborationGraphJob.created_at < cutoff_time ) diff --git a/service/src/main/inse/authors/v2/service.py b/service/src/main/inse/authors/v2/service.py index ba563736..7a49be8e 100644 --- a/service/src/main/inse/authors/v2/service.py +++ b/service/src/main/inse/authors/v2/service.py @@ -142,7 +142,7 @@ async def get_authors_by_ids(author_ids: list[str]) -> AuthorPage: return await search_authors( page=0, - size=len(author_ids) if len(author_ids) <10000 else 10000, + size=min(10000, len(author_ids)), query={"terms": {"id": author_ids}}, source=[ "id", diff --git a/service/src/main/inse/background_jobs/model.py b/service/src/main/inse/background_jobs/model.py index 2a19fbef..5de396de 100644 --- a/service/src/main/inse/background_jobs/model.py +++ b/service/src/main/inse/background_jobs/model.py @@ -2,9 +2,8 @@ Database tables and API schemas for the background job runner. """ -from datetime import datetime, timezone +from datetime import UTC, datetime from enum import StrEnum -from typing import Optional from pydantic import BaseModel from sqlmodel import JSON, Column, Field, SQLModel @@ -23,13 +22,13 @@ class JobTriggeredBy(StrEnum): def utcnow() -> datetime: - return datetime.now(timezone.utc).replace(tzinfo=None) + return datetime.now(UTC).replace(tzinfo=None) class JobDefinition(SQLModel, table=True): __tablename__ = "background_job_definition" - id: Optional[int] = Field(default=None, primary_key=True) + id: int | None = Field(default=None, primary_key=True) name: str = Field( index=True, unique=True, description="Human-readable job name shown in the UI." ) @@ -37,12 +36,12 @@ class JobDefinition(SQLModel, table=True): target_index: str = Field( default="", description="Elasticsearch index the job writes to (UI info)." ) - image: Optional[str] = Field( + image: str | None = Field( default=None, description="Docker image to run. Null falls back to the configured " "background-jobs image.", ) - command: Optional[str] = Field( + command: str | None = Field( default=None, description="Command passed to the image. Null uses the job name (for " "known jobs) or the image's default entrypoint.", @@ -52,14 +51,14 @@ class JobDefinition(SQLModel, table=True): sa_column=Column(JSON), description="Extra environment variables passed to the container.", ) - schedule: Optional[str] = Field( + schedule: str | None = Field( default=None, description="Cron expression in UTC (e.g. '0 3 * * *'). Null = manual only.", ) enabled: bool = Field( default=True, description="Disabled definitions are never scheduled." ) - next_run_at: Optional[datetime] = Field( + next_run_at: datetime | None = Field( default=None, description="Computed by the scheduler from the cron expression." ) created_at: datetime = Field(default_factory=utcnow) @@ -68,19 +67,19 @@ class JobDefinition(SQLModel, table=True): class JobRun(SQLModel, table=True): __tablename__ = "background_job_run" - id: Optional[int] = Field(default=None, primary_key=True) + id: int | None = Field(default=None, primary_key=True) definition_id: int = Field( foreign_key="background_job_definition.id", index=True ) - container_id: Optional[str] = Field(default=None) + container_id: str | None = Field(default=None) status: JobRunStatus = Field(default=JobRunStatus.RUNNING) triggered_by: JobTriggeredBy = Field( description="Whether the scheduler or a superadmin started this run." ) started_at: datetime = Field(default_factory=utcnow) - finished_at: Optional[datetime] = Field(default=None) - exit_code: Optional[int] = Field(default=None) - logs: Optional[str] = Field( + finished_at: datetime | None = Field(default=None) + exit_code: int | None = Field(default=None) + logs: str | None = Field( default=None, description="Captured stdout/stderr, filled in when the run finishes " "(the container itself is removed afterwards).", @@ -89,24 +88,24 @@ class JobRun(SQLModel, table=True): class JobDefinitionCreateRequest(BaseModel): name: str - image: Optional[str] = None - command: Optional[str] = None + image: str | None = None + command: str | None = None env: dict[str, str] = {} description: str = "" target_index: str = "" - schedule: Optional[str] = None + schedule: str | None = None enabled: bool = True class JobDefinitionUpdateRequest(BaseModel): - name: Optional[str] = None - image: Optional[str] = None - command: Optional[str] = None - env: Optional[dict[str, str]] = None - description: Optional[str] = None - target_index: Optional[str] = None - schedule: Optional[str] = None - enabled: Optional[bool] = None + name: str | None = None + image: str | None = None + command: str | None = None + env: dict[str, str] | None = None + description: str | None = None + target_index: str | None = None + schedule: str | None = None + enabled: bool | None = None class BackgroundJobTask(BaseModel): @@ -114,13 +113,13 @@ class BackgroundJobTask(BaseModel): name: str description: str target_index: str - image: Optional[str] - command: Optional[str] + image: str | None + command: str | None env: dict[str, str] - schedule: Optional[str] + schedule: str | None enabled: bool - next_run_at: Optional[datetime] - last_run: Optional[JobRun] + next_run_at: datetime | None + last_run: JobRun | None status: str diff --git a/service/src/main/inse/background_jobs/router.py b/service/src/main/inse/background_jobs/router.py index 57b3704b..283214ab 100644 --- a/service/src/main/inse/background_jobs/router.py +++ b/service/src/main/inse/background_jobs/router.py @@ -11,11 +11,11 @@ from .model import ( AvailableImages, BackgroundJobTask, DockerHealth, - RegistryHealth, JobDefinitionCreateRequest, JobDefinitionUpdateRequest, JobRun, JobRunLogs, + RegistryHealth, ) router = APIRouter(prefix="/api/background-jobs", tags=[Tags.BACKGROUND_JOBS]) diff --git a/service/src/main/inse/background_jobs/runner.py b/service/src/main/inse/background_jobs/runner.py index 8e964f5e..813417dd 100644 --- a/service/src/main/inse/background_jobs/runner.py +++ b/service/src/main/inse/background_jobs/runner.py @@ -8,7 +8,6 @@ import logging import re from datetime import datetime from threading import RLock -from typing import Optional import docker import httpx @@ -28,7 +27,7 @@ settings = config.get_settings() RUN_STATE_LOCK = RLock() -_client: Optional[docker.DockerClient] = None +_client: docker.DockerClient | None = None def get_docker_client() -> docker.DockerClient: @@ -42,7 +41,7 @@ def docker_reachable() -> tuple[bool, str]: try: get_docker_client().ping() return True, "ok" - except Exception as error: # noqa: BLE001 + except Exception as error: return False, str(error) @@ -59,7 +58,7 @@ def registry_reachable() -> tuple[bool, str]: if response.status_code == 401: return False, "authentication failed (401)" return False, f"unexpected status {response.status_code}" - except Exception as error: # noqa: BLE001 + except Exception as error: return False, str(error) @@ -110,23 +109,23 @@ def list_registry_images() -> tuple[list[str], str]: response = client.get(f"{base}/v2/{repository}/tags/list") response.raise_for_status() tags = response.json().get("tags") or [] - except Exception: # noqa: BLE001 + except Exception: tags = [] if tags: images.extend(f"{host}/{repository}:{tag}" for tag in tags) else: images.append(f"{host}/{repository}") return sorted(images), "" - except Exception as error: # noqa: BLE001 + except Exception as error: logger.warning("Could not list registry images.", exc_info=True) return [], str(error) -def resolve_image(definition: JobDefinition) -> Optional[str]: +def resolve_image(definition: JobDefinition) -> str | None: return definition.image or None -def is_registry_image(image: Optional[str]) -> bool: +def is_registry_image(image: str | None) -> bool: return bool(image) and image.split("/", 1)[0] == registry_host() @@ -151,7 +150,7 @@ def resolve_environment(definition: JobDefinition) -> dict[str, str]: return {**base, **(definition.env or {})} -def registry_auth() -> Optional[dict[str, str]]: +def registry_auth() -> dict[str, str] | None: if ( settings.background_jobs_registry_username and settings.background_jobs_registry_password @@ -189,7 +188,7 @@ def start_run( if settings.background_jobs_pull_before_run and is_registry_image(image): try: pull_image(image) - except Exception as error: # noqa: BLE001 + except Exception as error: run.status = JobRunStatus.FAILED run.finished_at = utcnow() run.logs = ( @@ -211,7 +210,7 @@ def start_run( remove=False, ) run.container_id = container.id - except Exception as error: # noqa: BLE001 + except Exception as error: run.status = JobRunStatus.FAILED run.finished_at = utcnow() run.logs = ( @@ -241,8 +240,8 @@ def schedule_due_jobs(session: Session) -> None: now = utcnow() scheduled = session.exec( select(JobDefinition).where( - JobDefinition.enabled == True, # noqa: E712 - JobDefinition.schedule != None, # noqa: E711 + JobDefinition.enabled == True, + JobDefinition.schedule != None, ) ).all() @@ -276,8 +275,8 @@ def finalize_run( *, new_status: JobRunStatus, expected_status: JobRunStatus = JobRunStatus.RUNNING, - exit_code: Optional[int] = None, - logs: Optional[str] = None, + exit_code: int | None = None, + logs: str | None = None, ) -> bool: values: dict = {"status": new_status, "finished_at": utcnow()} if exit_code is not None: @@ -300,7 +299,7 @@ def append_system_log(logs: str, message: str) -> str: def remove_container(container, run_id: int) -> None: try: container.remove() - except Exception: # noqa: BLE001 + except Exception: logger.warning( "Could not remove container for run %s.", run_id, exc_info=True ) @@ -371,6 +370,6 @@ async def scheduler_loop() -> None: while True: try: await asyncio.to_thread(tick) - except Exception: # noqa: BLE001 + except Exception: logger.exception("Background job scheduler tick failed.") await asyncio.sleep(settings.background_jobs_tick_seconds) diff --git a/service/src/main/inse/background_jobs/service.py b/service/src/main/inse/background_jobs/service.py index 9f27b30e..32049d65 100644 --- a/service/src/main/inse/background_jobs/service.py +++ b/service/src/main/inse/background_jobs/service.py @@ -17,7 +17,6 @@ from .model import ( AvailableImages, BackgroundJobTask, DockerHealth, - RegistryHealth, JobDefinition, JobDefinitionCreateRequest, JobDefinitionUpdateRequest, @@ -25,6 +24,7 @@ from .model import ( JobRunLogs, JobRunStatus, JobTriggeredBy, + RegistryHealth, utcnow, ) @@ -289,7 +289,7 @@ def get_run_logs( "utf-8", errors="replace" ), ) - except Exception: # noqa: BLE001 + except Exception: pass return JobRunLogs( run_id=run_id, status=run.status, logs=_tail_log_lines(run.logs or "") @@ -319,7 +319,7 @@ def stop_run( status_code=status.HTTP_409_CONFLICT, detail=f"Container for run {run_id} no longer exists.", ) from error - except Exception as error: # noqa: BLE001 + except Exception as error: logger.warning( "Could not inspect run %s before stopping.", run_id, exc_info=True ) @@ -340,7 +340,7 @@ def stop_run( status_code=status.HTTP_502_BAD_GATEWAY, detail=f"Could not stop container for run {run_id}.", ) from error - except Exception as error: # noqa: BLE001 + except Exception as error: logger.warning("Could not stop run %s.", run_id, exc_info=True) raise HTTPException( status_code=status.HTTP_502_BAD_GATEWAY, diff --git a/service/src/main/inse/bookmarks/model.py b/service/src/main/inse/bookmarks/model.py index ab1f6846..be49f305 100644 --- a/service/src/main/inse/bookmarks/model.py +++ b/service/src/main/inse/bookmarks/model.py @@ -1,7 +1,8 @@ import uuid -from datetime import datetime, timezone +from datetime import UTC, datetime -from pydantic import BaseModel, Field as PydanticField +from pydantic import BaseModel +from pydantic import Field as PydanticField from sqlalchemy import UniqueConstraint from sqlmodel import Field, SQLModel @@ -21,7 +22,7 @@ class PersonBookmark(SQLModel, table=True): person_id: str = Field(nullable=False, index=True) person_name: str | None = Field(default=None) created_at: datetime = Field( - default_factory=lambda: datetime.now(timezone.utc), nullable=False, index=True + default_factory=lambda: datetime.now(UTC), nullable=False, index=True ) diff --git a/service/src/main/inse/bookmarks/router.py b/service/src/main/inse/bookmarks/router.py index 5f12e547..d0d590f5 100644 --- a/service/src/main/inse/bookmarks/router.py +++ b/service/src/main/inse/bookmarks/router.py @@ -7,7 +7,6 @@ from inse.database import SessionDep from . import service from .model import CreatePersonBookmark, PersonBookmarkResponse - router = APIRouter(prefix="/api/bookmarks", tags=["Bookmarks"]) diff --git a/service/src/main/inse/company_connections/logic.py b/service/src/main/inse/company_connections/logic.py index 14ccae33..7cb142c5 100644 --- a/service/src/main/inse/company_connections/logic.py +++ b/service/src/main/inse/company_connections/logic.py @@ -1,9 +1,10 @@ import logging from typing import Any -from . import model from inse.authors.v2.service import author_currently_belongs_to_institution from inse.exceptions import NotFoundException + +from . import model from .search_client import CompanyConnectionsSearchClient logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/company_connections/search_client.py b/service/src/main/inse/company_connections/search_client.py index 3e391ac8..43b64f3d 100644 --- a/service/src/main/inse/company_connections/search_client.py +++ b/service/src/main/inse/company_connections/search_client.py @@ -1,14 +1,10 @@ from typing import Any -from .. import config - - +from inse.exceptions import ElasticsearchNotFoundException from inse.integrations import elasticsearch from inse.model import ESCluster -from inse.exceptions import ElasticsearchNotFoundException - -from inse.exceptions import MissingApiKeyError +from .. import config class CompanyConnectionsSearchClient: diff --git a/service/src/main/inse/company_connections/service.py b/service/src/main/inse/company_connections/service.py index 19bef518..de682140 100644 --- a/service/src/main/inse/company_connections/service.py +++ b/service/src/main/inse/company_connections/service.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for possible company connections of OpenAlex authors. """ diff --git a/service/src/main/inse/config.py b/service/src/main/inse/config.py index 6075aa8b..d63ea508 100644 --- a/service/src/main/inse/config.py +++ b/service/src/main/inse/config.py @@ -1,17 +1,16 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ This module contains the configuration properties that can be adjusted via environment variables. """ -from functools import lru_cache import logging +from functools import lru_cache from pathlib import Path -from typing import Dict, List, Literal, Optional -from pydantic_settings import BaseSettings, SettingsConfigDict -from dotenv import load_dotenv +from typing import Literal +from dotenv import load_dotenv +from pydantic_settings import BaseSettings, SettingsConfigDict logger = logging.getLogger(__name__) @@ -35,17 +34,17 @@ class Settings(BaseSettings): openalex_works_search_timeout_seconds: float = 30.0 # OpenAlex public API config openalex_api_base_url: str = "https://api.openalex.org" - openalex_api_key: Optional[str] = None + openalex_api_key: str | None = None openalex_api_timeout_seconds: float = 30.0 # Patent Elasticsearch config patent_elasticsearch_url: str = "https://inse.nes.uni-due.de/elastic" - patent_elasticsearch_api_key: Optional[str] = None + patent_elasticsearch_api_key: str | None = None # LLM config - llm_api_url: Optional[str] = None - llm_api_key: Optional[str] = None - llm_model: Optional[str] = None + llm_api_url: str | None = None + llm_api_key: str | None = None + llm_model: str | None = None # Background job runner config (Docker-out-of-Docker) background_jobs_image: str = "docker.nes.uni-due.de/inse/background-jobs:latest" @@ -58,25 +57,25 @@ class Settings(BaseSettings): # Credentials for pulling the job image from a private registry (e.g. the # Nexus at docker.nes.uni-due.de). Needed because the runner pulls via the # Docker SDK inside the service container, which has no `docker login` creds. - background_jobs_registry_username: Optional[str] = None - background_jobs_registry_password: Optional[str] = None + background_jobs_registry_username: str | None = None + background_jobs_registry_password: str | None = None # Sentence Transformers config sentence_transformers_model_name: str = "intfloat/multilingual-e5-base" # Elasticsearch config elasticsearch_url: str = "https://project.nes.uni-due.de/elastic" - elasticsearch_api_key: Optional[str] = None - elasticsearch_inse_url: Optional[str] = None - elasticsearch_inse_api_key: Optional[str] = None + elasticsearch_api_key: str | None = None + elasticsearch_inse_url: str | None = None + elasticsearch_inse_api_key: str | None = None print_es_queries: bool = False print_es_timings: bool = False model_config = SettingsConfigDict(env_file=str(ENV_FILE)) - allowed_origins: List[str] = ["http://localhost:4200"] + allowed_origins: list[str] = ["http://localhost:4200"] - servers: List[Dict[str, str]] = [ + servers: list[dict[str, str]] = [ {"url": "http://localhost:8000", "description": "Local development server"}, ] @@ -84,8 +83,8 @@ class Settings(BaseSettings): environment: Literal["dev", "prod"] = "dev" - token_issuer_id: Optional[str] = None - token_hmac_key: Optional[str] = None + token_issuer_id: str | None = None + token_hmac_key: str | None = None skip_otk_validation: bool = True # SMTP / email config @@ -95,8 +94,8 @@ class Settings(BaseSettings): smtp_server: str = "localhost" smtp_port: int = 25 smtp_sender: str = "no-reply@smartguide.local" - smtp_username: Optional[str] = None - smtp_password: Optional[str] = None + smtp_username: str | None = None + smtp_password: str | None = None smtp_use_tls: bool = False diff --git a/service/src/main/inse/dashboard/router.py b/service/src/main/inse/dashboard/router.py index d481f7cb..bd5ad49b 100644 --- a/service/src/main/inse/dashboard/router.py +++ b/service/src/main/inse/dashboard/router.py @@ -10,8 +10,8 @@ from inse.tags import Tags from .model import ( BmbfProjectStatusStatistics, - DashboardStatisticValue, DashboardStatistics, + DashboardStatisticValue, DfgProjectStatusStatistics, DfgProjectTopics, EuProjectStatusStatistics, @@ -22,11 +22,11 @@ from .model import ( from .service import ( get_dashboard_bmbf_project_statuses, get_dashboard_bmbf_projects, - get_dashboard_dfg_projects, get_dashboard_dfg_project_statuses, + get_dashboard_dfg_projects, get_dashboard_dfg_topics, - get_dashboard_eu_projects, get_dashboard_eu_project_statuses, + get_dashboard_eu_projects, get_dashboard_organization, get_dashboard_patents, get_dashboard_persons, diff --git a/service/src/main/inse/dashboard/service.py b/service/src/main/inse/dashboard/service.py index 5519dae6..ac7d5f50 100644 --- a/service/src/main/inse/dashboard/service.py +++ b/service/src/main/inse/dashboard/service.py @@ -1,9 +1,9 @@ import asyncio import logging import re -from types import SimpleNamespace from collections import defaultdict from datetime import datetime +from types import SimpleNamespace from typing import Any, Literal from fastapi import HTTPException, status @@ -14,20 +14,30 @@ from inse.auth.model import AccessToken, Organization from inse.authors.institution_membership_query import ( build_institution_membership_query, ) -from inse.integrations import elasticsearch from inse.institutions.institutions_search_client import InstitutionsSearchClient +from inse.integrations import elasticsearch from inse.model import ESCluster, ESIndex from inse.patents.org.elastic_search_client import OrgPatentsSearchClient -from inse.projects.dfg_institutions.service import autocomplete_institutions_for_selector +from inse.projects.dfg_institutions.service import ( + autocomplete_institutions_for_selector, +) +from inse.projects.eu_cordis_projects_client import ( + get_eu_project_ids_by_organization_filters, +) from inse.projects.logic import get_person_ids_by_institution_ids +from inse.projects.model import ( + EuCordisProjectType, + ProjectsFilteringProperties, + ProjectType, +) from .institute_helper import get_openalex_institution from .model import ( BmbfProjectStatusStatistics, - DashboardStatisticValue, DashboardStatistics, - DfgProjectTopic, + DashboardStatisticValue, DfgProjectStatusStatistics, + DfgProjectTopic, DfgProjectTopics, EuProjectStatusStatistics, TopAuthor, @@ -40,14 +50,6 @@ from .model import ( TopicWordCloud, TopicWordCloudWord, ) -from inse.projects.eu_cordis_projects_client import ( - get_eu_project_ids_by_organization_filters, -) -from inse.projects.model import ( - EuCordisProjectType, - ProjectType, - ProjectsFilteringProperties, -) TOP_AUTHOR_LIMIT = 10 TOPIC_HEATMAP_LIMIT = 25 diff --git a/service/src/main/inse/dashboard/test_service.py b/service/src/main/inse/dashboard/test_service.py index 96131f40..2e58db2e 100644 --- a/service/src/main/inse/dashboard/test_service.py +++ b/service/src/main/inse/dashboard/test_service.py @@ -1,6 +1,6 @@ -from unittest.mock import AsyncMock, patch from datetime import datetime from types import SimpleNamespace +from unittest.mock import AsyncMock, patch import pytest from fastapi import HTTPException diff --git a/service/src/main/inse/exceptions.py b/service/src/main/inse/exceptions.py index da51e2de..eea6c9de 100644 --- a/service/src/main/inse/exceptions.py +++ b/service/src/main/inse/exceptions.py @@ -10,22 +10,18 @@ class NotFoundException(Exception): class ElasticsearchException(Exception): """Base exception for all Elasticsearch integrations.""" - pass class ElasticsearchNotFoundException(NotFoundException, ElasticsearchException): """Raised when an Elasticsearch document or index is not found.""" - pass class ElasticsearchConnectionException(ElasticsearchException): """Raised when connecting to Elasticsearch fails.""" - pass class MissingApiKeyError(Exception): """Raised when a required API key is missing.""" - pass class UpstreamAPIException(Exception): @@ -38,4 +34,3 @@ class UpstreamAPIException(Exception): class BadRequestException(Exception): """Raised when request parameters are invalid or validation fails.""" - pass diff --git a/service/src/main/inse/funders/__init__.py b/service/src/main/inse/funders/__init__.py index a12699fd..1235c7c2 100644 --- a/service/src/main/inse/funders/__init__.py +++ b/service/src/main/inse/funders/__init__.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Funders domain package. """ diff --git a/service/src/main/inse/funders/elastic_search_client.py b/service/src/main/inse/funders/elastic_search_client.py index 445ae4f0..ccb373fb 100644 --- a/service/src/main/inse/funders/elastic_search_client.py +++ b/service/src/main/inse/funders/elastic_search_client.py @@ -1,16 +1,14 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ HTTP client for funded-publication searches in the OpenAlex works index. """ from typing import Any -from .. import config +from inse.exceptions import MissingApiKeyError from inse.integrations import elasticsearch from inse.model import ESCluster - -from inse.exceptions import MissingApiKeyError +from .. import config class FundedPublicationsSearchClient: diff --git a/service/src/main/inse/funders/logic.py b/service/src/main/inse/funders/logic.py index bad9e46e..24069126 100644 --- a/service/src/main/inse/funders/logic.py +++ b/service/src/main/inse/funders/logic.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Business logic for author funding based on publication works. """ @@ -7,10 +6,14 @@ import logging from typing import Any from pydantic import ValidationError + +from inse.exceptions import ( + UpstreamAPIException, +) + from ..persons import logic as person_logic from . import model from .elastic_search_client import FundedPublicationsSearchClient -from inse.exceptions import MissingApiKeyError, ElasticsearchException, UpstreamAPIException logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/funders/model.py b/service/src/main/inse/funders/model.py index 2f0a2b4b..84dee177 100644 --- a/service/src/main/inse/funders/model.py +++ b/service/src/main/inse/funders/model.py @@ -1,7 +1,6 @@ from typing import Any -from pydantic import BaseModel -from pydantic import Field +from pydantic import BaseModel, Field class PublicationsByAuthorResponse(BaseModel): diff --git a/service/src/main/inse/funders/service.py b/service/src/main/inse/funders/service.py index b6c8c05f..96f57d5b 100644 --- a/service/src/main/inse/funders/service.py +++ b/service/src/main/inse/funders/service.py @@ -1,16 +1,12 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for author publications and funding. """ from typing import Annotated -from fastapi import APIRouter -from fastapi import Query - -from . import logic -from . import model +from fastapi import APIRouter, Query +from . import logic, model router = APIRouter(prefix="/api/inse-service/authors", tags=["Funding"]) diff --git a/service/src/main/inse/funders/test_logic.py b/service/src/main/inse/funders/test_logic.py index 52ff0fdb..700028a2 100644 --- a/service/src/main/inse/funders/test_logic.py +++ b/service/src/main/inse/funders/test_logic.py @@ -1,7 +1,8 @@ -import pytest from unittest.mock import AsyncMock, patch -from inse.exceptions import MissingApiKeyError +import pytest + +from inse.exceptions import MissingApiKeyError from inse.funders import logic from inse.funders.elastic_search_client import FundedPublicationsSearchClient diff --git a/service/src/main/inse/institutions/institutions_search_client.py b/service/src/main/inse/institutions/institutions_search_client.py index af18216e..482194d9 100644 --- a/service/src/main/inse/institutions/institutions_search_client.py +++ b/service/src/main/inse/institutions/institutions_search_client.py @@ -1,13 +1,10 @@ import logging -from typing import List, Set -from typing import Any, Dict, Literal, Optional +from typing import Any, Literal - -from inse.models.openalex.institution import Institution from inse.exceptions import NotFoundException -from inse.integrations import elasticsearch from inse.institutions.model import InstitutionPage - +from inse.integrations import elasticsearch +from inse.models.openalex.institution import Institution logger = logging.getLogger(__name__) @@ -18,7 +15,6 @@ class InstitutionsSearchClient: Initializes the client. Credentials and URLs are handled by the centralized elasticsearch integration. """ - pass async def get_institution_by_id(self, raw_oa_institution_id: str) -> Institution: """Retrieves an institution by its raw OpenAlex institution ID. @@ -56,7 +52,7 @@ class InstitutionsSearchClient: async def get_eu_organisation_id_by_oa_institution_id( self, raw_institution_id: str - ) -> Optional[str]: + ) -> str | None: """Retrieves the corresponding EU organisation ID for a given OpenAlex institution ID, if available. Args: @@ -99,7 +95,7 @@ class InstitutionsSearchClient: else: sort_config.append({"display_name.keyword": {"order": sorting_direction}}) - query: Dict[str, Any] = {"match_all": {}} + query: dict[str, Any] = {"match_all": {}} if len(name) > 0: query = { @@ -136,7 +132,7 @@ class InstitutionsSearchClient: return self.response_to_institution_page(response, page, size) def response_to_institution_page( - self, response: Dict[str, Any], page: int, size: int + self, response: dict[str, Any], page: int, size: int ) -> InstitutionPage: hits = response.get("hits", {}).get("hits", []) @@ -250,7 +246,7 @@ class InstitutionsSearchClient: async def get_institution_aliases_by_oa_institution_id( self, raw_oa_institution_id: str - ) -> List[str]: + ) -> list[str]: """Get a list of institution aliases for a given institution ID, including both display name alternatives and predefined aliases. Args: @@ -273,7 +269,7 @@ class InstitutionsSearchClient: def get_predefined_institution_aliases( self, raw_oa_institution_id: str - ) -> Set[str]: + ) -> set[str]: """Get predefined aliases for a given institution ID. Args: @@ -297,7 +293,7 @@ class InstitutionsSearchClient: set(predefined_aliases.get(raw_oa_institution_id, [])) ) - def augment_aliases(self, aliases: Set[str]) -> Set[str]: + def augment_aliases(self, aliases: set[str]) -> set[str]: """Augment a set of aliases by applying the augment_alias function to each alias. Args: @@ -311,7 +307,7 @@ class InstitutionsSearchClient: augmented_aliases.update(self.augment_alias(alias)) return augmented_aliases - def augment_alias(self, alias: str) -> List[str]: + def augment_alias(self, alias: str) -> list[str]: """Augment an alias by replacing German umlauts and ß with their alternative spellings. Args: @@ -343,7 +339,7 @@ class InstitutionsSearchClient: aliases.append(alias.replace("-", " ")) return aliases - def _convert_hit_to_institution(self, hit: Dict[str, Any]) -> Optional[Institution]: + def _convert_hit_to_institution(self, hit: dict[str, Any]) -> Institution | None: """Convert an Elasticsearch hit to an Institution object, applying necessary data cleaning and validation. Args: @@ -388,7 +384,7 @@ class InstitutionsSearchClient: async def get_cordis_eu_organisation_ids_by_oa_institution_id( self, raw_oa_institution_id: str - ) -> Optional[List[str]]: + ) -> list[str] | None: """Retrieves the corresponding EU organisation IDs for a given OpenAlex institution ID by searching for institution aliases and matching them against the Cordis EU organisations indices. Args: diff --git a/service/src/main/inse/institutions/logic.py b/service/src/main/inse/institutions/logic.py index d001c646..9e7eeb2e 100644 --- a/service/src/main/inse/institutions/logic.py +++ b/service/src/main/inse/institutions/logic.py @@ -1,26 +1,26 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Business logic for OpenAlex institutions. """ import logging from copy import deepcopy -from typing import Any, Optional +from typing import Any import httpx from pydantic import ValidationError -from inse.exceptions import UpstreamAPIException, BadRequestException +from inse.exceptions import BadRequestException, UpstreamAPIException +from inse.institutions.institutions_search_client import InstitutionsSearchClient from inse.models.openalex.autocomplete_response import AutocompleteResponse from inse.models.openalex.autocomplete_response_meta import AutocompleteResponseMeta from inse.models.openalex.autocomplete_response_results_inner import ( AutocompleteResponseResultsInner, ) -from inse.models.openalex.institutions_list_response import InstitutionsListResponse from inse.models.openalex.institution import Institution +from inse.models.openalex.institutions_list_response import InstitutionsListResponse + from .search_client import OpenAlexInstitutionsClient -from inse.institutions.institutions_search_client import InstitutionsSearchClient logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/institutions/model.py b/service/src/main/inse/institutions/model.py index 0eaf3c61..8ac8f972 100644 --- a/service/src/main/inse/institutions/model.py +++ b/service/src/main/inse/institutions/model.py @@ -1,4 +1,3 @@ -from typing import List from pydantic import BaseModel, Field @@ -6,7 +5,7 @@ from inse.models.openalex.institution import Institution class InstitutionPage(BaseModel): - elements: List[Institution] = Field( + elements: list[Institution] = Field( default_factory=list, description="List of institutions in the current page." ) page: int = Field(default=0, description="Current page number. (0-indexed)") diff --git a/service/src/main/inse/institutions/router.py b/service/src/main/inse/institutions/router.py index 2709e4d9..84c18e8e 100644 --- a/service/src/main/inse/institutions/router.py +++ b/service/src/main/inse/institutions/router.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for OpenAlex institutions. """ @@ -7,16 +6,16 @@ REST API for OpenAlex institutions. from functools import lru_cache from typing import Annotated, Literal -from fastapi import APIRouter, Depends, status, Query +from fastapi import APIRouter, Depends, Query, status +from inse.institutions.institutions_search_client import InstitutionsSearchClient +from inse.institutions.model import InstitutionPage from inse.models.openalex.autocomplete_response import AutocompleteResponse +from inse.models.openalex.institution import Institution from inse.models.openalex.institutions_list_response import InstitutionsListResponse from inse.tags import Tags -from inse.models.openalex.institution import Institution -from inse.institutions.model import InstitutionPage -from . import logic -from inse.institutions.institutions_search_client import InstitutionsSearchClient +from . import logic router = APIRouter(prefix="/api/inse-service/institutions", tags=[Tags.INSTITUTIONS]) diff --git a/service/src/main/inse/institutions/search_client.py b/service/src/main/inse/institutions/search_client.py index 9839e24c..5e9f32f5 100644 --- a/service/src/main/inse/institutions/search_client.py +++ b/service/src/main/inse/institutions/search_client.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ HTTP client for OpenAlex institutions. """ diff --git a/service/src/main/inse/institutions/test_logic.py b/service/src/main/inse/institutions/test_logic.py index 11544b19..cca61dc9 100644 --- a/service/src/main/inse/institutions/test_logic.py +++ b/service/src/main/inse/institutions/test_logic.py @@ -1,7 +1,7 @@ import httpx import pytest -from inse.exceptions import BadRequestException +from inse.exceptions import BadRequestException from inse.institutions import logic from inse.institutions.search_client import OpenAlexInstitutionsClient diff --git a/service/src/main/inse/integrations/elasticsearch.py b/service/src/main/inse/integrations/elasticsearch.py index 05a81575..0ad63956 100644 --- a/service/src/main/inse/integrations/elasticsearch.py +++ b/service/src/main/inse/integrations/elasticsearch.py @@ -1,22 +1,24 @@ import json import logging import time -from typing import Any, Dict, AsyncIterator, List, Optional, Tuple +from collections.abc import AsyncIterator +from typing import Any import httpx from inse.exceptions import ( + ElasticsearchConnectionException, ElasticsearchException, ElasticsearchNotFoundException, - ElasticsearchConnectionException, MissingApiKeyError, ) from inse.model import ESCluster, ESIndex + from .. import config logger = logging.getLogger(__name__) -_client: Optional[httpx.AsyncClient] = None +_client: httpx.AsyncClient | None = None _loop = None @@ -35,7 +37,7 @@ def get_client() -> httpx.AsyncClient: return _client -def _cluster_credentials(cluster: ESCluster) -> Tuple[str, str]: +def _cluster_credentials(cluster: ESCluster) -> tuple[str, str]: """Retrieves the Elasticsearch URL and API key for the specified cluster from the configuration. Args: @@ -75,7 +77,7 @@ def _cluster_credentials(cluster: ESCluster) -> Tuple[str, str]: raise ValueError(f"Unknown cluster: {cluster!r} (allowed: 'nes', 'inse')") -def _index_to_cluster(index: ESIndex) -> Optional[ESCluster]: +def _index_to_cluster(index: ESIndex) -> ESCluster | None: """Determines the Elasticsearch cluster to use based on the specified index. Args: @@ -111,7 +113,7 @@ def _index_to_cluster(index: ESIndex) -> Optional[ESCluster]: return None -def _headers(api_key: str, content_type: str = "application/json") -> Dict[str, str]: +def _headers(api_key: str, content_type: str = "application/json") -> dict[str, str]: return {"Authorization": f"ApiKey {api_key}", "Content-Type": content_type} @@ -135,9 +137,9 @@ async def _request( cluster: ESCluster, path: str, *, - json_body: Optional[Any] = None, - params: Optional[Dict[str, Any]] = None, - content: Optional[bytes] = None, + json_body: Any | None = None, + params: dict[str, Any] | None = None, + content: bytes | None = None, content_type: str = "application/json", ) -> httpx.Response: """Sends an authenticated request to cluster and returns the raw response. @@ -188,18 +190,18 @@ async def _request( async def search( - index: ESIndex | List[ESIndex] | str | List[str], - query: Optional[Dict] = None, - source: Optional[List] = None, - size: Optional[int] = None, - offset: Optional[int] = None, - sort: Optional[List] = None, - aggs: Optional[Dict] = None, - body: Optional[Dict] = None, + index: ESIndex | list[ESIndex] | str | list[str], + query: dict | None = None, + source: list | None = None, + size: int | None = None, + offset: int | None = None, + sort: list | None = None, + aggs: dict | None = None, + body: dict | None = None, track_total_hits=False, - highlight: Optional[Dict] = None, + highlight: dict | None = None, cluster: ESCluster = ESCluster.NES, -) -> Dict[str, Any]: +) -> dict[str, Any]: """Searches the specified Elasticsearch index using either a simple query string or a full query body. Args: @@ -237,7 +239,7 @@ async def search( elif len(clusters) == 1: cluster = clusters.pop() - payload: Dict[str, Any] = {} + payload: dict[str, Any] = {} if body is not None: payload = body @@ -300,22 +302,22 @@ async def close_point_in_time(pit_id: str, cluster: str = "nes") -> None: async def scan( index: str, - query: Dict, - source: Optional[List] = None, + query: dict, + source: list | None = None, page_size: int = 1000, keep_alive: str = "1m", cluster: str = "nes", -) -> AsyncIterator[Dict[str, Any]]: +) -> AsyncIterator[dict[str, Any]]: """Yields every hit matching ``query`` using a point-in-time + ``search_after``. Unlike ``from``/``size`` pagination, this is not bounded by ``index.max_result_window``, so it can stream result sets larger than 10k. """ pit_id = await open_point_in_time(index, keep_alive=keep_alive, cluster=cluster) - search_after: Optional[List] = None + search_after: list | None = None try: while True: - payload: Dict[str, Any] = { + payload: dict[str, Any] = { "size": page_size, "query": query, "pit": {"id": pit_id, "keep_alive": keep_alive}, @@ -351,7 +353,7 @@ async def scan( async def get( index: ESIndex | str, doc_id: str, - source: Optional[list] = None, + source: list | None = None, cluster: ESCluster = ESCluster.NES, ) -> dict[str, Any]: @@ -370,9 +372,9 @@ async def get( async def update( index: str, doc_id: str, - doc: Dict[str, Any], + doc: dict[str, Any], cluster: ESCluster = ESCluster.NES, -) -> Dict[str, Any]: +) -> dict[str, Any]: response = await _request( "POST", cluster, f"{index}/_update/{doc_id}", json_body={"doc": doc} ) @@ -383,9 +385,9 @@ async def update( async def index_doc( index: str, doc_id: str, - document: Dict[str, Any], + document: dict[str, Any], cluster: ESCluster = ESCluster.NES, -) -> Dict[str, Any]: +) -> dict[str, Any]: response = await _request( "PUT", cluster, f"{index}/_doc/{doc_id}", json_body=document ) @@ -394,8 +396,8 @@ async def index_doc( async def count( - index: ESIndex | List[ESIndex] | str | List[str], - query: Optional[Dict[str, Any]] = None, + index: ESIndex | list[ESIndex] | str | list[str], + query: dict[str, Any] | None = None, cluster: ESCluster = ESCluster.NES, ) -> int: """Performs a count request (_count) on the specified Elasticsearch index. @@ -435,9 +437,9 @@ async def count( async def msearch( - searches: List[Tuple[ESIndex | str | List[str], Dict[str, Any]]], + searches: list[tuple[ESIndex | str | list[str], dict[str, Any]]], cluster: ESCluster = ESCluster.NES, -) -> List[Dict[str, Any]]: +) -> list[dict[str, Any]]: """Performs a multi-search request (_msearch) on Elasticsearch. Args: diff --git a/service/src/main/inse/integrations/llm.py b/service/src/main/inse/integrations/llm.py index 101ce92c..7860ad8a 100644 --- a/service/src/main/inse/integrations/llm.py +++ b/service/src/main/inse/integrations/llm.py @@ -1,8 +1,11 @@ -from openai import APIConnectionError -from openai import AsyncOpenAI -from .. import config -from typing import Optional, Dict, Any import asyncio +from typing import Any + +from openai import APIConnectionError, AsyncOpenAI + +from .. import config + + async def call( system_prompt: str, user_prompt: str, @@ -45,7 +48,7 @@ async def call( "Etwas ist schiefgelaufen. Bitte versuche es erneut." ) -def _get_response_format(schema, schema_name: Optional[str] = None) -> Dict[str, Any]: +def _get_response_format(schema, schema_name: str | None = None) -> dict[str, Any]: response_format = { "type": "json_schema", "json_schema": { diff --git a/service/src/main/inse/keywords/extract_text.py b/service/src/main/inse/keywords/extract_text.py index b96a4d6b..92735312 100644 --- a/service/src/main/inse/keywords/extract_text.py +++ b/service/src/main/inse/keywords/extract_text.py @@ -1,10 +1,10 @@ # inse/keywords/file_extraction.py import base64 -import logging -import httpx -from bs4 import BeautifulSoup + # import fitz import io +import logging + from pypdf import PdfReader from pypdf.errors import PdfReadError diff --git a/service/src/main/inse/keywords/logic.py b/service/src/main/inse/keywords/logic.py index b2bdcb2e..f4fbcf32 100644 --- a/service/src/main/inse/keywords/logic.py +++ b/service/src/main/inse/keywords/logic.py @@ -1,39 +1,40 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Business logic for persons / authors. """ import asyncio -from typing import Any, Dict, List - -import partial_json_parser import json import logging import time +from collections.abc import Awaitable, Callable +from typing import Any + import httpx +import partial_json_parser from bs4 import BeautifulSoup from pydantic import ValidationError -from typing import Awaitable, Callable -from inse.keywords.prompts import KeywordsPrompt + from inse.integrations import llm +from inse.keywords.extract_text import extract_text_from_upload from inse.keywords.model import ( ExtractedKeywords, ExtractedKeywordsLLM, ExtractedKeywordsResponse, + FileUpload, KeywordEntry, KeywordEntryWithTopic, KeywordsWsEvent, - FileUpload, ) -from inse.keywords.extract_text import extract_text_from_upload +from inse.keywords.prompts import KeywordsPrompt from inse.topics.logic import vector_search_topics_batch + logger = logging.getLogger(__name__) EventCallback = Callable[[dict], Awaitable[None]] LEVELS = ("broad_keywords", "coarse_grained", "fine_grained") def _build_enriched_snapshot( - confirmed: Dict[str, List[KeywordEntryWithTopic]], + confirmed: dict[str, list[KeywordEntryWithTopic]], ) -> ExtractedKeywords: return ExtractedKeywords.model_validate( {level: [item.model_dump() for item in confirmed.get(level, [])] for level in LEVELS} @@ -41,13 +42,13 @@ def _build_enriched_snapshot( async def _enrich_llm_keywords(results: ExtractedKeywordsLLM) -> ExtractedKeywords: - confirmed: Dict[str, List[KeywordEntryWithTopic]] = { + confirmed: dict[str, list[KeywordEntryWithTopic]] = { level: [KeywordEntryWithTopic(llm_keyword=item) for item in getattr(results, level)] for level in LEVELS } - keywords: List[str] = [] - positions: List[tuple[str, int]] = [] + keywords: list[str] = [] + positions: list[tuple[str, int]] = [] for level in LEVELS: for idx, entry in enumerate(getattr(results, level)): keywords.append(entry.keyword) @@ -74,7 +75,7 @@ async def extract_keywords(query: str, mode: str, limit: int) -> ExtractedKeywor text = query - user_prompt = f""" + user_prompt = """ Now analyze the following text and return ONLY the JSON object.\n""" if limit: @@ -105,15 +106,15 @@ async def extract_keywords_stream_enriched( mode: str, limit: int, emit: EventCallback, - files: List[FileUpload] | None = None, + files: list[FileUpload] | None = None, ) -> ExtractedKeywordsResponse: start_time = time.time() timeout_seconds = 120 await emit(KeywordsWsEvent(type="status", step="started", message="Starte Keyword-Extraktion").model_dump()) LEVELS = ("broad_keywords", "coarse_grained", "fine_grained") - confirmed: Dict[str, List[KeywordEntryWithTopic]] = {level: [] for level in LEVELS} - enrichment_tasks: List[asyncio.Task] = [] + confirmed: dict[str, list[KeywordEntryWithTopic]] = {level: [] for level in LEVELS} + enrichment_tasks: list[asyncio.Task] = [] async def emit_full_results() -> None: try: @@ -136,7 +137,7 @@ async def extract_keywords_stream_enriched( logger.error(f"Error fetching OpenAlex topic for keyword '{item.keyword}': {e}") await emit_full_results() - def make_on_chunk(base_offset: Dict[str, int]): + def make_on_chunk(base_offset: dict[str, int]): """ Builds an on_chunk callback for a single streaming LLM call. @@ -147,7 +148,7 @@ async def extract_keywords_stream_enriched( (one per file). """ - async def on_chunk(event: Dict[str, Any]) -> None: + async def on_chunk(event: dict[str, Any]) -> None: if event["type"] != "llm_chunk": await emit(event) return @@ -206,7 +207,7 @@ async def extract_keywords_stream_enriched( on_chunk = make_on_chunk(base_offset) full_content_holder = {"value": ""} - async def emit_wrapper(event: Dict[str, Any]) -> None: + async def emit_wrapper(event: dict[str, Any]) -> None: if event["type"] == "llm_chunk": full_content_holder["value"] += event["content"] event = {**event, "_full_content": full_content_holder["value"]} @@ -232,7 +233,7 @@ async def extract_keywords_stream_enriched( ), timeout=timeout_seconds, ) - except asyncio.TimeoutError: + except TimeoutError: await emit(KeywordsWsEvent(type="error", message=f"LLM call timed out after {timeout_seconds}s{suffix}").model_dump()) raise RuntimeError(f"LLM streaming call timed out{suffix}") except asyncio.CancelledError: @@ -278,8 +279,8 @@ async def extract_keywords_stream_enriched( ).model_dump() ) - file_texts: List[str] = [] - failed_files: List[str] = [] + file_texts: list[str] = [] + failed_files: list[str] = [] for i, f in enumerate(provided_files, start=1): text = await asyncio.to_thread( diff --git a/service/src/main/inse/keywords/model.py b/service/src/main/inse/keywords/model.py index f8607a7a..8c55af2b 100644 --- a/service/src/main/inse/keywords/model.py +++ b/service/src/main/inse/keywords/model.py @@ -1,14 +1,13 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Data models for persons / authors. """ -from typing import List, Literal from pydantic import BaseModel, Field from inse.topics.model import KeywordTopicMatch + class FileUpload(BaseModel): filename: str = Field(description="The name of the uploaded file.") content_base64: str = Field(description="The base64-encoded content of the uploaded file.") @@ -36,14 +35,14 @@ class KeywordEntryWithTopic(BaseModel): ) class ExtractedKeywords(BaseModel): - broad_keywords: List[KeywordEntryWithTopic] = Field(description="The extracted broad keywords from text.") - coarse_grained: List[KeywordEntryWithTopic] = Field(description="The extracted coarse-grained keywords from text.") - fine_grained: List[KeywordEntryWithTopic] = Field(description="The extracted fine-grained keywords from text.") + broad_keywords: list[KeywordEntryWithTopic] = Field(description="The extracted broad keywords from text.") + coarse_grained: list[KeywordEntryWithTopic] = Field(description="The extracted coarse-grained keywords from text.") + fine_grained: list[KeywordEntryWithTopic] = Field(description="The extracted fine-grained keywords from text.") class ExtractedKeywordsLLM(BaseModel): - broad_keywords: List[KeywordEntry] = Field(description="The extracted broad keywords from text.") - coarse_grained: List[KeywordEntry] = Field(description="The extracted coarse-grained keywords from text.") - fine_grained: List[KeywordEntry] = Field(description="The extracted fine-grained keywords from text.") + broad_keywords: list[KeywordEntry] = Field(description="The extracted broad keywords from text.") + coarse_grained: list[KeywordEntry] = Field(description="The extracted coarse-grained keywords from text.") + fine_grained: list[KeywordEntry] = Field(description="The extracted fine-grained keywords from text.") class ExtractedKeywordsResponse(BaseModel): results_llm: ExtractedKeywordsLLM | None = None diff --git a/service/src/main/inse/keywords/prompts.py b/service/src/main/inse/keywords/prompts.py index adcf9a08..02c08117 100644 --- a/service/src/main/inse/keywords/prompts.py +++ b/service/src/main/inse/keywords/prompts.py @@ -1,4 +1,6 @@ from enum import StrEnum + + class KeywordsPrompt(StrEnum): EXTRACT_KEYWORDS_TEXT_PROMPT = """You are an expert scientific, technical, and innovation intelligence analyst. diff --git a/service/src/main/inse/keywords/service.py b/service/src/main/inse/keywords/service.py index 0b46fbc3..8f1e03a2 100644 --- a/service/src/main/inse/keywords/service.py +++ b/service/src/main/inse/keywords/service.py @@ -1,18 +1,18 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for persons / authors. """ import asyncio +import logging from typing import Annotated from fastapi import APIRouter, Body, WebSocket, WebSocketDisconnect from uvicorn.protocols.utils import ClientDisconnected -from . import logic from inse.keywords.model import ExtractedKeywordsResponse, KeywordsRequest -import logging + +from . import logic logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/logic.py b/service/src/main/inse/logic.py index dbe24899..311ac9f2 100644 --- a/service/src/main/inse/logic.py +++ b/service/src/main/inse/logic.py @@ -1,23 +1,17 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ This module defines the business logic for our web service. """ -from typing import List -import logging import json +import logging -from . import config from inse.integrations import elasticsearch - - from inse.models.openalex.topic import Topic -from inse.models.openalex.topic_subfield import TopicSubfield -from inse.models.openalex.topic_field import TopicField from inse.models.openalex.topic_domain import TopicDomain - +from inse.models.openalex.topic_field import TopicField +from inse.models.openalex.topic_subfield import TopicSubfield logger = logging.getLogger(__name__) @@ -91,7 +85,7 @@ async def build_topic_cache(save_json: bool = True) -> dict: return taxonomy_cache -def get_topics_from_cache(topic_names: List[str]) -> List[Topic]: +def get_topics_from_cache(topic_names: list[str]) -> list[Topic]: """ Given a list of topic names, retrieves their hierarchy information from the cache and returns a list of Topic models. Arguments: @@ -123,7 +117,7 @@ def get_topics_from_cache(topic_names: List[str]) -> List[Topic]: return topics -def count_topic_hierarchy(topic_names: List[str]) -> dict: +def count_topic_hierarchy(topic_names: list[str]) -> dict: """ Given a list of topic names, counts the occurrences of each topic and their hierarchy levels (subfield, field, domain) using the cache. Arguments: diff --git a/service/src/main/inse/main.py b/service/src/main/inse/main.py index 07750aed..c25144ab 100644 --- a/service/src/main/inse/main.py +++ b/service/src/main/inse/main.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python + """ This module contains the bootstrapping code for fastapi that loads the service and the @@ -51,8 +51,8 @@ from inse.patents.service import ( router as patents_service_router, ) from inse.persons.service import router as persons_service_router -from inse.projects.dfg_institutions.router import router as dfg_institutions_router from inse.projects.bund_institutions.router import router as bund_institutions_router +from inse.projects.dfg_institutions.router import router as dfg_institutions_router from inse.projects.dfg_persons.router import router as dfg_persons_router from inse.projects.eu_organizations.router import router as eu_organizations_router from inse.projects.router import router as projects_router diff --git a/service/src/main/inse/middleware/test_etag_cache.py b/service/src/main/inse/middleware/test_etag_cache.py index 72108082..2ae09207 100644 --- a/service/src/main/inse/middleware/test_etag_cache.py +++ b/service/src/main/inse/middleware/test_etag_cache.py @@ -1,6 +1,5 @@ from fastapi import FastAPI from fastapi.testclient import TestClient - from inse.middleware.etag_cache import ETagCacheMiddleware diff --git a/service/src/main/inse/model.py b/service/src/main/inse/model.py index 039a1367..e1f0d3aa 100644 --- a/service/src/main/inse/model.py +++ b/service/src/main/inse/model.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ This module defines the model classes returned from our api using pydantic. @@ -17,12 +16,9 @@ else: return self.value -from pydantic import BaseModel -from pydantic import Field -from typing import List -from typing import TypeVar -from typing import Generic +from typing import Generic, TypeVar +from pydantic import BaseModel, Field T = TypeVar("T", bound=BaseModel) @@ -30,7 +26,7 @@ T = TypeVar("T", bound=BaseModel) class Page(BaseModel, Generic[T]): """A generic page model that represents a paginated response containing elements of type T.""" - elements: List[T] = Field(default=[], description="The elements of the page.") + elements: list[T] = Field(default=[], description="The elements of the page.") page: int = Field(default=0, description="The page number. (0-based)") size: int = Field(default=20, description="The page size in elements.") total: int = Field(default=0, description="The total number of elements.") diff --git a/service/src/main/inse/models/bund_project.py b/service/src/main/inse/models/bund_project.py index 6599ed41..5de9413c 100644 --- a/service/src/main/inse/models/bund_project.py +++ b/service/src/main/inse/models/bund_project.py @@ -1,10 +1,10 @@ -from datetime import datetime, date -from typing import Annotated, Optional +from datetime import date, datetime +from typing import Annotated from pydantic import BaseModel, BeforeValidator, ConfigDict, Field -def parse_german_date(value: Optional[str]) -> Optional[date]: +def parse_german_date(value: str | None) -> date | None: if value is None or isinstance(value, date): return value @@ -17,98 +17,98 @@ class BundProject(BaseModel): extra="ignore", ) - funding_code: Optional[str] = Field( + funding_code: str | None = Field( default=None, validation_alias="Förderkennzeichen", description="The funding code of the project", examples=["19F2266G"], ) - department: Optional[str] = Field( + department: str | None = Field( default=None, validation_alias="Ressort", description="The department of the project", examples=["BMDV"], ) - department_fullname: Optional[str] = Field( + department_fullname: str | None = Field( default=None, validation_alias="Ressort_fullname", description="The full name of the department of the project", examples=["Bundesministerium für Digitales und Verkehr"], ) - referat: Optional[str] = Field( + referat: str | None = Field( default=None, validation_alias="Referat", description="The referat of the project", examples=["DP20"], ) - project_sponsor: Optional[str] = Field( + project_sponsor: str | None = Field( default=None, validation_alias="Projektträger", description="The project sponsor of the project", examples=["PT-TÜV"], ) - project_sponsor_fullname: Optional[str] = Field( + project_sponsor_fullname: str | None = Field( default=None, validation_alias="Projektträger_fullname", description="The full name of the project sponsor of the project", examples=["Projektträger TÜV Rheinland"], ) - work_unit: Optional[str] = Field( + work_unit: str | None = Field( default=None, validation_alias="Arb.-Einh.", description="The work unit of the project", examples=["mFUND"], ) - recipient: Optional[str] = Field( + recipient: str | None = Field( default=None, validation_alias="Zuwendungsempfänger", description="The recipient of the project", examples=["Universität Duisburg-Essen"], ) - municipal_code: Optional[str] = Field( + municipal_code: str | None = Field( default=None, validation_alias="Gemeindekennziffer", description="The municipal code of the project", examples=["05113000"], ) - municipality: Optional[str] = Field( + municipality: str | None = Field( default=None, validation_alias="Stadt/Gemeinde", description="The municipality of the project", examples=["Essen"], ) - place: Optional[str] = Field( + place: str | None = Field( default=None, validation_alias="Ort", description="The place of the project", examples=["Essen"], ) - state: Optional[str] = Field( + state: str | None = Field( default=None, validation_alias="Bundesland", description="The state of the project", examples=["Nordrhein-Westfalen"], ) - country: Optional[str] = Field( + country: str | None = Field( default=None, validation_alias="Staat", description="The country of the project", examples=["Deutschland"], ) - implementing_agency: Optional[str] = Field( + implementing_agency: str | None = Field( default=None, validation_alias="Ausführende Stelle", description="The implementing agency of the project", @@ -117,7 +117,7 @@ class BundProject(BaseModel): ], ) - topic: Optional[str] = Field( + topic: str | None = Field( default=None, validation_alias="Thema", description="The topic of the project", @@ -126,14 +126,14 @@ class BundProject(BaseModel): ], ) - performance_plan_system: Optional[str] = Field( + performance_plan_system: str | None = Field( default=None, validation_alias="Leistungsplansystematik", description="The performance plan system of the project", examples=["GA6011"], ) - performance_plan_system_text: Optional[str] = Field( + performance_plan_system_text: str | None = Field( default=None, validation_alias="Klartext Leistungsplansystematik", description="The performance plan system text of the project", @@ -141,7 +141,7 @@ class BundProject(BaseModel): ) funding_start: Annotated[ - Optional[date], + date | None, Field( default=None, validation_alias="Förderbeginn", @@ -152,7 +152,7 @@ class BundProject(BaseModel): ] funding_end: Annotated[ - Optional[date], + date | None, Field( default=None, validation_alias="Förderende", @@ -162,63 +162,63 @@ class BundProject(BaseModel): BeforeValidator(parse_german_date), ] - grant_amount: Optional[float] = Field( + grant_amount: float | None = Field( default=None, validation_alias="Fördersumme", description="The grant amount of the project", examples=[367651.00], ) - funding_profile: Optional[str] = Field( + funding_profile: str | None = Field( default=None, validation_alias="Förderprofil", description="The funding profile of the project", examples=["Technologie- und Innovationsförderung"], ) - joint_project: Optional[str] = Field( + joint_project: str | None = Field( default=None, validation_alias="Verbundprojekt", description="Whether the project is a joint project", examples=["Moby_Dex"], ) - funding_type: Optional[str] = Field( + funding_type: str | None = Field( default=None, validation_alias="Förderart", description="The funding type of the project", examples=["PDIR"], ) - publication_date: Optional[str] = Field( + publication_date: str | None = Field( default=None, validation_alias="Publikationsdatum", description="The publication date of the project", examples=["2023"], ) - unix_timestamp: Optional[int] = Field( + unix_timestamp: int | None = Field( default=None, validation_alias="Unix-Timestamp", description="The unix timestamp of the project", examples=[1737411518], ) - date: Optional[str] = Field( + date: str | None = Field( default=None, validation_alias="datum", description="The date of the project", examples=["20.01.2025"], ) - new: Optional[bool] = Field( + new: bool | None = Field( default=None, validation_alias="neu", description="Whether the project is new", examples=[False], ) - duration: Optional[str] = Field( + duration: str | None = Field( default=None, validation_alias="Laufzeit", description="The duration of the project", diff --git a/service/src/main/inse/models/bund_project_details.py b/service/src/main/inse/models/bund_project_details.py index 851f9f20..7889f475 100644 --- a/service/src/main/inse/models/bund_project_details.py +++ b/service/src/main/inse/models/bund_project_details.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Bund Project Clean Model @@ -8,10 +7,12 @@ """ from datetime import date, datetime -from typing import Optional, List, Set, Any, Dict -from inse.models.openalex.topic import Topic, TopicDomain, TopicField, TopicSubfield +from typing import Any + from pydantic import BaseModel, ConfigDict, Field, field_validator +from inse.models.openalex.topic import Topic, TopicDomain, TopicField, TopicSubfield + class BundProjectDetails(BaseModel): """ @@ -26,170 +27,170 @@ class BundProjectDetails(BaseModel): # Core identifiers id: str = Field(description="The ID of the Bund project") - funding_reference: Optional[str] = Field( + funding_reference: str | None = Field( default=None, description="The funding reference number (Förderkennzeichen)", ) # Project metadata - title: Optional[str] = Field( + title: str | None = Field( default=None, description="The project topic/title", ) - description: Optional[str] = Field( + description: str | None = Field( default=None, description="Plain text description of the performance plan classification", ) - joint_project: Optional[str] = Field( + joint_project: str | None = Field( default=None, description="Parent joint project if this is a sub-project", ) # Funding information - funding_type: Optional[str] = Field( + funding_type: str | None = Field( default=None, description="Type of funding (Förderart)", ) - funding_profile: Optional[str] = Field( + funding_profile: str | None = Field( default=None, description="Funding profile (Förderprofil)", ) - funding_amount: Optional[float] = Field( + funding_amount: float | None = Field( default=None, description="Funding amount in EUR", ) - funding_start_date: Optional[date] = Field( + funding_start_date: date | None = Field( default=None, description="Funding start date", ) - funding_end_date: Optional[date] = Field( + funding_end_date: date | None = Field( default=None, description="Funding end date", ) - duration: Optional[str] = Field( + duration: str | None = Field( default=None, description="Project duration (Laufzeit)", ) # Classification - performance_plan_code: Optional[str] = Field( + performance_plan_code: str | None = Field( default=None, description="Performance plan classification code", ) - performance_plan_fullname: Optional[str] = Field( + performance_plan_fullname: str | None = Field( default=None, description="Full name of the performance plan classification", ) # Organizational - executing_agency: Optional[str] = Field( + executing_agency: str | None = Field( default=None, description="Executing agency", ) - funding_recipient: Optional[str] = Field( + funding_recipient: str | None = Field( default=None, description="Funding recipient", ) - project_agency: Optional[str] = Field( + project_agency: str | None = Field( default=None, description="Project management agency", ) - project_agency_fullname: Optional[str] = Field( + project_agency_fullname: str | None = Field( default=None, description="Full name of the project management agency", ) # Government hierarchy - department: Optional[str] = Field( + department: str | None = Field( default=None, description="Government department code", ) - department_fullname: Optional[str] = Field( + department_fullname: str | None = Field( default=None, description="Full name of the government department", ) - division: Optional[str] = Field( + division: str | None = Field( default=None, description="Division/unit reference", ) # Location - location: Optional[str] = Field( + location: str | None = Field( default=None, description="Location/city", ) - municipality: Optional[str] = Field( + municipality: str | None = Field( default=None, description="City/Municipality", ) - state: Optional[str] = Field( + state: str | None = Field( default=None, description="Federal state", ) - country: Optional[str] = Field( + country: str | None = Field( default=None, description="Country", ) - municipality_code: Optional[str] = Field( + municipality_code: str | None = Field( default=None, description="Municipality code", ) # Publication - publication_date: Optional[str] = Field( + publication_date: str | None = Field( default=None, description="Publication date", ) # Additional - is_new: Optional[bool] = Field( + is_new: bool | None = Field( default=None, description="Flag indicating if the project is new", ) - record_date: Optional[str] = Field( + record_date: str | None = Field( default=None, description="Record date", ) - unix_timestamp: Optional[int] = Field( + unix_timestamp: int | None = Field( default=None, description="Unix timestamp of the record", ) # Unified lists for aggregation - associated_persons: List[str] = Field( + associated_persons: list[str] = Field( default_factory=list, description="All persons associated with the Bund project (from nested Arb object)", ) - institutions: List[str] = Field( + institutions: list[str] = Field( default_factory=list, description="All institutions associated with the Bund project", ) - oa_topics: Optional[List[Topic]] = Field( + oa_topics: list[Topic] | None = Field( default_factory=list, description="OpenAlex topics associated with the Bund project", ) @@ -198,7 +199,7 @@ class BundProjectDetails(BaseModel): @field_validator("funding_amount", mode="before") @classmethod - def parse_funding_amount(cls, v: Any) -> Optional[float]: + def parse_funding_amount(cls, v: Any) -> float | None: """Parse funding amount from string or number.""" if v is None: return None @@ -215,7 +216,7 @@ class BundProjectDetails(BaseModel): @field_validator("funding_start_date", "funding_end_date", mode="before") @classmethod - def parse_german_date(cls, v: Any) -> Optional[date]: + def parse_german_date(cls, v: Any) -> date | None: """Parse date from German format (dd.MM.yyyy) or date/datetime object.""" if v is None: return None @@ -244,7 +245,7 @@ class BundProjectDetails(BaseModel): @field_validator("is_new", mode="before") @classmethod - def parse_is_new(cls, v: Any) -> Optional[bool]: + def parse_is_new(cls, v: Any) -> bool | None: """Parse is_new from bool or string.""" if v is None: return None @@ -258,7 +259,7 @@ class BundProjectDetails(BaseModel): @field_validator("unix_timestamp", mode="before") @classmethod - def parse_unix_timestamp(cls, v: Any) -> Optional[int]: + def parse_unix_timestamp(cls, v: Any) -> int | None: """Parse unix timestamp from int, float, or string.""" if v is None: return None @@ -279,7 +280,7 @@ class BundProjectDetails(BaseModel): source = hit.get("_source", {}) # --- Extract persons from nested Arb object --- - persons: Set[str] = set() + persons: set[str] = set() arb = source.get("Arb") if arb and isinstance(arb, dict): for key, value in arb.items(): @@ -290,14 +291,14 @@ class BundProjectDetails(BaseModel): persons.add(person) # --- Extract institutions --- - institutions: Set[str] = set() + institutions: set[str] = set() inst_fields = [ "Ausführende Stelle", "Zuwendungsempfänger", "Projektträger", ] for field in inst_fields: - if field in source and source[field]: + if source.get(field): for inst in source[field].split(";"): inst = inst.strip() if inst: @@ -351,7 +352,7 @@ class BundProjectDetails(BaseModel): oa_topics=oa_topics ) @staticmethod - def _topic_from_match(match: Dict[str, Any]) -> Topic: + def _topic_from_match(match: dict[str, Any]) -> Topic: """Builds a Topic model from a flattened topic_match dict. """ domain_name = match.get("domain") diff --git a/service/src/main/inse/models/cordis_eu_project.py b/service/src/main/inse/models/cordis_eu_project.py index 557dfd57..66d2f9ed 100644 --- a/service/src/main/inse/models/cordis_eu_project.py +++ b/service/src/main/inse/models/cordis_eu_project.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Optional, List, Union + from pydantic import BaseModel, Field @@ -7,54 +7,54 @@ class CordisEuProject(BaseModel): id: str = Field( description="Unique identifier for the project, typically the CORDIS ID" ) - rcn: Optional[str] = Field( + rcn: str | None = Field( None, description="Research and Innovation project number (CORDIS RCN)" ) - acronym: Optional[str] = Field(None, description="Acronym for the project") - title: Optional[str] = Field(None, description="Title of the project") - objective: Optional[str] = Field(None, description="Objective of the project") + acronym: str | None = Field(None, description="Acronym for the project") + title: str | None = Field(None, description="Title of the project") + objective: str | None = Field(None, description="Objective of the project") - frameworkProgramme: Optional[str] = Field( + frameworkProgramme: str | None = Field( None, description="Framework Programme under which the project was funded" ) - fundingScheme: Optional[str] = Field( + fundingScheme: str | None = Field( None, description="Funding scheme of the project" ) - legalBasis: Optional[str] = Field( + legalBasis: str | None = Field( None, description="Legal basis for the project funding" ) - masterCall: Optional[str] = Field( + masterCall: str | None = Field( None, description="Master call identifier if applicable" ) - subCall: Optional[str] = Field( + subCall: str | None = Field( None, description="Sub call identifier if applicable" ) - topics: Optional[Union[str, List[str]]] = ( + topics: str | list[str] | None = ( None # Elastic keyword can map to a single string or list of strings ) - nature: Optional[str] = Field(None, description="Nature of the project") - status: Optional[str] = Field(None, description="Status of the project") + nature: str | None = Field(None, description="Nature of the project") + status: str | None = Field(None, description="Status of the project") - ecMaxContribution: Optional[float] = Field( + ecMaxContribution: float | None = Field( None, description="Maximum European Commission contribution" ) - totalCost: Optional[float] = Field(None, description="Total cost of the project") + totalCost: float | None = Field(None, description="Total cost of the project") - startDate: Optional[datetime] = Field(None, description="Start date of the project") - endDate: Optional[datetime] = Field(None, description="End date of the project") - ecSignatureDate: Optional[datetime] = Field( + startDate: datetime | None = Field(None, description="Start date of the project") + endDate: datetime | None = Field(None, description="End date of the project") + ecSignatureDate: datetime | None = Field( None, description="Date of the European Commission signature" ) - contentUpdateDate: Optional[datetime] = Field( + contentUpdateDate: datetime | None = Field( None, description="Date when the project content was last updated" ) - grantDoi: Optional[str] = Field(None, description="DOI for the project grant") - humanValidated: Optional[bool] = Field( + grantDoi: str | None = Field(None, description="DOI for the project grant") + humanValidated: bool | None = Field( None, description="Indicates if the project information has been human validated", ) - keywords: Optional[Union[str, List[str]]] = Field( + keywords: str | list[str] | None = Field( None, description="Keywords associated with the project" ) diff --git a/service/src/main/inse/models/dfg_project.py b/service/src/main/inse/models/dfg_project.py index 409e0fe5..009dd81d 100644 --- a/service/src/main/inse/models/dfg_project.py +++ b/service/src/main/inse/models/dfg_project.py @@ -1,5 +1,3 @@ -from datetime import date -from typing import Optional, Set from pydantic import BaseModel, Field @@ -31,8 +29,8 @@ class DfgProject(BaseModel): def from_elastic_hit(cls, hit: dict): source = hit["_source"] - associated_persons: Set[str] = set() - institutions: Set[str] = set() + associated_persons: set[str] = set() + institutions: set[str] = set() # persons diff --git a/service/src/main/inse/models/dfg_project_details.py b/service/src/main/inse/models/dfg_project_details.py index e7440ddf..fe914373 100644 --- a/service/src/main/inse/models/dfg_project_details.py +++ b/service/src/main/inse/models/dfg_project_details.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Project Clean Model (v2) @@ -8,25 +7,24 @@ rather than the old flat projects_dfg_all Elasticsearch index. """ -from typing import List, Optional from pydantic import BaseModel, ConfigDict, Field from inse.models.projects_dfg_v2.project.dfg_project import DFGProject -from inse.models.projects_dfg_v2.project.dfg_project_persons_inner import ( - DFGProjectPersonsInner, +from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import ( + DFGProjectFachgebieteInner, ) from inse.models.projects_dfg_v2.project.dfg_project_institutions_inner import ( DFGProjectInstitutionsInner, ) -from inse.models.projects_dfg_v2.project.dfg_project_subprojects_inner import ( - DFGProjectSubprojectsInner, +from inse.models.projects_dfg_v2.project.dfg_project_persons_inner import ( + DFGProjectPersonsInner, ) from inse.models.projects_dfg_v2.project.dfg_project_publications_inner import ( DFGProjectPublicationsInner, ) -from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import ( - DFGProjectFachgebieteInner, +from inse.models.projects_dfg_v2.project.dfg_project_subprojects_inner import ( + DFGProjectSubprojectsInner, ) from inse.topics.model import Topic @@ -36,9 +34,9 @@ class DfgProjectPersonRole(BaseModel): model_config = ConfigDict(populate_by_name=True) - person_id: Optional[int] = Field(default=None, description="DFG person ID") - full_name: Optional[str] = Field(default=None, description="Full name of the person") - orcid_id: Optional[str] = Field( + person_id: int | None = Field(default=None, description="DFG person ID") + full_name: str | None = Field(default=None, description="Full name of the person") + orcid_id: str | None = Field( default=None, description=( "ORCID iD, if known. Not present on the project's embedded person " @@ -47,19 +45,19 @@ class DfgProjectPersonRole(BaseModel): "calls DfgProjectDetails.enrich_orcids afterwards." ), ) - role_key: Optional[str] = Field( + role_key: str | None = Field( default=None, description="Machine-readable role key (e.g. 'antragsteller')" ) - role_label_de: Optional[str] = Field(default=None, description="Role label (German)") - role_label_en: Optional[str] = Field(default=None, description="Role label (English)") - affiliation_de: Optional[str] = Field( + role_label_de: str | None = Field(default=None, description="Role label (German)") + role_label_en: str | None = Field(default=None, description="Role label (English)") + affiliation_de: str | None = Field( default=None, description="Person's affiliation at time of project (German)" ) - affiliation_en: Optional[str] = Field( + affiliation_en: str | None = Field( default=None, description="Person's affiliation at time of project (English)" ) - is_deceased: Optional[bool] = Field(default=None, description="Whether the person is deceased") - is_head: Optional[bool] = Field( + is_deceased: bool | None = Field(default=None, description="Whether the person is deceased") + is_head: bool | None = Field( default=None, description="Whether this person is highlighted as the project head" ) @@ -83,16 +81,16 @@ class DfgProjectInstitutionRole(BaseModel): model_config = ConfigDict(populate_by_name=True) - institute_id: Optional[int] = Field(default=None, description="DFG institute ID") - name_de: Optional[str] = Field(default=None, description="Institution name (German)") - name_en: Optional[str] = Field(default=None, description="Institution name (English)") - role_key: Optional[str] = Field(default=None, description="Machine-readable role key") - role_label_de: Optional[str] = Field(default=None, description="Role label (German)") - role_label_en: Optional[str] = Field(default=None, description="Role label (English)") - is_dissolved: Optional[bool] = Field( + institute_id: int | None = Field(default=None, description="DFG institute ID") + name_de: str | None = Field(default=None, description="Institution name (German)") + name_en: str | None = Field(default=None, description="Institution name (English)") + role_key: str | None = Field(default=None, description="Machine-readable role key") + role_label_de: str | None = Field(default=None, description="Role label (German)") + role_label_en: str | None = Field(default=None, description="Role label (English)") + is_dissolved: bool | None = Field( default=None, description="Whether the institution has since been dissolved" ) - is_head: Optional[bool] = Field( + is_head: bool | None = Field( default=None, description="Whether this institution is highlighted as the lead institution" ) @@ -115,19 +113,19 @@ class DfgProjectSubprojectSummary(BaseModel): model_config = ConfigDict(populate_by_name=True) - subproject_id: Optional[int] = None - title_de: Optional[str] = None - title_en: Optional[str] = None - short_title: Optional[str] = None - role_label_de: Optional[str] = Field( + subproject_id: int | None = None + title_de: str | None = None + title_en: str | None = None + short_title: str | None = None + role_label_de: str | None = Field( default=None, description="Role of the sub-project lead within the sub-project" ) - person_full_name: Optional[str] = Field( + person_full_name: str | None = Field( default=None, description="Sub-project lead, derived from first/last name fields" ) - status_de: Optional[str] = None - funding_start: Optional[int] = None - funding_end: Optional[int] = None + status_de: str | None = None + funding_start: int | None = None + funding_end: int | None = None @classmethod def from_inner(cls, s: DFGProjectSubprojectsInner) -> "DfgProjectSubprojectSummary": @@ -155,11 +153,11 @@ class DfgProjectPublicationSummary(BaseModel): model_config = ConfigDict(populate_by_name=True) - publication_id: Optional[int] = None - title: Optional[str] = None - authors_editors: Optional[str] = None - doi: Optional[str] = None - publication_year: Optional[int] = None + publication_id: int | None = None + title: str | None = None + authors_editors: str | None = None + doi: str | None = None + publication_year: int | None = None @classmethod def from_inner(cls, p: DFGProjectPublicationsInner) -> "DfgProjectPublicationSummary": @@ -177,10 +175,10 @@ class DfgProjectSubjectArea(BaseModel): model_config = ConfigDict(populate_by_name=True) - fach: Optional[str] = None - fachgebiet: Optional[str] = None - fachkollegium: Optional[str] = None - wissenschaftsbereich: Optional[str] = None + fach: str | None = None + fachgebiet: str | None = None + fachkollegium: str | None = None + wissenschaftsbereich: str | None = None @classmethod def from_inner(cls, f: DFGProjectFachgebieteInner) -> "DfgProjectSubjectArea": @@ -199,107 +197,107 @@ class DfgProjectDetails(BaseModel): model_config = ConfigDict(populate_by_name=True, validate_assignment=True) - id: Optional[int] = Field(default=None, description="The DFG project ID") - link: Optional[str] = Field(default=None, description="Canonical DFG link to the project") - page_url: Optional[str] = Field(default=None, description="DFG GEPRIS page URL") - external_link: Optional[str] = Field( + id: int | None = Field(default=None, description="The DFG project ID") + link: str | None = Field(default=None, description="Canonical DFG link to the project") + page_url: str | None = Field(default=None, description="DFG GEPRIS page URL") + external_link: str | None = Field( default=None, description="External project website/link, if provided" ) - title_de: Optional[str] = Field(default=None, description="Project title (German)") - title_en: Optional[str] = Field(default=None, description="Project title (English)") - description_de: Optional[str] = Field(default=None, description="Project abstract (German)") - description_en: Optional[str] = Field(default=None, description="Project abstract (English)") - final_report_abstract_de: Optional[str] = Field( + title_de: str | None = Field(default=None, description="Project title (German)") + title_en: str | None = Field(default=None, description="Project title (English)") + description_de: str | None = Field(default=None, description="Project abstract (German)") + description_en: str | None = Field(default=None, description="Project abstract (English)") + final_report_abstract_de: str | None = Field( default=None, description="Final report abstract (German), if the project has concluded" ) - final_report_abstract_en: Optional[str] = Field( + final_report_abstract_en: str | None = Field( default=None, description="Final report abstract (English), if the project has concluded" ) - project_identifier_de: Optional[str] = Field(default=None, description="DFG project identifier (German)") - project_identifier_en: Optional[str] = Field(default=None, description="DFG project identifier (English)") + project_identifier_de: str | None = Field(default=None, description="DFG project identifier (German)") + project_identifier_en: str | None = Field(default=None, description="DFG project identifier (English)") - funding_start: Optional[int] = Field(default=None, description="Funding start year") - funding_end: Optional[int] = Field(default=None, description="Funding end year") - funding_period_de: Optional[str] = Field(default=None, description="Human-readable funding period (German)") - funding_period_en: Optional[str] = Field(default=None, description="Human-readable funding period (English)") + funding_start: int | None = Field(default=None, description="Funding start year") + funding_end: int | None = Field(default=None, description="Funding end year") + funding_period_de: str | None = Field(default=None, description="Human-readable funding period (German)") + funding_period_en: str | None = Field(default=None, description="Human-readable funding period (English)") - funding_type_de: Optional[str] = Field(default=None, description="Funding type / programme (German)") - funding_type_en: Optional[str] = Field(default=None, description="Funding type / programme (English)") - funding_type_key: Optional[str] = Field(default=None, description="Machine-readable funding type key") + funding_type_de: str | None = Field(default=None, description="Funding type / programme (German)") + funding_type_en: str | None = Field(default=None, description="Funding type / programme (English)") + funding_type_key: str | None = Field(default=None, description="Machine-readable funding type key") - dfg_procedure: Optional[str] = Field( + dfg_procedure: str | None = Field( default=None, description="DFG procedure / template type (e.g. Sachbeihilfe, SFB, GRK)" ) - is_transfer_project: Optional[bool] = Field( + is_transfer_project: bool | None = Field( default=None, description="Whether this is a transfer project" ) - website_html_de: Optional[str] = Field( + website_html_de: str | None = Field( default=None, description="Raw project website HTML content (German), as served by DFG" ) - website_html_en: Optional[str] = Field( + website_html_en: str | None = Field( default=None, description="Raw project website HTML content (English), as served by DFG" ) - equipment_group: Optional[str] = Field( + equipment_group: str | None = Field( default=None, description="Large-equipment (Großgerät) group, for equipment-funding projects", ) - equipment_name: Optional[str] = Field( + equipment_name: str | None = Field( default=None, description="Large-equipment (Großgerät) name, for equipment-funding projects", ) - subject_area_de: Optional[str] = Field(default=None, description="Subject area, summary text (German)") - subject_area_en: Optional[str] = Field(default=None, description="Subject area, summary text (English)") - subject_classifications: List[DfgProjectSubjectArea] = Field( + subject_area_de: str | None = Field(default=None, description="Subject area, summary text (German)") + subject_area_en: str | None = Field(default=None, description="Subject area, summary text (English)") + subject_classifications: list[DfgProjectSubjectArea] = Field( default_factory=list, description="Detailed DFG subject-area classification entries (Fachsystematik)", ) - international_relation_de: Optional[str] = Field( + international_relation_de: str | None = Field( default=None, description="International reference/cooperation (German)" ) - international_relation_en: Optional[str] = Field( + international_relation_en: str | None = Field( default=None, description="International reference/cooperation (English)" ) # Structured, role-aware person and institution lists - persons: List[DfgProjectPersonRole] = Field( + persons: list[DfgProjectPersonRole] = Field( default_factory=list, description="All persons associated with the project, each with their role", ) - institutions: List[DfgProjectInstitutionRole] = Field( + institutions: list[DfgProjectInstitutionRole] = Field( default_factory=list, description="All institutions associated with the project, each with their role", ) # Convenience flat views, derived from the structured lists above - associated_persons: List[str] = Field( + associated_persons: list[str] = Field( default_factory=list, description="Flat, de-duplicated list of all person full names (convenience view)", ) - associated_institutions: List[str] = Field( + associated_institutions: list[str] = Field( default_factory=list, description="Flat, de-duplicated list of all institution names (convenience view)", ) # Parent / sub-project structure - parent_project_id: Optional[int] = Field(default=None, description="Parent project ID, if this is a sub-project") - parent_title_de: Optional[str] = Field(default=None, description="Parent project title (German)") - parent_title_en: Optional[str] = Field(default=None, description="Parent project title (English)") - subprojects: List[DfgProjectSubprojectSummary] = Field( + parent_project_id: int | None = Field(default=None, description="Parent project ID, if this is a sub-project") + parent_title_de: str | None = Field(default=None, description="Parent project title (German)") + parent_title_en: str | None = Field(default=None, description="Parent project title (English)") + subprojects: list[DfgProjectSubprojectSummary] = Field( default_factory=list, description="Sub-projects of this project, if any" ) - publications: List[DfgProjectPublicationSummary] = Field( + publications: list[DfgProjectPublicationSummary] = Field( default_factory=list, description="Publications resulting from the project" ) - topics: Optional[List[Topic]] = Field( + topics: list[Topic] | None = Field( default_factory=list, description="OpenAlex topics associated with the project ID" ) diff --git a/service/src/main/inse/models/eu_project.py b/service/src/main/inse/models/eu_project.py index a499216a..76763c2d 100644 --- a/service/src/main/inse/models/eu_project.py +++ b/service/src/main/inse/models/eu_project.py @@ -1,11 +1,11 @@ -from typing import List, Optional + from pydantic import BaseModel, ConfigDict, Field class DisplayCodeSplittedNested(BaseModel): model_config = ConfigDict(populate_by_name=True) - single_display_code: Optional[str] = Field( + single_display_code: str | None = Field( default=None, validation_alias="singleDisplayCode", description="A solitary segment or specific component broken out from the main display code.", @@ -15,25 +15,25 @@ class DisplayCodeSplittedNested(BaseModel): class CategoryNested(BaseModel): model_config = ConfigDict(populate_by_name=True) - category: Optional[str] = Field( + category: str | None = Field( default=None, description="The descriptive classification title or taxonomy name for the project.", ) - code: Optional[str] = Field( + code: str | None = Field( default=None, description="The system code representing the specific category." ) - display_code: Optional[str] = Field( + display_code: str | None = Field( default=None, validation_alias="displayCode", description="The alphanumeric code formatted for user interface display purposes.", ) # REFINED: Mapped to List[str] because the real data provides an array of strings - display_code_splitted: List[str] = Field( + display_code_splitted: list[str] = Field( default_factory=list, validation_alias="displayCode_splitted", description="A tokenized hierarchy breakdown of the display code represented as an array of strings.", ) - display_code_splitted_nested: List[DisplayCodeSplittedNested] = Field( + display_code_splitted_nested: list[DisplayCodeSplittedNested] = Field( default_factory=list, validation_alias="displayCode_splitted_nested", description="Granular, nested breakdowns of the split parts of the display code.", @@ -43,7 +43,7 @@ class CategoryNested(BaseModel): class KeywordNested(BaseModel): model_config = ConfigDict(populate_by_name=True) - keyword: Optional[str] = Field( + keyword: str | None = Field( default=None, description="An individual standalone keyword or tag used for granular search index filtering.", ) @@ -52,30 +52,30 @@ class KeywordNested(BaseModel): class OrganizationNested(BaseModel): model_config = ConfigDict(populate_by_name=True) - ec_contribution: Optional[str] = Field( + ec_contribution: str | None = Field( default=None, validation_alias="ecContribution", description="The gross European Commission financial contribution allocated to this specific participant organization.", ) - id: Optional[str] = Field( + id: str | None = Field( default=None, description="The unique identifier or Participant Identification Code (PIC) of the organization.", ) - name: Optional[str] = Field( + name: str | None = Field( default=None, description="The full legal name of the participating organization or institution.", ) - net_ec_contribution: Optional[str] = Field( + net_ec_contribution: str | None = Field( default=None, validation_alias="netEcContribution", description="The net European Commission financial funding provided to the organization after adjustments.", ) - total_cost: Optional[str] = Field( + total_cost: str | None = Field( default=None, validation_alias="totalCost", description="The overall individual budget or total cost declared by this organization for its share of work.", ) - organization_type: Optional[str] = Field( + organization_type: str | None = Field( default=None, validation_alias="type", description="The legal entity type or role of the organization (e.g., coordinator, participant).", @@ -85,15 +85,15 @@ class OrganizationNested(BaseModel): class ProgrammeNested(BaseModel): model_config = ConfigDict(populate_by_name=True) - code: Optional[str] = Field( + code: str | None = Field( default=None, description="The structural code identifying the framework or specific funding sub-programme.", ) - id: Optional[str] = Field( + id: str | None = Field( default=None, description="The unique identifier of the funding program within the registry.", ) - programme: Optional[str] = Field( + programme: str | None = Field( default=None, description="The official title or description of the EU funding program.", ) @@ -102,90 +102,90 @@ class ProgrammeNested(BaseModel): class EuProject(BaseModel): model_config = ConfigDict(populate_by_name=True) - acronym: Optional[str] = Field( + acronym: str | None = Field( default=None, description="The official, short acronym chosen to identify the EU project.", ) - categories_nested: List[CategoryNested] = Field( + categories_nested: list[CategoryNested] = Field( default_factory=list, description="Structured lists of classification categories and taxonomy mappings assigned to the project.", ) - doc_number: Optional[str] = Field( + doc_number: str | None = Field( default=None, description="The internal administrative document control number or record tracking identifier.", ) - doi: Optional[str] = Field( + doi: str | None = Field( default=None, description="The Digital Object Identifier (DOI) linked to the project's official metadata or primary publication.", ) - ec_max_contribution: Optional[str] = Field( + ec_max_contribution: str | None = Field( default=None, validation_alias="ecMaxContribution", description="The maximum authorized limit for the European Commission's financial grant contribution to the project.", ) - end_date: Optional[str] = Field( + end_date: str | None = Field( default=None, validation_alias="endDate", description="The calendar date marking the official structural conclusion of the project execution timeline.", ) - funding_end: Optional[str] = Field( + funding_end: str | None = Field( default=None, description="The exact calendar termination year for the project's financial eligibility period.", ) - funding_start: Optional[str] = Field( + funding_start: str | None = Field( default=None, description="The exact calendar activation year from which project expenses can be billed against the grant.", ) - id: Optional[str] = Field( + id: str | None = Field( default=None, description="The unique global record ID for the project document (typically the Grant Agreement Number).", ) - keywords: Optional[str] = Field( + keywords: str | None = Field( default=None, description="A general text string or comma-separated list of keywords applied to the project record.", ) - keywords_nested: List[KeywordNested] = Field( + keywords_nested: list[KeywordNested] = Field( default_factory=list, description="Strictly tokenized and isolated keywords nested for targeted search engine aggregations.", ) - link: Optional[str] = Field( + link: str | None = Field( default=None, description="The web URL linking directly to the project's public profile page on CORDIS or an equivalent registry.", ) - objective: Optional[str] = Field( + objective: str | None = Field( default=None, description="The complete, detailed abstract outlining the goals, methodology, and expected impact of the project.", ) - organization_nested: List[OrganizationNested] = Field( + organization_nested: list[OrganizationNested] = Field( default_factory=list, description="The full roster of academic, public, or private organizations participating in the project consortium.", ) - programme_nested: List[ProgrammeNested] = Field( + programme_nested: list[ProgrammeNested] = Field( default_factory=list, description="The nested historical line of EU funding frameworks and structural grants supporting this project.", ) - source: Optional[str] = Field( + source: str | None = Field( default=None, description="The specific upstream system or database repository from which this document was fetched or synced.", ) - start_date: Optional[str] = Field( + start_date: str | None = Field( default=None, validation_alias="startDate", description="The official calendar date marking the active kickoff and formal initiation of the project.", ) - status: Optional[str] = Field( + status: str | None = Field( default=None, description="The lifecycle phase of the project (e.g., 'CLOSED', 'ONGOING').", ) - teaser: Optional[str] = Field( + teaser: str | None = Field( default=None, description="A brief, high-level summary or editorial sentence written for general public consumption.", ) - title: Optional[str] = Field( + title: str | None = Field( default=None, description="The comprehensive, full legal title describing the scope of the project.", ) - total_cost: Optional[str] = Field( + total_cost: str | None = Field( default=None, validation_alias="totalCost", description="The combined sum total budget estimated for the implementation of the entire project.", diff --git a/service/src/main/inse/models/news_aktuell/aktuell.py b/service/src/main/inse/models/news_aktuell/aktuell.py index 8076484c..a0b72a7a 100644 --- a/service/src/main/inse/models/news_aktuell/aktuell.py +++ b/service/src/main/inse/models/news_aktuell/aktuell.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Aktuell Index Backend Models @@ -9,42 +8,42 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.news_aktuell.link_item import LinkItem from inse.models.news_aktuell.tag_item import TagItem -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from pydantic_core import to_jsonable_python + class Aktuell(BaseModel): """ Main document model for the aktuell index. - """ # noqa: E501 - author: Optional[StrictStr] = None - var_date: Optional[StrictStr] = Field(default=None, alias="date") - date_full: Optional[StrictInt] = None - date_year: Optional[StrictInt] = None - full_content: Optional[StrictStr] = None - further_content: Optional[StrictStr] = None - intro_content: Optional[StrictStr] = None - links_nested: Optional[List[LinkItem]] = None - main_content: Optional[StrictStr] = None - maintitle: Optional[StrictStr] = None - redaktion: Optional[StrictStr] = None - subtitle: Optional[StrictStr] = None - tags: Optional[StrictStr] = None - tags_nested: Optional[List[TagItem]] = None - url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["author", "date", "date_full", "date_year", "full_content", "further_content", "intro_content", "links_nested", "main_content", "maintitle", "redaktion", "subtitle", "tags", "tags_nested", "url"] + """ + author: StrictStr | None = None + var_date: StrictStr | None = Field(default=None, alias="date") + date_full: StrictInt | None = None + date_year: StrictInt | None = None + full_content: StrictStr | None = None + further_content: StrictStr | None = None + intro_content: StrictStr | None = None + links_nested: list[LinkItem] | None = None + main_content: StrictStr | None = None + maintitle: StrictStr | None = None + redaktion: StrictStr | None = None + subtitle: StrictStr | None = None + tags: StrictStr | None = None + tags_nested: list[TagItem] | None = None + url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["author", "date", "date_full", "date_year", "full_content", "further_content", "intro_content", "links_nested", "main_content", "maintitle", "redaktion", "subtitle", "tags", "tags_nested", "url"] model_config = ConfigDict( validate_by_name=True, @@ -63,11 +62,11 @@ class Aktuell(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Aktuell from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -77,7 +76,7 @@ class Aktuell(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -102,7 +101,7 @@ class Aktuell(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Aktuell from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/news_aktuell/link_item.py b/service/src/main/inse/models/news_aktuell/link_item.py index 2b3e07c0..08576bdf 100644 --- a/service/src/main/inse/models/news_aktuell/link_item.py +++ b/service/src/main/inse/models/news_aktuell/link_item.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Aktuell Index Backend Models @@ -9,27 +8,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class LinkItem(BaseModel): """ Nested link object within the Aktuell document. - """ # noqa: E501 - text: Optional[StrictStr] = None - url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["text", "url"] + """ + text: StrictStr | None = None + url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["text", "url"] model_config = ConfigDict( validate_by_name=True, @@ -48,11 +47,11 @@ class LinkItem(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of LinkItem from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -62,7 +61,7 @@ class LinkItem(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -73,7 +72,7 @@ class LinkItem(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of LinkItem from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/news_aktuell/tag_item.py b/service/src/main/inse/models/news_aktuell/tag_item.py index e7a64e1e..83721dbb 100644 --- a/service/src/main/inse/models/news_aktuell/tag_item.py +++ b/service/src/main/inse/models/news_aktuell/tag_item.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Aktuell Index Backend Models @@ -9,26 +8,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class TagItem(BaseModel): """ Nested tag object within the Aktuell document. - """ # noqa: E501 - tag: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["tag"] + """ + tag: StrictStr | None = None + __properties: ClassVar[list[str]] = ["tag"] model_config = ConfigDict( validate_by_name=True, @@ -47,11 +46,11 @@ class TagItem(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TagItem from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,7 +60,7 @@ class TagItem(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -72,7 +71,7 @@ class TagItem(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TagItem from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/author.py b/service/src/main/inse/models/openalex/author.py index f318c85b..6bf010df 100644 --- a/service/src/main/inse/models/openalex/author.py +++ b/service/src/main/inse/models/openalex/author.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,50 +9,51 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.author_affiliations_inner import AuthorAffiliationsInner from inse.models.openalex.author_counts_by_year_inner import AuthorCountsByYearInner from inse.models.openalex.author_ids import AuthorIds from inse.models.openalex.author_parsed_longest_name import AuthorParsedLongestName from inse.models.openalex.author_summary_stats import AuthorSummaryStats -from inse.models.openalex.work_topic import WorkTopic from inse.models.openalex.dehydrated_institution import DehydratedInstitution -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from inse.models.openalex.work_topic import WorkTopic + class Author(BaseModel): """ A person who creates scholarly works - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this author.") - orcid: Optional[StrictStr] = Field(default=None, description="The ORCID ID for this author. This is the Canonical External ID for authors.") - display_name: Optional[StrictStr] = Field(default=None, description="The name of the author as a single string.") - display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Other ways this author's name has been displayed.") - longest_name: Optional[StrictStr] = Field(default=None, description="The longest name variant found for this author across all their works.") - parsed_longest_name: Optional[AuthorParsedLongestName] = None - works_count: Optional[StrictInt] = Field(default=None, description="The number of works this author has created.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="The total number of works that cite a work this author has created.") - summary_stats: Optional[AuthorSummaryStats] = None - affiliations: Optional[List[AuthorAffiliationsInner]] = Field(default=None, description="List of affiliations this author has claimed in their publications. Each object has:") - last_known_institutions: Optional[List[DehydratedInstitution]] = Field(default=None, description="This author's last known institutional affiliations. Each item is a dehydrated Institution object.") - topics: Optional[List[WorkTopic]] = None - counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") - ids: Optional[AuthorIds] = None - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all this author's works.") - created_date: Optional[date] = Field(default=None, description="When this author was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this author was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "orcid", "display_name", "display_name_alternatives", "longest_name", "parsed_longest_name", "works_count", "cited_by_count", "summary_stats", "affiliations", "last_known_institutions", "topics", "counts_by_year", "ids", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this author.") + orcid: StrictStr | None = Field(default=None, description="The ORCID ID for this author. This is the Canonical External ID for authors.") + display_name: StrictStr | None = Field(default=None, description="The name of the author as a single string.") + display_name_alternatives: list[StrictStr] | None = Field(default=None, description="Other ways this author's name has been displayed.") + longest_name: StrictStr | None = Field(default=None, description="The longest name variant found for this author across all their works.") + parsed_longest_name: AuthorParsedLongestName | None = None + works_count: StrictInt | None = Field(default=None, description="The number of works this author has created.") + cited_by_count: StrictInt | None = Field(default=None, description="The total number of works that cite a work this author has created.") + summary_stats: AuthorSummaryStats | None = None + affiliations: list[AuthorAffiliationsInner] | None = Field(default=None, description="List of affiliations this author has claimed in their publications. Each object has:") + last_known_institutions: list[DehydratedInstitution] | None = Field(default=None, description="This author's last known institutional affiliations. Each item is a dehydrated Institution object.") + topics: list[WorkTopic] | None = None + counts_by_year: list[AuthorCountsByYearInner] | None = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") + ids: AuthorIds | None = None + works_api_url: StrictStr | None = Field(default=None, description="A URL that will get you a list of all this author's works.") + created_date: date | None = Field(default=None, description="When this author was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this author was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "orcid", "display_name", "display_name_alternatives", "longest_name", "parsed_longest_name", "works_count", "cited_by_count", "summary_stats", "affiliations", "last_known_institutions", "topics", "counts_by_year", "ids", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -72,11 +72,11 @@ class Author(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Author from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -86,7 +86,7 @@ class Author(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -134,7 +134,7 @@ class Author(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Author from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/author_affiliations_inner.py b/service/src/main/inse/models/openalex/author_affiliations_inner.py index 33985031..e08e689f 100644 --- a/service/src/main/inse/models/openalex/author_affiliations_inner.py +++ b/service/src/main/inse/models/openalex/author_affiliations_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,32 +9,32 @@ Contact: support@openalex.org Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.dehydrated_institution import DehydratedInstitution -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.dehydrated_institution import DehydratedInstitution + class AuthorAffiliationsInner(BaseModel): """ AuthorAffiliationsInner - """ # noqa: E501 + """ - institution: Optional[DehydratedInstitution] = Field( + institution: DehydratedInstitution | None = Field( default=None, description="[Dehydrated institution](/api-reference/institutions#the-dehydratedinstitution-object)", ) - years: Optional[List[StrictInt]] = None - __properties: ClassVar[List[str]] = ["institution", "years"] + years: list[StrictInt] | None = None + __properties: ClassVar[list[str]] = ["institution", "years"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +52,11 @@ class AuthorAffiliationsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AuthorAffiliationsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +66,7 @@ class AuthorAffiliationsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([]) + excluded_fields: set[str] = set([]) _dict = self.model_dump( by_alias=True, @@ -80,7 +79,7 @@ class AuthorAffiliationsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AuthorAffiliationsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/author_counts_by_year_inner.py b/service/src/main/inse/models/openalex/author_counts_by_year_inner.py index 1c6152f0..bc811891 100644 --- a/service/src/main/inse/models/openalex/author_counts_by_year_inner.py +++ b/service/src/main/inse/models/openalex/author_counts_by_year_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AuthorCountsByYearInner(BaseModel): """ AuthorCountsByYearInner - """ # noqa: E501 - year: Optional[StrictInt] = None - works_count: Optional[StrictInt] = None - cited_by_count: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["year", "works_count", "cited_by_count"] + """ + year: StrictInt | None = None + works_count: StrictInt | None = None + cited_by_count: StrictInt | None = None + __properties: ClassVar[list[str]] = ["year", "works_count", "cited_by_count"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class AuthorCountsByYearInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AuthorCountsByYearInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class AuthorCountsByYearInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class AuthorCountsByYearInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AuthorCountsByYearInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/author_ids.py b/service/src/main/inse/models/openalex/author_ids.py index 70853b20..d06f8d06 100644 --- a/service/src/main/inse/models/openalex/author_ids.py +++ b/service/src/main/inse/models/openalex/author_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AuthorIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - orcid: Optional[StrictStr] = None - scopus: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "orcid", "scopus"] + """ + openalex: StrictStr | None = None + orcid: StrictStr | None = None + scopus: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "orcid", "scopus"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class AuthorIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AuthorIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class AuthorIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class AuthorIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AuthorIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/author_parsed_longest_name.py b/service/src/main/inse/models/openalex/author_parsed_longest_name.py index d84b4cd5..e55d7629 100644 --- a/service/src/main/inse/models/openalex/author_parsed_longest_name.py +++ b/service/src/main/inse/models/openalex/author_parsed_longest_name.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,30 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AuthorParsedLongestName(BaseModel): """ The longest name parsed into its component parts. - """ # noqa: E501 - first: Optional[StrictStr] = Field(default=None, description="First name (lowercased).") - middle: Optional[StrictStr] = Field(default=None, description="Middle name or initial (lowercased).") - last: Optional[StrictStr] = Field(default=None, description="Last name (lowercased).") - suffix: Optional[StrictStr] = Field(default=None, description="Name suffix (e.g., Jr., III).") - nickname: Optional[StrictStr] = Field(default=None, description="Nickname, if any.") - __properties: ClassVar[List[str]] = ["first", "middle", "last", "suffix", "nickname"] + """ + first: StrictStr | None = Field(default=None, description="First name (lowercased).") + middle: StrictStr | None = Field(default=None, description="Middle name or initial (lowercased).") + last: StrictStr | None = Field(default=None, description="Last name (lowercased).") + suffix: StrictStr | None = Field(default=None, description="Name suffix (e.g., Jr., III).") + nickname: StrictStr | None = Field(default=None, description="Nickname, if any.") + __properties: ClassVar[list[str]] = ["first", "middle", "last", "suffix", "nickname"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class AuthorParsedLongestName(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AuthorParsedLongestName from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class AuthorParsedLongestName(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class AuthorParsedLongestName(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AuthorParsedLongestName from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/author_summary_stats.py b/service/src/main/inse/models/openalex/author_summary_stats.py index 4a00d974..f3768097 100644 --- a/service/src/main/inse/models/openalex/author_summary_stats.py +++ b/service/src/main/inse/models/openalex/author_summary_stats.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AuthorSummaryStats(BaseModel): """ Citation metrics: - """ # noqa: E501 - var_2yr_mean_citedness: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="2yr_mean_citedness") - h_index: Optional[StrictInt] = None - i10_index: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["2yr_mean_citedness", "h_index", "i10_index"] + """ + var_2yr_mean_citedness: StrictFloat | StrictInt | None = Field(default=None, alias="2yr_mean_citedness") + h_index: StrictInt | None = None + i10_index: StrictInt | None = None + __properties: ClassVar[list[str]] = ["2yr_mean_citedness", "h_index", "i10_index"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class AuthorSummaryStats(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AuthorSummaryStats from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class AuthorSummaryStats(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class AuthorSummaryStats(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AuthorSummaryStats from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/author_topics_inner.py b/service/src/main/inse/models/openalex/author_topics_inner.py index e9471d9f..ce848a48 100644 --- a/service/src/main/inse/models/openalex/author_topics_inner.py +++ b/service/src/main/inse/models/openalex/author_topics_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AuthorTopicsInner(BaseModel): """ AuthorTopicsInner - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - count: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "count"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + count: StrictInt | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "count"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class AuthorTopicsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AuthorTopicsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class AuthorTopicsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class AuthorTopicsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AuthorTopicsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/authors_list_response.py b/service/src/main/inse/models/openalex/authors_list_response.py index 8a266d1e..91636889 100644 --- a/service/src/main/inse/models/openalex/authors_list_response.py +++ b/service/src/main/inse/models/openalex/authors_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.author import Author from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class AuthorsListResponse(BaseModel): """ AuthorsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Author]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Author] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class AuthorsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AuthorsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class AuthorsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class AuthorsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AuthorsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/authorship.py b/service/src/main/inse/models/openalex/authorship.py index 5f112d23..8082f7d0 100644 --- a/service/src/main/inse/models/openalex/authorship.py +++ b/service/src/main/inse/models/openalex/authorship.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,34 +9,42 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) +from pydantic_core import to_jsonable_python -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional from inse.models.openalex.dehydrated_author import DehydratedAuthor from inse.models.openalex.dehydrated_institution import DehydratedInstitution -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Authorship(BaseModel): """ Author and their affiliation for a work - """ # noqa: E501 - author_position: Optional[StrictStr] = Field(default=None, description="Position in author list") - author: Optional[DehydratedAuthor] = Field(default=None, description="[Dehydrated author](/api-reference/authors#the-dehydratedauthor-object)") - institutions: Optional[List[DehydratedInstitution]] = Field(default=None, description="[Dehydrated institutions](/api-reference/institutions#the-dehydratedinstitution-object)") - countries: Optional[List[StrictStr]] = Field(default=None, description="Country codes of affiliations") - is_corresponding: Optional[StrictBool] = Field(default=None, description="Whether this is the corresponding author") - raw_author_name: Optional[StrictStr] = Field(default=None, description="Author name as it appears in the work") - raw_affiliation_strings: Optional[List[StrictStr]] = None - __properties: ClassVar[List[str]] = ["author_position", "author", "institutions", "countries", "is_corresponding", "raw_author_name", "raw_affiliation_strings"] + """ + author_position: StrictStr | None = Field(default=None, description="Position in author list") + author: DehydratedAuthor | None = Field(default=None, description="[Dehydrated author](/api-reference/authors#the-dehydratedauthor-object)") + institutions: list[DehydratedInstitution] | None = Field(default=None, description="[Dehydrated institutions](/api-reference/institutions#the-dehydratedinstitution-object)") + countries: list[StrictStr] | None = Field(default=None, description="Country codes of affiliations") + is_corresponding: StrictBool | None = Field(default=None, description="Whether this is the corresponding author") + raw_author_name: StrictStr | None = Field(default=None, description="Author name as it appears in the work") + raw_affiliation_strings: list[StrictStr] | None = None + __properties: ClassVar[list[str]] = ["author_position", "author", "institutions", "countries", "is_corresponding", "raw_author_name", "raw_affiliation_strings"] @field_validator('author_position') def author_position_validate_enum(cls, value): @@ -66,11 +73,11 @@ class Authorship(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Authorship from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -80,7 +87,7 @@ class Authorship(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -101,7 +108,7 @@ class Authorship(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Authorship from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/autocomplete_response.py b/service/src/main/inse/models/openalex/autocomplete_response.py index 953a05a3..e3758e08 100644 --- a/service/src/main/inse/models/openalex/autocomplete_response.py +++ b/service/src/main/inse/models/openalex/autocomplete_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.autocomplete_response_meta import AutocompleteResponseMeta -from inse.models.openalex.autocomplete_response_results_inner import AutocompleteResponseResultsInner -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.autocomplete_response_meta import AutocompleteResponseMeta +from inse.models.openalex.autocomplete_response_results_inner import ( + AutocompleteResponseResultsInner, +) + + class AutocompleteResponse(BaseModel): """ AutocompleteResponse - """ # noqa: E501 - meta: Optional[AutocompleteResponseMeta] = None - results: Optional[List[AutocompleteResponseResultsInner]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: AutocompleteResponseMeta | None = None + results: list[AutocompleteResponseResultsInner] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +53,11 @@ class AutocompleteResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AutocompleteResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +67,7 @@ class AutocompleteResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +88,7 @@ class AutocompleteResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AutocompleteResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/autocomplete_response_meta.py b/service/src/main/inse/models/openalex/autocomplete_response_meta.py index ca195725..945553b0 100644 --- a/service/src/main/inse/models/openalex/autocomplete_response_meta.py +++ b/service/src/main/inse/models/openalex/autocomplete_response_meta.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AutocompleteResponseMeta(BaseModel): """ AutocompleteResponseMeta - """ # noqa: E501 - count: Optional[StrictInt] = None - db_response_time_ms: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["count", "db_response_time_ms"] + """ + count: StrictInt | None = None + db_response_time_ms: StrictInt | None = None + __properties: ClassVar[list[str]] = ["count", "db_response_time_ms"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class AutocompleteResponseMeta(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AutocompleteResponseMeta from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class AutocompleteResponseMeta(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class AutocompleteResponseMeta(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AutocompleteResponseMeta from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/autocomplete_response_results_inner.py b/service/src/main/inse/models/openalex/autocomplete_response_results_inner.py index ae2d0b35..a1c21a25 100644 --- a/service/src/main/inse/models/openalex/autocomplete_response_results_inner.py +++ b/service/src/main/inse/models/openalex/autocomplete_response_results_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,32 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AutocompleteResponseResultsInner(BaseModel): """ AutocompleteResponseResultsInner - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - hint: Optional[StrictStr] = None - cited_by_count: Optional[StrictInt] = None - works_count: Optional[StrictInt] = None - entity_type: Optional[StrictStr] = None - external_id: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "hint", "cited_by_count", "works_count", "entity_type", "external_id"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + hint: StrictStr | None = None + cited_by_count: StrictInt | None = None + works_count: StrictInt | None = None + entity_type: StrictStr | None = None + external_id: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "hint", "cited_by_count", "works_count", "entity_type", "external_id"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class AutocompleteResponseResultsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AutocompleteResponseResultsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class AutocompleteResponseResultsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class AutocompleteResponseResultsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AutocompleteResponseResultsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/award.py b/service/src/main/inse/models/openalex/award.py index 7b376d84..ce5a4bf3 100644 --- a/service/src/main/inse/models/openalex/award.py +++ b/service/src/main/inse/models/openalex/award.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Award(BaseModel): """ Award - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - funder_award_id: Optional[StrictStr] = None - funder_id: Optional[StrictStr] = None - funder_display_name: Optional[StrictStr] = None - doi: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "funder_award_id", "funder_id", "funder_display_name", "doi"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + funder_award_id: StrictStr | None = None + funder_id: StrictStr | None = None + funder_display_name: StrictStr | None = None + doi: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "funder_award_id", "funder_id", "funder_display_name", "doi"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +52,11 @@ class Award(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Award from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +66,7 @@ class Award(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +77,7 @@ class Award(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Award from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/award_full.py b/service/src/main/inse/models/openalex/award_full.py index 06a86912..cd17562d 100644 --- a/service/src/main/inse/models/openalex/award_full.py +++ b/service/src/main/inse/models/openalex/award_full.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,51 +9,52 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union -from inse.models.openalex.award_full_funder import AwardFullFunder -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.award_full_funder import AwardFullFunder + + class AwardFull(BaseModel): """ Research grant or funding award - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this award.") - display_name: Optional[StrictStr] = Field(default=None, description="The name of the award, if available.") - description: Optional[StrictStr] = Field(default=None, description="A description of the award, if available.") - funder_award_id: Optional[StrictStr] = Field(default=None, description="The funder's internal ID for this award.") - funder: Optional[AwardFullFunder] = None - funded_outputs: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs of works funded by this award (first 100).") - funded_outputs_count: Optional[StrictInt] = Field(default=None, description="Total number of works funded by this award.") - amount: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The funding amount, if available.") - currency: Optional[StrictStr] = Field(default=None, description="The currency of the funding amount, if available.") - funding_type: Optional[StrictStr] = Field(default=None, description="The type of funding, if available.") - funder_scheme: Optional[StrictStr] = Field(default=None, description="The funder's scheme or program, if available.") - start_date: Optional[date] = Field(default=None, description="Start date of the award (ISO 8601), if available.") - end_date: Optional[date] = Field(default=None, description="End date of the award (ISO 8601), if available.") - start_year: Optional[StrictInt] = Field(default=None, description="Start year of the award, if available.") - end_year: Optional[StrictInt] = Field(default=None, description="End year of the award, if available.") - landing_page_url: Optional[StrictStr] = Field(default=None, description="URL to the award's landing page, if available.") - doi: Optional[StrictStr] = Field(default=None, description="DOI for this award, if available.") - provenance: Optional[StrictStr] = Field(default=None, description="The source of this award data.") - lead_investigator: Optional[Dict[str, Any]] = Field(default=None, description="The lead investigator for this award, if available.") - co_lead_investigator: Optional[Dict[str, Any]] = Field(default=None, description="The co-lead investigator, if available.") - investigators: Optional[List[Any]] = Field(default=None, description="List of investigators on this award, if available.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works funded by this award.") - created_date: Optional[date] = Field(default=None, description="When this award was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this award was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "funder_award_id", "funder", "funded_outputs", "funded_outputs_count", "amount", "currency", "funding_type", "funder_scheme", "start_date", "end_date", "start_year", "end_year", "landing_page_url", "doi", "provenance", "lead_investigator", "co_lead_investigator", "investigators", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this award.") + display_name: StrictStr | None = Field(default=None, description="The name of the award, if available.") + description: StrictStr | None = Field(default=None, description="A description of the award, if available.") + funder_award_id: StrictStr | None = Field(default=None, description="The funder's internal ID for this award.") + funder: AwardFullFunder | None = None + funded_outputs: list[StrictStr] | None = Field(default=None, description="OpenAlex IDs of works funded by this award (first 100).") + funded_outputs_count: StrictInt | None = Field(default=None, description="Total number of works funded by this award.") + amount: StrictFloat | StrictInt | None = Field(default=None, description="The funding amount, if available.") + currency: StrictStr | None = Field(default=None, description="The currency of the funding amount, if available.") + funding_type: StrictStr | None = Field(default=None, description="The type of funding, if available.") + funder_scheme: StrictStr | None = Field(default=None, description="The funder's scheme or program, if available.") + start_date: date | None = Field(default=None, description="Start date of the award (ISO 8601), if available.") + end_date: date | None = Field(default=None, description="End date of the award (ISO 8601), if available.") + start_year: StrictInt | None = Field(default=None, description="Start year of the award, if available.") + end_year: StrictInt | None = Field(default=None, description="End year of the award, if available.") + landing_page_url: StrictStr | None = Field(default=None, description="URL to the award's landing page, if available.") + doi: StrictStr | None = Field(default=None, description="DOI for this award, if available.") + provenance: StrictStr | None = Field(default=None, description="The source of this award data.") + lead_investigator: dict[str, Any] | None = Field(default=None, description="The lead investigator for this award, if available.") + co_lead_investigator: dict[str, Any] | None = Field(default=None, description="The co-lead investigator, if available.") + investigators: list[Any] | None = Field(default=None, description="List of investigators on this award, if available.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works funded by this award.") + created_date: date | None = Field(default=None, description="When this award was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this award was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "funder_award_id", "funder", "funded_outputs", "funded_outputs_count", "amount", "currency", "funding_type", "funder_scheme", "start_date", "end_date", "start_year", "end_year", "landing_page_url", "doi", "provenance", "lead_investigator", "co_lead_investigator", "investigators", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -73,11 +73,11 @@ class AwardFull(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AwardFull from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -87,7 +87,7 @@ class AwardFull(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -101,7 +101,7 @@ class AwardFull(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AwardFull from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/award_full_funder.py b/service/src/main/inse/models/openalex/award_full_funder.py index d49607a6..a509a212 100644 --- a/service/src/main/inse/models/openalex/award_full_funder.py +++ b/service/src/main/inse/models/openalex/award_full_funder.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AwardFullFunder(BaseModel): """ The [funder](/api-reference/funders) of this award - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - doi: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "doi"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + doi: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "doi"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class AwardFullFunder(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AwardFullFunder from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class AwardFullFunder(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class AwardFullFunder(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AwardFullFunder from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/awards_list_response.py b/service/src/main/inse/models/openalex/awards_list_response.py index c28e4f3b..c70d755c 100644 --- a/service/src/main/inse/models/openalex/awards_list_response.py +++ b/service/src/main/inse/models/openalex/awards_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.award_full import AwardFull from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class AwardsListResponse(BaseModel): """ AwardsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[AwardFull]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[AwardFull] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class AwardsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AwardsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class AwardsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class AwardsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AwardsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/concept.py b/service/src/main/inse/models/openalex/concept.py index 063f7b5a..7c0bf026 100644 --- a/service/src/main/inse/models/openalex/concept.py +++ b/service/src/main/inse/models/openalex/concept.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,43 +9,44 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.concept_ids import ConceptIds -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.concept_ids import ConceptIds + + class Concept(BaseModel): """ Legacy research area taxonomy (deprecated) - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this concept.") - display_name: Optional[StrictStr] = Field(default=None, description="The name of the concept.") - description: Optional[StrictStr] = Field(default=None, description="A description of this concept.") - level: Optional[StrictInt] = Field(default=None, description="The hierarchical level (0 = top level, higher = more specific).") - wikidata: Optional[StrictStr] = Field(default=None, description="The Wikidata ID for this concept.") - ids: Optional[ConceptIds] = None - image_url: Optional[StrictStr] = Field(default=None, description="URL for an image representing this concept.") - image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.") - works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with this concept.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works tagged with this concept.") - ancestors: Optional[List[Any]] = Field(default=None, description="Parent concepts in the hierarchy.") - related_concepts: Optional[List[Any]] = Field(default=None, description="Related concepts with similarity scores.") - counts_by_year: Optional[List[Any]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this concept.") - created_date: Optional[date] = Field(default=None, description="When this concept was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this concept was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "level", "wikidata", "ids", "image_url", "image_thumbnail_url", "works_count", "cited_by_count", "ancestors", "related_concepts", "counts_by_year", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this concept.") + display_name: StrictStr | None = Field(default=None, description="The name of the concept.") + description: StrictStr | None = Field(default=None, description="A description of this concept.") + level: StrictInt | None = Field(default=None, description="The hierarchical level (0 = top level, higher = more specific).") + wikidata: StrictStr | None = Field(default=None, description="The Wikidata ID for this concept.") + ids: ConceptIds | None = None + image_url: StrictStr | None = Field(default=None, description="URL for an image representing this concept.") + image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.") + works_count: StrictInt | None = Field(default=None, description="The number of works tagged with this concept.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works tagged with this concept.") + ancestors: list[Any] | None = Field(default=None, description="Parent concepts in the hierarchy.") + related_concepts: list[Any] | None = Field(default=None, description="Related concepts with similarity scores.") + counts_by_year: list[Any] | None = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works tagged with this concept.") + created_date: date | None = Field(default=None, description="When this concept was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this concept was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "level", "wikidata", "ids", "image_url", "image_thumbnail_url", "works_count", "cited_by_count", "ancestors", "related_concepts", "counts_by_year", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -65,11 +65,11 @@ class Concept(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Concept from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -79,7 +79,7 @@ class Concept(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -93,7 +93,7 @@ class Concept(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Concept from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/concept_ids.py b/service/src/main/inse/models/openalex/concept_ids.py index 090a8c3f..d8b24e2b 100644 --- a/service/src/main/inse/models/openalex/concept_ids.py +++ b/service/src/main/inse/models/openalex/concept_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class ConceptIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - wikipedia: Optional[StrictStr] = None - mag: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["openalex", "wikidata", "wikipedia", "mag"] + """ + openalex: StrictStr | None = None + wikidata: StrictStr | None = None + wikipedia: StrictStr | None = None + mag: StrictInt | None = None + __properties: ClassVar[list[str]] = ["openalex", "wikidata", "wikipedia", "mag"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +50,11 @@ class ConceptIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ConceptIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +64,7 @@ class ConceptIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -76,7 +75,7 @@ class ConceptIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ConceptIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/concepts_list_response.py b/service/src/main/inse/models/openalex/concepts_list_response.py index 4425cd6f..477dd726 100644 --- a/service/src/main/inse/models/openalex/concepts_list_response.py +++ b/service/src/main/inse/models/openalex/concepts_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.concept import Concept from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class ConceptsListResponse(BaseModel): """ ConceptsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Concept]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[Concept] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class ConceptsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ConceptsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class ConceptsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class ConceptsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ConceptsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/continent.py b/service/src/main/inse/models/openalex/continent.py index e8fbe4d2..8b89f852 100644 --- a/service/src/main/inse/models/openalex/continent.py +++ b/service/src/main/inse/models/openalex/continent.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,36 +9,37 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.continent_ids import ContinentIds from inse.models.openalex.domain_fields_inner import DomainFieldsInner -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Continent(BaseModel): """ Geographic continent (7 total) - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this continent (uses Wikidata Q-IDs).") - display_name: Optional[StrictStr] = Field(default=None, description="The name of the continent.") - description: Optional[StrictStr] = Field(default=None, description="A brief description of the continent.") - display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this continent.") - countries: Optional[List[DomainFieldsInner]] = Field(default=None, description="The countries within this continent. Each object has `id` and `display_name`.") - ids: Optional[ContinentIds] = None - created_date: Optional[date] = Field(default=None, description="When this continent was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this continent was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "countries", "ids", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this continent (uses Wikidata Q-IDs).") + display_name: StrictStr | None = Field(default=None, description="The name of the continent.") + description: StrictStr | None = Field(default=None, description="A brief description of the continent.") + display_name_alternatives: list[StrictStr] | None = Field(default=None, description="Alternate names for this continent.") + countries: list[DomainFieldsInner] | None = Field(default=None, description="The countries within this continent. Each object has `id` and `display_name`.") + ids: ContinentIds | None = None + created_date: date | None = Field(default=None, description="When this continent was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this continent was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "display_name_alternatives", "countries", "ids", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -58,11 +58,11 @@ class Continent(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Continent from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -72,7 +72,7 @@ class Continent(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -93,7 +93,7 @@ class Continent(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Continent from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/continent_ids.py b/service/src/main/inse/models/openalex/continent_ids.py index 087bda24..441a4f93 100644 --- a/service/src/main/inse/models/openalex/continent_ids.py +++ b/service/src/main/inse/models/openalex/continent_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class ContinentIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "wikidata"] + """ + openalex: StrictStr | None = None + wikidata: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "wikidata"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class ContinentIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ContinentIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class ContinentIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class ContinentIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ContinentIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/continents_list_response.py b/service/src/main/inse/models/openalex/continents_list_response.py index ceeb4e68..3bd7b2e8 100644 --- a/service/src/main/inse/models/openalex/continents_list_response.py +++ b/service/src/main/inse/models/openalex/continents_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.continent import Continent from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class ContinentsListResponse(BaseModel): """ ContinentsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Continent]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[Continent] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class ContinentsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ContinentsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class ContinentsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class ContinentsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ContinentsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/countries_list_response.py b/service/src/main/inse/models/openalex/countries_list_response.py index ac26b32e..2bb00fda 100644 --- a/service/src/main/inse/models/openalex/countries_list_response.py +++ b/service/src/main/inse/models/openalex/countries_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.country import Country from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class CountriesListResponse(BaseModel): """ CountriesListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Country]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[Country] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class CountriesListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of CountriesListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class CountriesListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class CountriesListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of CountriesListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/country.py b/service/src/main/inse/models/openalex/country.py index 4d051a60..7918d297 100644 --- a/service/src/main/inse/models/openalex/country.py +++ b/service/src/main/inse/models/openalex/country.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,43 +9,44 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.country_continent import CountryContinent from inse.models.openalex.country_ids import CountryIds -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Country(BaseModel): """ Geographic country - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this country.") - display_name: Optional[StrictStr] = Field(default=None, description="The full name of the country.") - country_code: Optional[StrictStr] = Field(default=None, description="ISO 3166-1 alpha-2 country code.") - description: Optional[StrictStr] = Field(default=None, description="A brief description of the country.") - display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this country.") - continent: Optional[CountryContinent] = None - is_global_south: Optional[StrictBool] = Field(default=None, description="Whether this country is part of the Global South.") - ids: Optional[CountryIds] = None - works_count: Optional[StrictInt] = Field(default=None, description="The number of works with authors affiliated with institutions in this country.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works from this country.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works from authors in this country.") - authors_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all authors with affiliations in this country.") - institutions_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all institutions in this country.") - created_date: Optional[date] = Field(default=None, description="When this country was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this country was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "country_code", "description", "display_name_alternatives", "continent", "is_global_south", "ids", "works_count", "cited_by_count", "works_api_url", "authors_api_url", "institutions_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this country.") + display_name: StrictStr | None = Field(default=None, description="The full name of the country.") + country_code: StrictStr | None = Field(default=None, description="ISO 3166-1 alpha-2 country code.") + description: StrictStr | None = Field(default=None, description="A brief description of the country.") + display_name_alternatives: list[StrictStr] | None = Field(default=None, description="Alternate names for this country.") + continent: CountryContinent | None = None + is_global_south: StrictBool | None = Field(default=None, description="Whether this country is part of the Global South.") + ids: CountryIds | None = None + works_count: StrictInt | None = Field(default=None, description="The number of works with authors affiliated with institutions in this country.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works from this country.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works from authors in this country.") + authors_api_url: StrictStr | None = Field(default=None, description="A URL that returns all authors with affiliations in this country.") + institutions_api_url: StrictStr | None = Field(default=None, description="A URL that returns all institutions in this country.") + created_date: date | None = Field(default=None, description="When this country was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this country was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "country_code", "description", "display_name_alternatives", "continent", "is_global_south", "ids", "works_count", "cited_by_count", "works_api_url", "authors_api_url", "institutions_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -65,11 +65,11 @@ class Country(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Country from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -79,7 +79,7 @@ class Country(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -96,7 +96,7 @@ class Country(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Country from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/country_continent.py b/service/src/main/inse/models/openalex/country_continent.py index 80f1319c..6aa443fe 100644 --- a/service/src/main/inse/models/openalex/country_continent.py +++ b/service/src/main/inse/models/openalex/country_continent.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class CountryContinent(BaseModel): """ The [continent](/api-reference/continents) - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class CountryContinent(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of CountryContinent from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class CountryContinent(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class CountryContinent(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of CountryContinent from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/country_ids.py b/service/src/main/inse/models/openalex/country_ids.py index 0f1b3998..28f32396 100644 --- a/service/src/main/inse/models/openalex/country_ids.py +++ b/service/src/main/inse/models/openalex/country_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class CountryIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - iso: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - wikipedia: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "iso", "wikidata", "wikipedia"] + """ + openalex: StrictStr | None = None + iso: StrictStr | None = None + wikidata: StrictStr | None = None + wikipedia: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "iso", "wikidata", "wikipedia"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +50,11 @@ class CountryIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of CountryIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +64,7 @@ class CountryIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -76,7 +75,7 @@ class CountryIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of CountryIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/dehydrated_author.py b/service/src/main/inse/models/openalex/dehydrated_author.py index 9749c67e..4d8b3348 100644 --- a/service/src/main/inse/models/openalex/dehydrated_author.py +++ b/service/src/main/inse/models/openalex/dehydrated_author.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DehydratedAuthor(BaseModel): """ [Dehydrated Author](/api-reference/authors#the-dehydratedauthor-object) — reduced-field version used in nested contexts - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - orcid: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "orcid"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + orcid: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "orcid"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class DehydratedAuthor(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DehydratedAuthor from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class DehydratedAuthor(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class DehydratedAuthor(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DehydratedAuthor from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/dehydrated_funder.py b/service/src/main/inse/models/openalex/dehydrated_funder.py index 4a43cd35..e59d9f6a 100644 --- a/service/src/main/inse/models/openalex/dehydrated_funder.py +++ b/service/src/main/inse/models/openalex/dehydrated_funder.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DehydratedFunder(BaseModel): """ [Dehydrated Funder](/api-reference/funders) — reduced-field version used in nested contexts - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - ror: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "ror"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + ror: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "ror"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class DehydratedFunder(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DehydratedFunder from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class DehydratedFunder(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class DehydratedFunder(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DehydratedFunder from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/dehydrated_institution.py b/service/src/main/inse/models/openalex/dehydrated_institution.py index 8ecf0b25..0b43e839 100644 --- a/service/src/main/inse/models/openalex/dehydrated_institution.py +++ b/service/src/main/inse/models/openalex/dehydrated_institution.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DehydratedInstitution(BaseModel): """ [Dehydrated Institution](/api-reference/institutions#the-dehydratedinstitution-object) — reduced-field version used in nested contexts - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - ror: Optional[StrictStr] = None - country_code: Optional[StrictStr] = Field(default=None, description="[Country](/api-reference/countries) code") - type: Optional[StrictStr] = Field(default=None, description="The [institution type](/api-reference/institution-types)") - lineage: Optional[List[StrictStr]] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "ror", "country_code", "type", "lineage"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + ror: StrictStr | None = None + country_code: StrictStr | None = Field(default=None, description="[Country](/api-reference/countries) code") + type: StrictStr | None = Field(default=None, description="The [institution type](/api-reference/institution-types)") + lineage: list[StrictStr] | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "ror", "country_code", "type", "lineage"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +52,11 @@ class DehydratedInstitution(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DehydratedInstitution from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +66,7 @@ class DehydratedInstitution(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +77,7 @@ class DehydratedInstitution(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DehydratedInstitution from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/dehydrated_source.py b/service/src/main/inse/models/openalex/dehydrated_source.py index 1174194f..084ae3df 100644 --- a/service/src/main/inse/models/openalex/dehydrated_source.py +++ b/service/src/main/inse/models/openalex/dehydrated_source.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,36 +9,36 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DehydratedSource(BaseModel): """ [Dehydrated Source](/api-reference/sources#the-dehydratedsource-object) — reduced-field version used in nested contexts - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - issn_l: Optional[StrictStr] = None - issn: Optional[List[StrictStr]] = None - is_oa: Optional[StrictBool] = None - is_in_doaj: Optional[StrictBool] = None - is_core: Optional[StrictBool] = None - host_organization: Optional[StrictStr] = None - host_organization_name: Optional[StrictStr] = None - host_organization_lineage: Optional[List[StrictStr]] = None - type: Optional[StrictStr] = Field(default=None, description="The [source type](/api-reference/source-types)") - __properties: ClassVar[List[str]] = ["id", "display_name", "issn_l", "issn", "is_oa", "is_in_doaj", "is_core", "host_organization", "host_organization_name", "host_organization_lineage", "type"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + issn_l: StrictStr | None = None + issn: list[StrictStr] | None = None + is_oa: StrictBool | None = None + is_in_doaj: StrictBool | None = None + is_core: StrictBool | None = None + host_organization: StrictStr | None = None + host_organization_name: StrictStr | None = None + host_organization_lineage: list[StrictStr] | None = None + type: StrictStr | None = Field(default=None, description="The [source type](/api-reference/source-types)") + __properties: ClassVar[list[str]] = ["id", "display_name", "issn_l", "issn", "is_oa", "is_in_doaj", "is_core", "host_organization", "host_organization_name", "host_organization_lineage", "type"] model_config = ConfigDict( validate_by_name=True, @@ -58,11 +57,11 @@ class DehydratedSource(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DehydratedSource from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -72,7 +71,7 @@ class DehydratedSource(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -83,7 +82,7 @@ class DehydratedSource(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DehydratedSource from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/domain.py b/service/src/main/inse/models/openalex/domain.py index 16cec7ff..0ffd03d8 100644 --- a/service/src/main/inse/models/openalex/domain.py +++ b/service/src/main/inse/models/openalex/domain.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,40 +9,41 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.domain_fields_inner import DomainFieldsInner from inse.models.openalex.domain_ids import DomainIds -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Domain(BaseModel): """ Top-level category in the topic hierarchy (4 total) - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this domain.") - display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the domain.") - description: Optional[StrictStr] = Field(default=None, description="A description of this domain.") - display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this domain.") - fields: Optional[List[DomainFieldsInner]] = Field(default=None, description="The fields within this domain. Each object has `id` and `display_name`.") - siblings: Optional[List[DomainFieldsInner]] = Field(default=None, description="Other domains at the same level. Each object has `id` and `display_name`.") - ids: Optional[DomainIds] = None - works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with topics in this domain.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this domain.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this domain.") - created_date: Optional[date] = Field(default=None, description="When this domain was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this domain was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "fields", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this domain.") + display_name: StrictStr | None = Field(default=None, description="The English-language label of the domain.") + description: StrictStr | None = Field(default=None, description="A description of this domain.") + display_name_alternatives: list[StrictStr] | None = Field(default=None, description="Alternate names for this domain.") + fields: list[DomainFieldsInner] | None = Field(default=None, description="The fields within this domain. Each object has `id` and `display_name`.") + siblings: list[DomainFieldsInner] | None = Field(default=None, description="Other domains at the same level. Each object has `id` and `display_name`.") + ids: DomainIds | None = None + works_count: StrictInt | None = Field(default=None, description="The number of works tagged with topics in this domain.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works in this domain.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works tagged with this domain.") + created_date: date | None = Field(default=None, description="When this domain was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this domain was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "display_name_alternatives", "fields", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -62,11 +62,11 @@ class Domain(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Domain from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -76,7 +76,7 @@ class Domain(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -104,7 +104,7 @@ class Domain(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Domain from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/domain_fields_inner.py b/service/src/main/inse/models/openalex/domain_fields_inner.py index 5f5db6c6..1943ff49 100644 --- a/service/src/main/inse/models/openalex/domain_fields_inner.py +++ b/service/src/main/inse/models/openalex/domain_fields_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DomainFieldsInner(BaseModel): """ DomainFieldsInner - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class DomainFieldsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DomainFieldsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class DomainFieldsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class DomainFieldsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DomainFieldsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/domain_ids.py b/service/src/main/inse/models/openalex/domain_ids.py index 30aba687..0e14c700 100644 --- a/service/src/main/inse/models/openalex/domain_ids.py +++ b/service/src/main/inse/models/openalex/domain_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DomainIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - wikipedia: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "wikidata", "wikipedia"] + """ + openalex: StrictStr | None = None + wikidata: StrictStr | None = None + wikipedia: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "wikidata", "wikipedia"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class DomainIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DomainIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class DomainIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class DomainIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DomainIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/domains_list_response.py b/service/src/main/inse/models/openalex/domains_list_response.py index 3ea8e07c..ffa09da8 100644 --- a/service/src/main/inse/models/openalex/domains_list_response.py +++ b/service/src/main/inse/models/openalex/domains_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.domain import Domain from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class DomainsListResponse(BaseModel): """ DomainsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Domain]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[Domain] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class DomainsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DomainsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class DomainsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class DomainsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DomainsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/error.py b/service/src/main/inse/models/openalex/error.py index bbde186c..cbc6c163 100644 --- a/service/src/main/inse/models/openalex/error.py +++ b/service/src/main/inse/models/openalex/error.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Error(BaseModel): """ Error - """ # noqa: E501 - error: Optional[StrictStr] = Field(default=None, description="Error type") - message: Optional[StrictStr] = Field(default=None, description="Human-readable error message") - __properties: ClassVar[List[str]] = ["error", "message"] + """ + error: StrictStr | None = Field(default=None, description="Error type") + message: StrictStr | None = Field(default=None, description="Human-readable error message") + __properties: ClassVar[list[str]] = ["error", "message"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class Error(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Error from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class Error(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class Error(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Error from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/fields_list_response.py b/service/src/main/inse/models/openalex/fields_list_response.py index cc02907e..4013b349 100644 --- a/service/src/main/inse/models/openalex/fields_list_response.py +++ b/service/src/main/inse/models/openalex/fields_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.meta import Meta from inse.models.openalex.model_field import ModelField -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class FieldsListResponse(BaseModel): """ FieldsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[ModelField]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[ModelField] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class FieldsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of FieldsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class FieldsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class FieldsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of FieldsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/funder.py b/service/src/main/inse/models/openalex/funder.py index ef860bf1..aec40b4c 100644 --- a/service/src/main/inse/models/openalex/funder.py +++ b/service/src/main/inse/models/openalex/funder.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,44 +9,45 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.author_counts_by_year_inner import AuthorCountsByYearInner from inse.models.openalex.funder_ids import FunderIds -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Funder(BaseModel): """ An organization that funds research - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this funder.") - display_name: Optional[StrictStr] = Field(default=None, description="The primary name of the funder.") - alternate_titles: Optional[List[StrictStr]] = Field(default=None, description="A list of alternate titles for this funder.") - country_code: Optional[StrictStr] = Field(default=None, description="ISO two-letter country code where this funder is located.") - description: Optional[StrictStr] = Field(default=None, description="A short description from Wikidata.") - homepage_url: Optional[StrictStr] = Field(default=None, description="URL for this funder's primary homepage.") - image_url: Optional[StrictStr] = Field(default=None, description="URL for an image representing this funder (usually from Wikimedia).") - image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.") - grants_count: Optional[StrictInt] = Field(default=None, description="The number of grants linked to this funder.") - works_count: Optional[StrictInt] = Field(default=None, description="The number of works linked to this funder.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works linked to this funder.") - ids: Optional[FunderIds] = None - counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") - works_api_url: Optional[StrictStr] = None - created_date: Optional[date] = Field(default=None, description="When this funder was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this funder was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "alternate_titles", "country_code", "description", "homepage_url", "image_url", "image_thumbnail_url", "grants_count", "works_count", "cited_by_count", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this funder.") + display_name: StrictStr | None = Field(default=None, description="The primary name of the funder.") + alternate_titles: list[StrictStr] | None = Field(default=None, description="A list of alternate titles for this funder.") + country_code: StrictStr | None = Field(default=None, description="ISO two-letter country code where this funder is located.") + description: StrictStr | None = Field(default=None, description="A short description from Wikidata.") + homepage_url: StrictStr | None = Field(default=None, description="URL for this funder's primary homepage.") + image_url: StrictStr | None = Field(default=None, description="URL for an image representing this funder (usually from Wikimedia).") + image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.") + grants_count: StrictInt | None = Field(default=None, description="The number of grants linked to this funder.") + works_count: StrictInt | None = Field(default=None, description="The number of works linked to this funder.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works linked to this funder.") + ids: FunderIds | None = None + counts_by_year: list[AuthorCountsByYearInner] | None = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") + works_api_url: StrictStr | None = None + created_date: date | None = Field(default=None, description="When this funder was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this funder was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "alternate_titles", "country_code", "description", "homepage_url", "image_url", "image_thumbnail_url", "grants_count", "works_count", "cited_by_count", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -66,11 +66,11 @@ class Funder(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Funder from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -80,7 +80,7 @@ class Funder(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -101,7 +101,7 @@ class Funder(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Funder from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/funder_ids.py b/service/src/main/inse/models/openalex/funder_ids.py index 96bbb040..054722b3 100644 --- a/service/src/main/inse/models/openalex/funder_ids.py +++ b/service/src/main/inse/models/openalex/funder_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,30 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class FunderIds(BaseModel): """ External identifiers for this funder: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - ror: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - crossref: Optional[StrictStr] = None - doi: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "ror", "wikidata", "crossref", "doi"] + """ + openalex: StrictStr | None = None + ror: StrictStr | None = None + wikidata: StrictStr | None = None + crossref: StrictStr | None = None + doi: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "ror", "wikidata", "crossref", "doi"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class FunderIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of FunderIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class FunderIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class FunderIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of FunderIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/funders_list_response.py b/service/src/main/inse/models/openalex/funders_list_response.py index c856665c..0fc9bd8a 100644 --- a/service/src/main/inse/models/openalex/funders_list_response.py +++ b/service/src/main/inse/models/openalex/funders_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.funder import Funder from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class FundersListResponse(BaseModel): """ FundersListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Funder]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Funder] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class FundersListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of FundersListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class FundersListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class FundersListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of FundersListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/get_changefile200_response.py b/service/src/main/inse/models/openalex/get_changefile200_response.py index cd801766..5c409eef 100644 --- a/service/src/main/inse/models/openalex/get_changefile200_response.py +++ b/service/src/main/inse/models/openalex/get_changefile200_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,34 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.get_changefile200_response_meta import GetChangefile200ResponseMeta -from inse.models.openalex.get_changefile200_response_results_inner import GetChangefile200ResponseResultsInner -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.get_changefile200_response_meta import ( + GetChangefile200ResponseMeta, +) +from inse.models.openalex.get_changefile200_response_results_inner import ( + GetChangefile200ResponseResultsInner, +) + + class GetChangefile200Response(BaseModel): """ GetChangefile200Response - """ # noqa: E501 - meta: Optional[GetChangefile200ResponseMeta] = None - results: Optional[List[GetChangefile200ResponseResultsInner]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: GetChangefile200ResponseMeta | None = None + results: list[GetChangefile200ResponseResultsInner] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +55,11 @@ class GetChangefile200Response(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of GetChangefile200Response from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +69,7 @@ class GetChangefile200Response(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +90,7 @@ class GetChangefile200Response(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of GetChangefile200Response from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/get_changefile200_response_meta.py b/service/src/main/inse/models/openalex/get_changefile200_response_meta.py index 2fce5545..75c052c5 100644 --- a/service/src/main/inse/models/openalex/get_changefile200_response_meta.py +++ b/service/src/main/inse/models/openalex/get_changefile200_response_meta.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class GetChangefile200ResponseMeta(BaseModel): """ GetChangefile200ResponseMeta - """ # noqa: E501 - count: Optional[StrictInt] = Field(default=None, description="Number of entity types with changes") - var_date: Optional[date] = Field(default=None, description="The changefile date", alias="date") - __properties: ClassVar[List[str]] = ["count", "date"] + """ + count: StrictInt | None = Field(default=None, description="Number of entity types with changes") + var_date: date | None = Field(default=None, description="The changefile date", alias="date") + __properties: ClassVar[list[str]] = ["count", "date"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class GetChangefile200ResponseMeta(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of GetChangefile200ResponseMeta from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class GetChangefile200ResponseMeta(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class GetChangefile200ResponseMeta(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of GetChangefile200ResponseMeta from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner.py b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner.py index 39639cf2..ed7403e3 100644 --- a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner.py +++ b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.get_changefile200_response_results_inner_formats import GetChangefile200ResponseResultsInnerFormats -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.get_changefile200_response_results_inner_formats import ( + GetChangefile200ResponseResultsInnerFormats, +) + + class GetChangefile200ResponseResultsInner(BaseModel): """ GetChangefile200ResponseResultsInner - """ # noqa: E501 - entity: Optional[StrictStr] = Field(default=None, description="The entity type (e.g., works, authors, institutions)") - records: Optional[StrictInt] = Field(default=None, description="Number of created or modified records") - formats: Optional[GetChangefile200ResponseResultsInnerFormats] = None - __properties: ClassVar[List[str]] = ["entity", "records", "formats"] + """ + entity: StrictStr | None = Field(default=None, description="The entity type (e.g., works, authors, institutions)") + records: StrictInt | None = Field(default=None, description="Number of created or modified records") + formats: GetChangefile200ResponseResultsInnerFormats | None = None + __properties: ClassVar[list[str]] = ["entity", "records", "formats"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +53,11 @@ class GetChangefile200ResponseResultsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +67,7 @@ class GetChangefile200ResponseResultsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +81,7 @@ class GetChangefile200ResponseResultsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats.py b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats.py index a78c2bac..25ef67e7 100644 --- a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats.py +++ b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,34 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.get_changefile200_response_results_inner_formats_jsonl import GetChangefile200ResponseResultsInnerFormatsJsonl -from inse.models.openalex.get_changefile200_response_results_inner_formats_parquet import GetChangefile200ResponseResultsInnerFormatsParquet -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.get_changefile200_response_results_inner_formats_jsonl import ( + GetChangefile200ResponseResultsInnerFormatsJsonl, +) +from inse.models.openalex.get_changefile200_response_results_inner_formats_parquet import ( + GetChangefile200ResponseResultsInnerFormatsParquet, +) + + class GetChangefile200ResponseResultsInnerFormats(BaseModel): """ GetChangefile200ResponseResultsInnerFormats - """ # noqa: E501 - jsonl: Optional[GetChangefile200ResponseResultsInnerFormatsJsonl] = None - parquet: Optional[GetChangefile200ResponseResultsInnerFormatsParquet] = None - __properties: ClassVar[List[str]] = ["jsonl", "parquet"] + """ + jsonl: GetChangefile200ResponseResultsInnerFormatsJsonl | None = None + parquet: GetChangefile200ResponseResultsInnerFormatsParquet | None = None + __properties: ClassVar[list[str]] = ["jsonl", "parquet"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +55,11 @@ class GetChangefile200ResponseResultsInnerFormats(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInnerFormats from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +69,7 @@ class GetChangefile200ResponseResultsInnerFormats(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -82,7 +86,7 @@ class GetChangefile200ResponseResultsInnerFormats(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInnerFormats from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_jsonl.py b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_jsonl.py index 09f3ceed..84eecb6e 100644 --- a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_jsonl.py +++ b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_jsonl.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class GetChangefile200ResponseResultsInnerFormatsJsonl(BaseModel): """ GetChangefile200ResponseResultsInnerFormatsJsonl - """ # noqa: E501 - size_bytes: Optional[StrictInt] = Field(default=None, description="File size in bytes") - size_display: Optional[StrictStr] = Field(default=None, description="Human-readable file size") - url: Optional[StrictStr] = Field(default=None, description="Download URL for gzipped JSONL file") - __properties: ClassVar[List[str]] = ["size_bytes", "size_display", "url"] + """ + size_bytes: StrictInt | None = Field(default=None, description="File size in bytes") + size_display: StrictStr | None = Field(default=None, description="Human-readable file size") + url: StrictStr | None = Field(default=None, description="Download URL for gzipped JSONL file") + __properties: ClassVar[list[str]] = ["size_bytes", "size_display", "url"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class GetChangefile200ResponseResultsInnerFormatsJsonl(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInnerFormatsJsonl from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class GetChangefile200ResponseResultsInnerFormatsJsonl(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class GetChangefile200ResponseResultsInnerFormatsJsonl(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInnerFormatsJsonl from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_parquet.py b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_parquet.py index fc295753..e1041c5a 100644 --- a/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_parquet.py +++ b/service/src/main/inse/models/openalex/get_changefile200_response_results_inner_formats_parquet.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class GetChangefile200ResponseResultsInnerFormatsParquet(BaseModel): """ GetChangefile200ResponseResultsInnerFormatsParquet - """ # noqa: E501 - size_bytes: Optional[StrictInt] = Field(default=None, description="File size in bytes") - size_display: Optional[StrictStr] = Field(default=None, description="Human-readable file size") - url: Optional[StrictStr] = Field(default=None, description="Download URL for Parquet file") - __properties: ClassVar[List[str]] = ["size_bytes", "size_display", "url"] + """ + size_bytes: StrictInt | None = Field(default=None, description="File size in bytes") + size_display: StrictStr | None = Field(default=None, description="Human-readable file size") + url: StrictStr | None = Field(default=None, description="Download URL for Parquet file") + __properties: ClassVar[list[str]] = ["size_bytes", "size_display", "url"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class GetChangefile200ResponseResultsInnerFormatsParquet(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInnerFormatsParquet from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class GetChangefile200ResponseResultsInnerFormatsParquet(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class GetChangefile200ResponseResultsInnerFormatsParquet(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of GetChangefile200ResponseResultsInnerFormatsParquet from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/group_by_result.py b/service/src/main/inse/models/openalex/group_by_result.py index a41bfff4..4c7578f8 100644 --- a/service/src/main/inse/models/openalex/group_by_result.py +++ b/service/src/main/inse/models/openalex/group_by_result.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class GroupByResult(BaseModel): """ GroupByResult - """ # noqa: E501 - key: Optional[StrictStr] = Field(default=None, description="The group key value") - key_display_name: Optional[StrictStr] = Field(default=None, description="Human-readable name for the key") - count: Optional[StrictInt] = Field(default=None, description="Number of results in this group") - __properties: ClassVar[List[str]] = ["key", "key_display_name", "count"] + """ + key: StrictStr | None = Field(default=None, description="The group key value") + key_display_name: StrictStr | None = Field(default=None, description="Human-readable name for the key") + count: StrictInt | None = Field(default=None, description="Number of results in this group") + __properties: ClassVar[list[str]] = ["key", "key_display_name", "count"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class GroupByResult(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of GroupByResult from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class GroupByResult(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class GroupByResult(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of GroupByResult from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/institution.py b/service/src/main/inse/models/openalex/institution.py index 1d1062b5..deede4f7 100644 --- a/service/src/main/inse/models/openalex/institution.py +++ b/service/src/main/inse/models/openalex/institution.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,50 +9,51 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.author_counts_by_year_inner import AuthorCountsByYearInner from inse.models.openalex.author_summary_stats import AuthorSummaryStats from inse.models.openalex.institution_geo import InstitutionGeo from inse.models.openalex.institution_ids import InstitutionIds -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Institution(BaseModel): """ A university, research organization, or other affiliation - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this institution.", json_schema_extra={"examples": ["https://openalex.org/I27837315"]}) - ror: Optional[StrictStr] = Field(default=None, description="The ROR ID for this institution. This is the Canonical External ID for institutions.") - display_name: Optional[StrictStr] = Field(default=None, description="The primary name of the institution.") - country_code: Optional[StrictStr] = Field(default=None, description="ISO two-letter country code where this institution is located.") - type: Optional[StrictStr] = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`.") - homepage_url: Optional[StrictStr] = Field(default=None, description="URL for the institution's primary homepage.") - image_url: Optional[StrictStr] = Field(default=None, description="URL for an image representing this institution (usually from Wikimedia).") - image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.") - display_name_acronyms: Optional[List[StrictStr]] = Field(default=None, description="Acronyms or initialisms for this institution.") - display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Other names people may use for this institution.") - works_count: Optional[StrictInt] = Field(default=None, description="The number of works created by authors affiliated with this institution.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works from authors affiliated with this institution.") - summary_stats: Optional[AuthorSummaryStats] = None - geo: Optional[InstitutionGeo] = None - lineage: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs including this institution and any parent institutions.") - ids: Optional[InstitutionIds] = None - counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all works affiliated with this institution.") - created_date: Optional[date] = Field(default=None, description="When this institution was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this institution was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "ror", "display_name", "country_code", "type", "homepage_url", "image_url", "image_thumbnail_url", "display_name_acronyms", "display_name_alternatives", "works_count", "cited_by_count", "summary_stats", "geo", "lineage", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this institution.", json_schema_extra={"examples": ["https://openalex.org/I27837315"]}) + ror: StrictStr | None = Field(default=None, description="The ROR ID for this institution. This is the Canonical External ID for institutions.") + display_name: StrictStr | None = Field(default=None, description="The primary name of the institution.") + country_code: StrictStr | None = Field(default=None, description="ISO two-letter country code where this institution is located.") + type: StrictStr | None = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`.") + homepage_url: StrictStr | None = Field(default=None, description="URL for the institution's primary homepage.") + image_url: StrictStr | None = Field(default=None, description="URL for an image representing this institution (usually from Wikimedia).") + image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.") + display_name_acronyms: list[StrictStr] | None = Field(default=None, description="Acronyms or initialisms for this institution.") + display_name_alternatives: list[StrictStr] | None = Field(default=None, description="Other names people may use for this institution.") + works_count: StrictInt | None = Field(default=None, description="The number of works created by authors affiliated with this institution.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works from authors affiliated with this institution.") + summary_stats: AuthorSummaryStats | None = None + geo: InstitutionGeo | None = None + lineage: list[StrictStr] | None = Field(default=None, description="OpenAlex IDs including this institution and any parent institutions.") + ids: InstitutionIds | None = None + counts_by_year: list[AuthorCountsByYearInner] | None = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that will get you a list of all works affiliated with this institution.") + created_date: date | None = Field(default=None, description="When this institution was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this institution was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "ror", "display_name", "country_code", "type", "homepage_url", "image_url", "image_thumbnail_url", "display_name_acronyms", "display_name_alternatives", "works_count", "cited_by_count", "summary_stats", "geo", "lineage", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"] @field_validator('type') def type_validate_enum(cls, value): @@ -82,11 +82,11 @@ class Institution(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Institution from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -96,7 +96,7 @@ class Institution(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -123,7 +123,7 @@ class Institution(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Institution from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/institution_geo.py b/service/src/main/inse/models/openalex/institution_geo.py index 5b2b7781..8748c87a 100644 --- a/service/src/main/inse/models/openalex/institution_geo.py +++ b/service/src/main/inse/models/openalex/institution_geo.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,32 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class InstitutionGeo(BaseModel): """ Location information: - """ # noqa: E501 - city: Optional[StrictStr] = None - geonames_city_id: Optional[StrictStr] = None - region: Optional[StrictStr] = None - country_code: Optional[StrictStr] = None - country: Optional[StrictStr] = None - latitude: Optional[Union[StrictFloat, StrictInt]] = None - longitude: Optional[Union[StrictFloat, StrictInt]] = None - __properties: ClassVar[List[str]] = ["city", "geonames_city_id", "region", "country_code", "country", "latitude", "longitude"] + """ + city: StrictStr | None = None + geonames_city_id: StrictStr | None = None + region: StrictStr | None = None + country_code: StrictStr | None = None + country: StrictStr | None = None + latitude: StrictFloat | StrictInt | None = None + longitude: StrictFloat | StrictInt | None = None + __properties: ClassVar[list[str]] = ["city", "geonames_city_id", "region", "country_code", "country", "latitude", "longitude"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class InstitutionGeo(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of InstitutionGeo from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class InstitutionGeo(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class InstitutionGeo(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of InstitutionGeo from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/institution_ids.py b/service/src/main/inse/models/openalex/institution_ids.py index 4e4f363d..6350e226 100644 --- a/service/src/main/inse/models/openalex/institution_ids.py +++ b/service/src/main/inse/models/openalex/institution_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class InstitutionIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - ror: Optional[StrictStr] = None - mag: Optional[StrictInt] = None - grid: Optional[StrictStr] = None - wikipedia: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "ror", "mag", "grid", "wikipedia", "wikidata"] + """ + openalex: StrictStr | None = None + ror: StrictStr | None = None + mag: StrictInt | None = None + grid: StrictStr | None = None + wikipedia: StrictStr | None = None + wikidata: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "ror", "mag", "grid", "wikipedia", "wikidata"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +52,11 @@ class InstitutionIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of InstitutionIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +66,7 @@ class InstitutionIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +77,7 @@ class InstitutionIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of InstitutionIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/institution_type.py b/service/src/main/inse/models/openalex/institution_type.py index 0a2e4291..bb6035a2 100644 --- a/service/src/main/inse/models/openalex/institution_type.py +++ b/service/src/main/inse/models/openalex/institution_type.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,33 +9,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class InstitutionType(BaseModel): """ Type of institution - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - works_count: Optional[StrictInt] = None - cited_by_count: Optional[StrictInt] = None - works_api_url: Optional[StrictStr] = None - created_date: Optional[date] = None - updated_date: Optional[datetime] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + works_count: StrictInt | None = None + cited_by_count: StrictInt | None = None + works_api_url: StrictStr | None = None + created_date: date | None = None + updated_date: datetime | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -55,11 +54,11 @@ class InstitutionType(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of InstitutionType from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -69,7 +68,7 @@ class InstitutionType(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -80,7 +79,7 @@ class InstitutionType(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of InstitutionType from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/institution_types_list_response.py b/service/src/main/inse/models/openalex/institution_types_list_response.py index c06b2e4b..15f513e1 100644 --- a/service/src/main/inse/models/openalex/institution_types_list_response.py +++ b/service/src/main/inse/models/openalex/institution_types_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.institution_type import InstitutionType from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class InstitutionTypesListResponse(BaseModel): """ InstitutionTypesListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[InstitutionType]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[InstitutionType] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class InstitutionTypesListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of InstitutionTypesListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class InstitutionTypesListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class InstitutionTypesListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of InstitutionTypesListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/institutions_list_response.py b/service/src/main/inse/models/openalex/institutions_list_response.py index f3313a74..8d8c6297 100644 --- a/service/src/main/inse/models/openalex/institutions_list_response.py +++ b/service/src/main/inse/models/openalex/institutions_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.institution import Institution from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class InstitutionsListResponse(BaseModel): """ InstitutionsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Institution]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Institution] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class InstitutionsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of InstitutionsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class InstitutionsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class InstitutionsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of InstitutionsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/keyword.py b/service/src/main/inse/models/openalex/keyword.py index a436b4b6..9ca7decf 100644 --- a/service/src/main/inse/models/openalex/keyword.py +++ b/service/src/main/inse/models/openalex/keyword.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,33 +9,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Keyword(BaseModel): """ A keyword identified from works' topics - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this keyword.") - display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the keyword.") - works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with this keyword.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="The total citations to works tagged with this keyword.") - works_api_url: Optional[StrictStr] = None - created_date: Optional[date] = Field(default=None, description="When this keyword was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this keyword was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this keyword.") + display_name: StrictStr | None = Field(default=None, description="The English-language label of the keyword.") + works_count: StrictInt | None = Field(default=None, description="The number of works tagged with this keyword.") + cited_by_count: StrictInt | None = Field(default=None, description="The total citations to works tagged with this keyword.") + works_api_url: StrictStr | None = None + created_date: date | None = Field(default=None, description="When this keyword was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this keyword was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -55,11 +54,11 @@ class Keyword(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Keyword from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -69,7 +68,7 @@ class Keyword(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -80,7 +79,7 @@ class Keyword(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Keyword from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/keywords_list_response.py b/service/src/main/inse/models/openalex/keywords_list_response.py index ef7676a2..fc554fe3 100644 --- a/service/src/main/inse/models/openalex/keywords_list_response.py +++ b/service/src/main/inse/models/openalex/keywords_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.keyword import Keyword from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class KeywordsListResponse(BaseModel): """ KeywordsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Keyword]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Keyword] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class KeywordsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of KeywordsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class KeywordsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class KeywordsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of KeywordsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/language.py b/service/src/main/inse/models/openalex/language.py index a983c074..d1e4a002 100644 --- a/service/src/main/inse/models/openalex/language.py +++ b/service/src/main/inse/models/openalex/language.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,33 +9,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Language(BaseModel): """ Language of scholarly works - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this language (uses ISO 639-1 codes).") - display_name: Optional[StrictStr] = Field(default=None, description="The name of the language.") - works_count: Optional[StrictInt] = Field(default=None, description="The number of works written in this language.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this language.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works in this language.") - created_date: Optional[date] = Field(default=None, description="When this language was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this language was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this language (uses ISO 639-1 codes).") + display_name: StrictStr | None = Field(default=None, description="The name of the language.") + works_count: StrictInt | None = Field(default=None, description="The number of works written in this language.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works in this language.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works in this language.") + created_date: date | None = Field(default=None, description="When this language was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this language was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -55,11 +54,11 @@ class Language(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Language from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -69,7 +68,7 @@ class Language(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -80,7 +79,7 @@ class Language(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Language from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/languages_list_response.py b/service/src/main/inse/models/openalex/languages_list_response.py index 6c4cc2c1..9b4ae530 100644 --- a/service/src/main/inse/models/openalex/languages_list_response.py +++ b/service/src/main/inse/models/openalex/languages_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.language import Language from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class LanguagesListResponse(BaseModel): """ LanguagesListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Language]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[Language] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class LanguagesListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of LanguagesListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class LanguagesListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class LanguagesListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of LanguagesListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/license.py b/service/src/main/inse/models/openalex/license.py index 7083e2ec..61c35b0d 100644 --- a/service/src/main/inse/models/openalex/license.py +++ b/service/src/main/inse/models/openalex/license.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,35 +9,35 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class License(BaseModel): """ Open access license - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - url: Optional[StrictStr] = None - description: Optional[StrictStr] = None - works_count: Optional[StrictInt] = None - cited_by_count: Optional[StrictInt] = None - works_api_url: Optional[StrictStr] = None - created_date: Optional[date] = None - updated_date: Optional[datetime] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "url", "description", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + url: StrictStr | None = None + description: StrictStr | None = None + works_count: StrictInt | None = None + cited_by_count: StrictInt | None = None + works_api_url: StrictStr | None = None + created_date: date | None = None + updated_date: datetime | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "url", "description", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -57,11 +56,11 @@ class License(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of License from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -71,7 +70,7 @@ class License(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -82,7 +81,7 @@ class License(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of License from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/licenses_list_response.py b/service/src/main/inse/models/openalex/licenses_list_response.py index d94b15c0..d262414d 100644 --- a/service/src/main/inse/models/openalex/licenses_list_response.py +++ b/service/src/main/inse/models/openalex/licenses_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.license import License from inse.models.openalex.meta import Meta -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class LicensesListResponse(BaseModel): """ LicensesListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[License]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[License] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class LicensesListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of LicensesListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class LicensesListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class LicensesListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of LicensesListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/list_changefiles200_response.py b/service/src/main/inse/models/openalex/list_changefiles200_response.py index a183d821..87be1dbf 100644 --- a/service/src/main/inse/models/openalex/list_changefiles200_response.py +++ b/service/src/main/inse/models/openalex/list_changefiles200_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,34 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.list_changefiles200_response_meta import ListChangefiles200ResponseMeta -from inse.models.openalex.list_changefiles200_response_results_inner import ListChangefiles200ResponseResultsInner -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.list_changefiles200_response_meta import ( + ListChangefiles200ResponseMeta, +) +from inse.models.openalex.list_changefiles200_response_results_inner import ( + ListChangefiles200ResponseResultsInner, +) + + class ListChangefiles200Response(BaseModel): """ ListChangefiles200Response - """ # noqa: E501 - meta: Optional[ListChangefiles200ResponseMeta] = None - results: Optional[List[ListChangefiles200ResponseResultsInner]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: ListChangefiles200ResponseMeta | None = None + results: list[ListChangefiles200ResponseResultsInner] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +55,11 @@ class ListChangefiles200Response(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ListChangefiles200Response from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +69,7 @@ class ListChangefiles200Response(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +90,7 @@ class ListChangefiles200Response(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ListChangefiles200Response from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/list_changefiles200_response_meta.py b/service/src/main/inse/models/openalex/list_changefiles200_response_meta.py index 53a11886..f81d4439 100644 --- a/service/src/main/inse/models/openalex/list_changefiles200_response_meta.py +++ b/service/src/main/inse/models/openalex/list_changefiles200_response_meta.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,26 +9,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class ListChangefiles200ResponseMeta(BaseModel): """ ListChangefiles200ResponseMeta - """ # noqa: E501 - count: Optional[StrictInt] = Field(default=None, description="Number of available changefile dates") - __properties: ClassVar[List[str]] = ["count"] + """ + count: StrictInt | None = Field(default=None, description="Number of available changefile dates") + __properties: ClassVar[list[str]] = ["count"] model_config = ConfigDict( validate_by_name=True, @@ -48,11 +47,11 @@ class ListChangefiles200ResponseMeta(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ListChangefiles200ResponseMeta from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -62,7 +61,7 @@ class ListChangefiles200ResponseMeta(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -73,7 +72,7 @@ class ListChangefiles200ResponseMeta(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ListChangefiles200ResponseMeta from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/list_changefiles200_response_results_inner.py b/service/src/main/inse/models/openalex/list_changefiles200_response_results_inner.py index 2f25c3e7..62f12de9 100644 --- a/service/src/main/inse/models/openalex/list_changefiles200_response_results_inner.py +++ b/service/src/main/inse/models/openalex/list_changefiles200_response_results_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class ListChangefiles200ResponseResultsInner(BaseModel): """ ListChangefiles200ResponseResultsInner - """ # noqa: E501 - var_date: Optional[date] = Field(default=None, description="The changefile date (YYYY-MM-DD)", alias="date") - url: Optional[StrictStr] = Field(default=None, description="URL to get details and download links for this date") - __properties: ClassVar[List[str]] = ["date", "url"] + """ + var_date: date | None = Field(default=None, description="The changefile date (YYYY-MM-DD)", alias="date") + url: StrictStr | None = Field(default=None, description="URL to get details and download links for this date") + __properties: ClassVar[list[str]] = ["date", "url"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class ListChangefiles200ResponseResultsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ListChangefiles200ResponseResultsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class ListChangefiles200ResponseResultsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class ListChangefiles200ResponseResultsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ListChangefiles200ResponseResultsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/location.py b/service/src/main/inse/models/openalex/location.py index a2b88732..01c291df 100644 --- a/service/src/main/inse/models/openalex/location.py +++ b/service/src/main/inse/models/openalex/location.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,35 +9,43 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.dehydrated_source import DehydratedSource -from typing import Optional, Set -from typing_extensions import Self +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) from pydantic_core import to_jsonable_python +from inse.models.openalex.dehydrated_source import DehydratedSource + + class Location(BaseModel): """ Where a work is hosted - """ # noqa: E501 - is_oa: Optional[StrictBool] = Field(default=None, description="Whether this location provides open access") - landing_page_url: Optional[StrictStr] = Field(default=None, description="URL to the landing page") - pdf_url: Optional[StrictStr] = Field(default=None, description="Direct URL to PDF") - source: Optional[DehydratedSource] = Field(default=None, description="[Dehydrated source](/api-reference/sources#the-dehydratedsource-object)") - license: Optional[StrictStr] = Field(default=None, description="The [license](/api-reference/licenses) (e.g., cc-by)") - license_id: Optional[StrictStr] = None - version: Optional[StrictStr] = Field(default=None, description="Version of the work at this location") - is_accepted: Optional[StrictBool] = None - is_published: Optional[StrictBool] = None - __properties: ClassVar[List[str]] = ["is_oa", "landing_page_url", "pdf_url", "source", "license", "license_id", "version", "is_accepted", "is_published"] + """ + is_oa: StrictBool | None = Field(default=None, description="Whether this location provides open access") + landing_page_url: StrictStr | None = Field(default=None, description="URL to the landing page") + pdf_url: StrictStr | None = Field(default=None, description="Direct URL to PDF") + source: DehydratedSource | None = Field(default=None, description="[Dehydrated source](/api-reference/sources#the-dehydratedsource-object)") + license: StrictStr | None = Field(default=None, description="The [license](/api-reference/licenses) (e.g., cc-by)") + license_id: StrictStr | None = None + version: StrictStr | None = Field(default=None, description="Version of the work at this location") + is_accepted: StrictBool | None = None + is_published: StrictBool | None = None + __properties: ClassVar[list[str]] = ["is_oa", "landing_page_url", "pdf_url", "source", "license", "license_id", "version", "is_accepted", "is_published"] @field_validator('version') def version_validate_enum(cls, value): @@ -67,11 +74,11 @@ class Location(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Location from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -81,7 +88,7 @@ class Location(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +102,7 @@ class Location(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Location from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/lsf_person.py b/service/src/main/inse/models/openalex/lsf_person.py index 2820d56c..41fc6b06 100644 --- a/service/src/main/inse/models/openalex/lsf_person.py +++ b/service/src/main/inse/models/openalex/lsf_person.py @@ -1,4 +1,3 @@ -from typing import List, Optional from pydantic import BaseModel, Field, StrictStr @@ -13,40 +12,40 @@ class LsfPerson(BaseModel): name: StrictStr = Field(description="The name of the person.") firstname: StrictStr = Field(description="The first name of the person.") surname: StrictStr = Field(description="The last name of the person.") - title: Optional[StrictStr] = Field( + title: StrictStr | None = Field( default=None, description="The title of the person." ) - location: Optional[StrictStr] = Field( + location: StrictStr | None = Field( default=None, description="The location of the person." ) - room: Optional[StrictStr] = Field( + room: StrictStr | None = Field( default=None, description="The room of the person." ) - telefon: Optional[StrictStr] = Field( + telefon: StrictStr | None = Field( default=None, description="The telephone number of the person." ) - telefax: Optional[StrictStr] = Field( + telefax: StrictStr | None = Field( default=None, description="The telefax number of the person." ) - mail: Optional[StrictStr] = Field( + mail: StrictStr | None = Field( default=None, description="The email address of the person." ) - website: Optional[StrictStr] = Field( + website: StrictStr | None = Field( default=None, description="The website of the person." ) - affiliation_university: Optional[StrictStr] = Field( + affiliation_university: StrictStr | None = Field( default=None, description="The university affiliation of the person." ) - affiliation_faculty: Optional[StrictStr] = Field( + affiliation_faculty: StrictStr | None = Field( default=None, description="The faculty affiliation of the person." ) - affiliation_institute: Optional[StrictStr] = Field( + affiliation_institute: StrictStr | None = Field( default=None, description="The institute affiliation of the person." ) - affiliation_chair: Optional[StrictStr] = Field( + affiliation_chair: StrictStr | None = Field( default=None, description="The chair affiliation of the person." ) - functions: List[Function] = Field(description="The functions of the person.") + functions: list[Function] = Field(description="The functions of the person.") @classmethod def from_dict(cls, data: dict) -> "LsfPerson": diff --git a/service/src/main/inse/models/openalex/meta.py b/service/src/main/inse/models/openalex/meta.py index 833e3d79..3939ba4a 100644 --- a/service/src/main/inse/models/openalex/meta.py +++ b/service/src/main/inse/models/openalex/meta.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,32 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Meta(BaseModel): """ Metadata about the query results - """ # noqa: E501 - count: Optional[StrictInt] = Field(default=None, description="Total number of results matching the query") - db_response_time_ms: Optional[StrictInt] = Field(default=None, description="Database response time in milliseconds") - page: Optional[StrictInt] = Field(default=None, description="Current page number") - per_page: Optional[StrictInt] = Field(default=None, description="Number of results per page") - next_cursor: Optional[StrictStr] = Field(default=None, description="Cursor for the next page (when using cursor pagination)") - groups_count: Optional[StrictInt] = Field(default=None, description="Number of groups when using group_by") - cost_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Cost of this request in USD") - __properties: ClassVar[List[str]] = ["count", "db_response_time_ms", "page", "per_page", "next_cursor", "groups_count", "cost_usd"] + """ + count: StrictInt | None = Field(default=None, description="Total number of results matching the query") + db_response_time_ms: StrictInt | None = Field(default=None, description="Database response time in milliseconds") + page: StrictInt | None = Field(default=None, description="Current page number") + per_page: StrictInt | None = Field(default=None, description="Number of results per page") + next_cursor: StrictStr | None = Field(default=None, description="Cursor for the next page (when using cursor pagination)") + groups_count: StrictInt | None = Field(default=None, description="Number of groups when using group_by") + cost_usd: StrictFloat | StrictInt | None = Field(default=None, description="Cost of this request in USD") + __properties: ClassVar[list[str]] = ["count", "db_response_time_ms", "page", "per_page", "next_cursor", "groups_count", "cost_usd"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class Meta(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Meta from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class Meta(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class Meta(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Meta from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/model_field.py b/service/src/main/inse/models/openalex/model_field.py index ce3c8afc..da24f3b3 100644 --- a/service/src/main/inse/models/openalex/model_field.py +++ b/service/src/main/inse/models/openalex/model_field.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,42 +9,43 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.domain_fields_inner import DomainFieldsInner from inse.models.openalex.domain_ids import DomainIds from inse.models.openalex.work_topic_domain import WorkTopicDomain -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class ModelField(BaseModel): """ Second-level category in the topic hierarchy (26 total) - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this field.") - display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the field.") - description: Optional[StrictStr] = Field(default=None, description="A description of this field.") - display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this field.") - domain: Optional[WorkTopicDomain] = None - subfields: Optional[List[DomainFieldsInner]] = Field(default=None, description="The subfields within this field. Each object has `id` and `display_name`.") - siblings: Optional[List[DomainFieldsInner]] = Field(default=None, description="Other fields at the same level. Each object has `id` and `display_name`.") - ids: Optional[DomainIds] = None - works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with topics in this field.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this field.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this field.") - created_date: Optional[date] = Field(default=None, description="When this field was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this field was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "domain", "subfields", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this field.") + display_name: StrictStr | None = Field(default=None, description="The English-language label of the field.") + description: StrictStr | None = Field(default=None, description="A description of this field.") + display_name_alternatives: list[StrictStr] | None = Field(default=None, description="Alternate names for this field.") + domain: WorkTopicDomain | None = None + subfields: list[DomainFieldsInner] | None = Field(default=None, description="The subfields within this field. Each object has `id` and `display_name`.") + siblings: list[DomainFieldsInner] | None = Field(default=None, description="Other fields at the same level. Each object has `id` and `display_name`.") + ids: DomainIds | None = None + works_count: StrictInt | None = Field(default=None, description="The number of works tagged with topics in this field.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works in this field.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works tagged with this field.") + created_date: date | None = Field(default=None, description="When this field was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this field was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "display_name_alternatives", "domain", "subfields", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -64,11 +64,11 @@ class ModelField(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ModelField from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -78,7 +78,7 @@ class ModelField(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -109,7 +109,7 @@ class ModelField(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ModelField from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/open_access.py b/service/src/main/inse/models/openalex/open_access.py index 740c89b2..2f9496ab 100644 --- a/service/src/main/inse/models/openalex/open_access.py +++ b/service/src/main/inse/models/openalex/open_access.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,36 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictStr, + field_validator, +) from pydantic_core import to_jsonable_python + class OpenAccess(BaseModel): """ Open access information - """ # noqa: E501 - is_oa: Optional[StrictBool] = Field(default=None, description="Whether this work is open access") - oa_status: Optional[StrictStr] = Field(default=None, description="Open access status") - oa_url: Optional[StrictStr] = Field(default=None, description="Best open access URL") - any_repository_has_fulltext: Optional[StrictBool] = Field(default=None, description="Whether any repository has the full text") - __properties: ClassVar[List[str]] = ["is_oa", "oa_status", "oa_url", "any_repository_has_fulltext"] + """ + is_oa: StrictBool | None = Field(default=None, description="Whether this work is open access") + oa_status: StrictStr | None = Field(default=None, description="Open access status") + oa_url: StrictStr | None = Field(default=None, description="Best open access URL") + any_repository_has_fulltext: StrictBool | None = Field(default=None, description="Whether any repository has the full text") + __properties: ClassVar[list[str]] = ["is_oa", "oa_status", "oa_url", "any_repository_has_fulltext"] @field_validator('oa_status') def oa_status_validate_enum(cls, value): @@ -61,11 +67,11 @@ class OpenAccess(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of OpenAccess from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -75,7 +81,7 @@ class OpenAccess(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +92,7 @@ class OpenAccess(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of OpenAccess from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/publisher.py b/service/src/main/inse/models/openalex/publisher.py index 57e477c8..5afdd235 100644 --- a/service/src/main/inse/models/openalex/publisher.py +++ b/service/src/main/inse/models/openalex/publisher.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,43 +9,44 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.author_counts_by_year_inner import AuthorCountsByYearInner from inse.models.openalex.publisher_ids import PublisherIds from inse.models.openalex.publisher_parent_publisher import PublisherParentPublisher -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Publisher(BaseModel): """ An organization that publishes scholarly works - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this publisher.") - display_name: Optional[StrictStr] = Field(default=None, description="The primary name of the publisher.") - alternate_titles: Optional[List[StrictStr]] = Field(default=None, description="Alternate titles for this publisher (including translations).") - country_codes: Optional[List[StrictStr]] = Field(default=None, description="ISO two-letter country codes where the publisher is primarily located.") - hierarchy_level: Optional[StrictInt] = Field(default=None, description="The hierarchy level for this publisher. Level 0 has no parent publishers.") - parent_publisher: Optional[PublisherParentPublisher] = None - lineage: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs including this publisher and any parent publishers.") - works_count: Optional[StrictInt] = Field(default=None, description="The number of works published by this publisher.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works linked to this publisher.") - sources_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all sources published by this publisher.") - ids: Optional[PublisherIds] = None - counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") - created_date: Optional[date] = Field(default=None, description="When this publisher was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this publisher was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "alternate_titles", "country_codes", "hierarchy_level", "parent_publisher", "lineage", "works_count", "cited_by_count", "sources_api_url", "ids", "counts_by_year", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this publisher.") + display_name: StrictStr | None = Field(default=None, description="The primary name of the publisher.") + alternate_titles: list[StrictStr] | None = Field(default=None, description="Alternate titles for this publisher (including translations).") + country_codes: list[StrictStr] | None = Field(default=None, description="ISO two-letter country codes where the publisher is primarily located.") + hierarchy_level: StrictInt | None = Field(default=None, description="The hierarchy level for this publisher. Level 0 has no parent publishers.") + parent_publisher: PublisherParentPublisher | None = None + lineage: list[StrictStr] | None = Field(default=None, description="OpenAlex IDs including this publisher and any parent publishers.") + works_count: StrictInt | None = Field(default=None, description="The number of works published by this publisher.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works linked to this publisher.") + sources_api_url: StrictStr | None = Field(default=None, description="A URL that will get you a list of all sources published by this publisher.") + ids: PublisherIds | None = None + counts_by_year: list[AuthorCountsByYearInner] | None = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") + created_date: date | None = Field(default=None, description="When this publisher was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this publisher was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "alternate_titles", "country_codes", "hierarchy_level", "parent_publisher", "lineage", "works_count", "cited_by_count", "sources_api_url", "ids", "counts_by_year", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -65,11 +65,11 @@ class Publisher(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Publisher from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -79,7 +79,7 @@ class Publisher(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -103,7 +103,7 @@ class Publisher(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Publisher from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/publisher_ids.py b/service/src/main/inse/models/openalex/publisher_ids.py index 57c2f8b5..e5bfba29 100644 --- a/service/src/main/inse/models/openalex/publisher_ids.py +++ b/service/src/main/inse/models/openalex/publisher_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class PublisherIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - ror: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "ror", "wikidata"] + """ + openalex: StrictStr | None = None + ror: StrictStr | None = None + wikidata: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "ror", "wikidata"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class PublisherIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of PublisherIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class PublisherIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class PublisherIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of PublisherIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/publisher_parent_publisher.py b/service/src/main/inse/models/openalex/publisher_parent_publisher.py index 14412f61..3fa0ba02 100644 --- a/service/src/main/inse/models/openalex/publisher_parent_publisher.py +++ b/service/src/main/inse/models/openalex/publisher_parent_publisher.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class PublisherParentPublisher(BaseModel): """ OpenAlex ID of the direct parent publisher. Null if `hierarchy_level` is 0. - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class PublisherParentPublisher(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of PublisherParentPublisher from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class PublisherParentPublisher(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class PublisherParentPublisher(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of PublisherParentPublisher from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/publishers_list_response.py b/service/src/main/inse/models/openalex/publishers_list_response.py index 1dc91eab..8940efc6 100644 --- a/service/src/main/inse/models/openalex/publishers_list_response.py +++ b/service/src/main/inse/models/openalex/publishers_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.meta import Meta from inse.models.openalex.publisher import Publisher -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class PublishersListResponse(BaseModel): """ PublishersListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Publisher]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Publisher] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class PublishersListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of PublishersListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class PublishersListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class PublishersListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of PublishersListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/rate_limit_response.py b/service/src/main/inse/models/openalex/rate_limit_response.py index 2508594b..9c3f73c3 100644 --- a/service/src/main/inse/models/openalex/rate_limit_response.py +++ b/service/src/main/inse/models/openalex/rate_limit_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.rate_limit_response_rate_limit import RateLimitResponseRateLimit -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.rate_limit_response_rate_limit import ( + RateLimitResponseRateLimit, +) + + class RateLimitResponse(BaseModel): """ RateLimitResponse - """ # noqa: E501 - api_key: Optional[StrictStr] = None - rate_limit: Optional[RateLimitResponseRateLimit] = None - __properties: ClassVar[List[str]] = ["api_key", "rate_limit"] + """ + api_key: StrictStr | None = None + rate_limit: RateLimitResponseRateLimit | None = None + __properties: ClassVar[list[str]] = ["api_key", "rate_limit"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +52,11 @@ class RateLimitResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of RateLimitResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +66,7 @@ class RateLimitResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +80,7 @@ class RateLimitResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of RateLimitResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/rate_limit_response_rate_limit.py b/service/src/main/inse/models/openalex/rate_limit_response_rate_limit.py index 324aee1d..0e0df1b6 100644 --- a/service/src/main/inse/models/openalex/rate_limit_response_rate_limit.py +++ b/service/src/main/inse/models/openalex/rate_limit_response_rate_limit.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,40 +9,43 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt -from typing import Any, ClassVar, Dict, List, Optional, Union -from inse.models.openalex.rate_limit_response_rate_limit_endpoint_costs_usd import RateLimitResponseRateLimitEndpointCostsUsd -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.rate_limit_response_rate_limit_endpoint_costs_usd import ( + RateLimitResponseRateLimitEndpointCostsUsd, +) + + class RateLimitResponseRateLimit(BaseModel): """ RateLimitResponseRateLimit - """ # noqa: E501 - daily_budget_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Your daily usage allowance in USD") - daily_used_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount used today in USD") - daily_remaining_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Remaining daily allowance in USD") - prepaid_balance_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Total prepaid balance in USD") - prepaid_remaining_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Remaining prepaid balance in USD") - prepaid_expires_at: Optional[datetime] = Field(default=None, description="When prepaid balance expires") - resets_at: Optional[datetime] = None - resets_in_seconds: Optional[StrictInt] = None - endpoint_costs_usd: Optional[RateLimitResponseRateLimitEndpointCostsUsd] = None - credits_limit: Optional[StrictInt] = Field(default=None, description="Deprecated. Use daily_budget_usd instead.") - credits_used: Optional[StrictInt] = Field(default=None, description="Deprecated. Use daily_used_usd instead.") - credits_remaining: Optional[StrictInt] = Field(default=None, description="Deprecated. Use daily_remaining_usd instead.") - credit_costs: Optional[Dict[str, Any]] = Field(default=None, description="Deprecated. Use endpoint_costs_usd instead.") - __properties: ClassVar[List[str]] = ["daily_budget_usd", "daily_used_usd", "daily_remaining_usd", "prepaid_balance_usd", "prepaid_remaining_usd", "prepaid_expires_at", "resets_at", "resets_in_seconds", "endpoint_costs_usd", "credits_limit", "credits_used", "credits_remaining", "credit_costs"] + """ + daily_budget_usd: StrictFloat | StrictInt | None = Field(default=None, description="Your daily usage allowance in USD") + daily_used_usd: StrictFloat | StrictInt | None = Field(default=None, description="Amount used today in USD") + daily_remaining_usd: StrictFloat | StrictInt | None = Field(default=None, description="Remaining daily allowance in USD") + prepaid_balance_usd: StrictFloat | StrictInt | None = Field(default=None, description="Total prepaid balance in USD") + prepaid_remaining_usd: StrictFloat | StrictInt | None = Field(default=None, description="Remaining prepaid balance in USD") + prepaid_expires_at: datetime | None = Field(default=None, description="When prepaid balance expires") + resets_at: datetime | None = None + resets_in_seconds: StrictInt | None = None + endpoint_costs_usd: RateLimitResponseRateLimitEndpointCostsUsd | None = None + credits_limit: StrictInt | None = Field(default=None, description="Deprecated. Use daily_budget_usd instead.") + credits_used: StrictInt | None = Field(default=None, description="Deprecated. Use daily_used_usd instead.") + credits_remaining: StrictInt | None = Field(default=None, description="Deprecated. Use daily_remaining_usd instead.") + credit_costs: dict[str, Any] | None = Field(default=None, description="Deprecated. Use endpoint_costs_usd instead.") + __properties: ClassVar[list[str]] = ["daily_budget_usd", "daily_used_usd", "daily_remaining_usd", "prepaid_balance_usd", "prepaid_remaining_usd", "prepaid_expires_at", "resets_at", "resets_in_seconds", "endpoint_costs_usd", "credits_limit", "credits_used", "credits_remaining", "credit_costs"] model_config = ConfigDict( validate_by_name=True, @@ -62,11 +64,11 @@ class RateLimitResponseRateLimit(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of RateLimitResponseRateLimit from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -76,7 +78,7 @@ class RateLimitResponseRateLimit(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -90,7 +92,7 @@ class RateLimitResponseRateLimit(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of RateLimitResponseRateLimit from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/rate_limit_response_rate_limit_endpoint_costs_usd.py b/service/src/main/inse/models/openalex/rate_limit_response_rate_limit_endpoint_costs_usd.py index 432d9b0c..8e70bfed 100644 --- a/service/src/main/inse/models/openalex/rate_limit_response_rate_limit_endpoint_costs_usd.py +++ b/service/src/main/inse/models/openalex/rate_limit_response_rate_limit_endpoint_costs_usd.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import builtins +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class RateLimitResponseRateLimitEndpointCostsUsd(BaseModel): """ Cost per request in USD for each endpoint type - """ # noqa: E501 - singleton: Optional[Union[StrictFloat, StrictInt]] = None - list: Optional[Union[StrictFloat, StrictInt]] = None - search: Optional[Union[StrictFloat, StrictInt]] = None - content: Optional[Union[StrictFloat, StrictInt]] = None - semantic: Optional[Union[StrictFloat, StrictInt]] = None - text: Optional[Union[StrictFloat, StrictInt]] = None - __properties: ClassVar[List[str]] = ["singleton", "list", "search", "content", "semantic", "text"] + """ + singleton: StrictFloat | StrictInt | None = None + list: StrictFloat | StrictInt | None = None + search: StrictFloat | StrictInt | None = None + content: StrictFloat | StrictInt | None = None + semantic: StrictFloat | StrictInt | None = None + text: StrictFloat | StrictInt | None = None + __properties: ClassVar[builtins.list[str]] = ["singleton", "list", "search", "content", "semantic", "text"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class RateLimitResponseRateLimitEndpointCostsUsd(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of RateLimitResponseRateLimitEndpointCostsUsd from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class RateLimitResponseRateLimitEndpointCostsUsd(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +78,7 @@ class RateLimitResponseRateLimitEndpointCostsUsd(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of RateLimitResponseRateLimitEndpointCostsUsd from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/sdg.py b/service/src/main/inse/models/openalex/sdg.py index 64180e96..b5c3e09d 100644 --- a/service/src/main/inse/models/openalex/sdg.py +++ b/service/src/main/inse/models/openalex/sdg.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,38 +9,39 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.sdg_ids import SdgIds -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.sdg_ids import SdgIds + + class Sdg(BaseModel): """ UN Sustainable Development Goal (17 total) - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this SDG.") - display_name: Optional[StrictStr] = Field(default=None, description="The name of the SDG.") - description: Optional[StrictStr] = Field(default=None, description="The official UN description of this goal.") - ids: Optional[SdgIds] = None - works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with this SDG.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works tagged with this SDG.") - image_url: Optional[StrictStr] = Field(default=None, description="URL to the official SDG icon image.") - image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this SDG.") - created_date: Optional[date] = Field(default=None, description="When this SDG was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this SDG was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "ids", "works_count", "cited_by_count", "image_url", "image_thumbnail_url", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this SDG.") + display_name: StrictStr | None = Field(default=None, description="The name of the SDG.") + description: StrictStr | None = Field(default=None, description="The official UN description of this goal.") + ids: SdgIds | None = None + works_count: StrictInt | None = Field(default=None, description="The number of works tagged with this SDG.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works tagged with this SDG.") + image_url: StrictStr | None = Field(default=None, description="URL to the official SDG icon image.") + image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works tagged with this SDG.") + created_date: date | None = Field(default=None, description="When this SDG was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this SDG was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "ids", "works_count", "cited_by_count", "image_url", "image_thumbnail_url", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -60,11 +60,11 @@ class Sdg(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Sdg from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -74,7 +74,7 @@ class Sdg(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -88,7 +88,7 @@ class Sdg(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Sdg from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/sdg_ids.py b/service/src/main/inse/models/openalex/sdg_ids.py index 103d4ccd..4b387cab 100644 --- a/service/src/main/inse/models/openalex/sdg_ids.py +++ b/service/src/main/inse/models/openalex/sdg_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class SdgIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - un: Optional[StrictStr] = None - wikidata: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "un", "wikidata"] + """ + openalex: StrictStr | None = None + un: StrictStr | None = None + wikidata: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "un", "wikidata"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class SdgIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SdgIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class SdgIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class SdgIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SdgIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/sdgs_list_response.py b/service/src/main/inse/models/openalex/sdgs_list_response.py index f2b680b2..1368e3d4 100644 --- a/service/src/main/inse/models/openalex/sdgs_list_response.py +++ b/service/src/main/inse/models/openalex/sdgs_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.meta import Meta from inse.models.openalex.sdg import Sdg -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class SdgsListResponse(BaseModel): """ SdgsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Sdg]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[Sdg] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class SdgsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SdgsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class SdgsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class SdgsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SdgsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/source.py b/service/src/main/inse/models/openalex/source.py index bdfefdf3..82e241eb 100644 --- a/service/src/main/inse/models/openalex/source.py +++ b/service/src/main/inse/models/openalex/source.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,49 +9,58 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictInt, + StrictStr, + field_validator, +) +from pydantic_core import to_jsonable_python + from inse.models.openalex.author_counts_by_year_inner import AuthorCountsByYearInner from inse.models.openalex.author_summary_stats import AuthorSummaryStats from inse.models.openalex.source_ids import SourceIds -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Source(BaseModel): """ A journal, repository, or other venue for scholarly works - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this source.") - issn_l: Optional[StrictStr] = Field(default=None, description="The ISSN-L (linking ISSN) for this source. This is the Canonical External ID for sources.") - issn: Optional[List[StrictStr]] = Field(default=None, description="All ISSNs used by this source. Many publications have multiple ISSNs.") - display_name: Optional[StrictStr] = Field(default=None, description="The name of the source.") - type: Optional[StrictStr] = Field(default=None, description="The type of source: `journal`, `repository`, `conference`, `ebook platform`, `book series`, `metadata`, or `other`.") - host_organization: Optional[StrictStr] = Field(default=None, description="The host organization as an OpenAlex ID. This will be an Institution ID if the source is a repository, or a Publisher ID if it's a journal/conference.") - host_organization_name: Optional[StrictStr] = Field(default=None, description="The display_name of the host organization.") - host_organization_lineage: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs of parent publishers (only for publisher-hosted sources).") - is_oa: Optional[StrictBool] = Field(default=None, description="Whether this is currently a fully open-access source.") - is_in_doaj: Optional[StrictBool] = Field(default=None, description="Whether this journal is listed in the Directory of Open Access Journals.") - works_count: Optional[StrictInt] = Field(default=None, description="The number of works this source hosts.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works hosted in this source.") - summary_stats: Optional[AuthorSummaryStats] = None - apc_usd: Optional[StrictInt] = Field(default=None, description="The source's article processing charge in USD.") - homepage_url: Optional[StrictStr] = Field(default=None, description="The homepage URL for this source.") - ids: Optional[SourceIds] = None - counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all this source's works.") - created_date: Optional[date] = Field(default=None, description="When this source was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this source was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "issn_l", "issn", "display_name", "type", "host_organization", "host_organization_name", "host_organization_lineage", "is_oa", "is_in_doaj", "works_count", "cited_by_count", "summary_stats", "apc_usd", "homepage_url", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this source.") + issn_l: StrictStr | None = Field(default=None, description="The ISSN-L (linking ISSN) for this source. This is the Canonical External ID for sources.") + issn: list[StrictStr] | None = Field(default=None, description="All ISSNs used by this source. Many publications have multiple ISSNs.") + display_name: StrictStr | None = Field(default=None, description="The name of the source.") + type: StrictStr | None = Field(default=None, description="The type of source: `journal`, `repository`, `conference`, `ebook platform`, `book series`, `metadata`, or `other`.") + host_organization: StrictStr | None = Field(default=None, description="The host organization as an OpenAlex ID. This will be an Institution ID if the source is a repository, or a Publisher ID if it's a journal/conference.") + host_organization_name: StrictStr | None = Field(default=None, description="The display_name of the host organization.") + host_organization_lineage: list[StrictStr] | None = Field(default=None, description="OpenAlex IDs of parent publishers (only for publisher-hosted sources).") + is_oa: StrictBool | None = Field(default=None, description="Whether this is currently a fully open-access source.") + is_in_doaj: StrictBool | None = Field(default=None, description="Whether this journal is listed in the Directory of Open Access Journals.") + works_count: StrictInt | None = Field(default=None, description="The number of works this source hosts.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works hosted in this source.") + summary_stats: AuthorSummaryStats | None = None + apc_usd: StrictInt | None = Field(default=None, description="The source's article processing charge in USD.") + homepage_url: StrictStr | None = Field(default=None, description="The homepage URL for this source.") + ids: SourceIds | None = None + counts_by_year: list[AuthorCountsByYearInner] | None = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that will get you a list of all this source's works.") + created_date: date | None = Field(default=None, description="When this source was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this source was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "issn_l", "issn", "display_name", "type", "host_organization", "host_organization_name", "host_organization_lineage", "is_oa", "is_in_doaj", "works_count", "cited_by_count", "summary_stats", "apc_usd", "homepage_url", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"] @field_validator('type') def type_validate_enum(cls, value): @@ -81,11 +89,11 @@ class Source(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Source from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -95,7 +103,7 @@ class Source(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -119,7 +127,7 @@ class Source(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Source from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/source_ids.py b/service/src/main/inse/models/openalex/source_ids.py index b8c7c185..765ba273 100644 --- a/service/src/main/inse/models/openalex/source_ids.py +++ b/service/src/main/inse/models/openalex/source_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class SourceIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - issn_l: Optional[StrictStr] = None - issn: Optional[List[StrictStr]] = None - mag: Optional[StrictInt] = None - wikidata: Optional[StrictStr] = None - fatcat: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "issn_l", "issn", "mag", "wikidata", "fatcat"] + """ + openalex: StrictStr | None = None + issn_l: StrictStr | None = None + issn: list[StrictStr] | None = None + mag: StrictInt | None = None + wikidata: StrictStr | None = None + fatcat: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "issn_l", "issn", "mag", "wikidata", "fatcat"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +52,11 @@ class SourceIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SourceIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +66,7 @@ class SourceIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +77,7 @@ class SourceIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SourceIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/source_type.py b/service/src/main/inse/models/openalex/source_type.py index 8811321b..804d465f 100644 --- a/service/src/main/inse/models/openalex/source_type.py +++ b/service/src/main/inse/models/openalex/source_type.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,33 +9,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class SourceType(BaseModel): """ Type of source - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - works_count: Optional[StrictInt] = None - cited_by_count: Optional[StrictInt] = None - works_api_url: Optional[StrictStr] = None - created_date: Optional[date] = None - updated_date: Optional[datetime] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + works_count: StrictInt | None = None + cited_by_count: StrictInt | None = None + works_api_url: StrictStr | None = None + created_date: date | None = None + updated_date: datetime | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -55,11 +54,11 @@ class SourceType(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SourceType from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -69,7 +68,7 @@ class SourceType(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -80,7 +79,7 @@ class SourceType(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SourceType from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/source_types_list_response.py b/service/src/main/inse/models/openalex/source_types_list_response.py index 9f2f552c..ff98a416 100644 --- a/service/src/main/inse/models/openalex/source_types_list_response.py +++ b/service/src/main/inse/models/openalex/source_types_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.meta import Meta from inse.models.openalex.source_type import SourceType -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class SourceTypesListResponse(BaseModel): """ SourceTypesListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[SourceType]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[SourceType] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class SourceTypesListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SourceTypesListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class SourceTypesListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class SourceTypesListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SourceTypesListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/sources_list_response.py b/service/src/main/inse/models/openalex/sources_list_response.py index a9d1710e..d1ac5a60 100644 --- a/service/src/main/inse/models/openalex/sources_list_response.py +++ b/service/src/main/inse/models/openalex/sources_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.meta import Meta from inse.models.openalex.source import Source -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class SourcesListResponse(BaseModel): """ SourcesListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Source]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Source] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class SourcesListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SourcesListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class SourcesListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class SourcesListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SourcesListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/subfield.py b/service/src/main/inse/models/openalex/subfield.py index b4edd67c..337e9a17 100644 --- a/service/src/main/inse/models/openalex/subfield.py +++ b/service/src/main/inse/models/openalex/subfield.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,44 +9,45 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.domain_fields_inner import DomainFieldsInner from inse.models.openalex.domain_ids import DomainIds from inse.models.openalex.subfield_domain import SubfieldDomain from inse.models.openalex.subfield_field import SubfieldField -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Subfield(BaseModel): """ Third-level category in the topic hierarchy (254 total) - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this subfield.") - display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the subfield.") - description: Optional[StrictStr] = Field(default=None, description="A description of this subfield.") - display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this subfield.") - var_field: Optional[SubfieldField] = Field(default=None, alias="field") - domain: Optional[SubfieldDomain] = None - topics: Optional[List[DomainFieldsInner]] = Field(default=None, description="The topics within this subfield. Each object has `id` and `display_name`.") - siblings: Optional[List[DomainFieldsInner]] = Field(default=None, description="Other subfields at the same level (across all fields). Each object has `id` and `display_name`.") - ids: Optional[DomainIds] = None - works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with topics in this subfield.") - cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this subfield.") - works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this subfield.") - created_date: Optional[date] = Field(default=None, description="When this subfield was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this subfield was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "field", "domain", "topics", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this subfield.") + display_name: StrictStr | None = Field(default=None, description="The English-language label of the subfield.") + description: StrictStr | None = Field(default=None, description="A description of this subfield.") + display_name_alternatives: list[StrictStr] | None = Field(default=None, description="Alternate names for this subfield.") + var_field: SubfieldField | None = Field(default=None, alias="field") + domain: SubfieldDomain | None = None + topics: list[DomainFieldsInner] | None = Field(default=None, description="The topics within this subfield. Each object has `id` and `display_name`.") + siblings: list[DomainFieldsInner] | None = Field(default=None, description="Other subfields at the same level (across all fields). Each object has `id` and `display_name`.") + ids: DomainIds | None = None + works_count: StrictInt | None = Field(default=None, description="The number of works tagged with topics in this subfield.") + cited_by_count: StrictInt | None = Field(default=None, description="Total citations to works in this subfield.") + works_api_url: StrictStr | None = Field(default=None, description="A URL that returns all works tagged with this subfield.") + created_date: date | None = Field(default=None, description="When this subfield was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this subfield was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "display_name_alternatives", "field", "domain", "topics", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -66,11 +66,11 @@ class Subfield(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Subfield from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -80,7 +80,7 @@ class Subfield(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -114,7 +114,7 @@ class Subfield(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Subfield from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/subfield_domain.py b/service/src/main/inse/models/openalex/subfield_domain.py index e3997b3e..7d85a6d4 100644 --- a/service/src/main/inse/models/openalex/subfield_domain.py +++ b/service/src/main/inse/models/openalex/subfield_domain.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class SubfieldDomain(BaseModel): """ The domain containing this subfield (top level of hierarchy). - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class SubfieldDomain(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SubfieldDomain from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class SubfieldDomain(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class SubfieldDomain(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SubfieldDomain from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/subfield_field.py b/service/src/main/inse/models/openalex/subfield_field.py index 8d8d1c23..b2d20233 100644 --- a/service/src/main/inse/models/openalex/subfield_field.py +++ b/service/src/main/inse/models/openalex/subfield_field.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class SubfieldField(BaseModel): """ The field containing this subfield (parent level). - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class SubfieldField(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SubfieldField from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class SubfieldField(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class SubfieldField(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SubfieldField from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/subfields_list_response.py b/service/src/main/inse/models/openalex/subfields_list_response.py index d3721a4d..3a179da0 100644 --- a/service/src/main/inse/models/openalex/subfields_list_response.py +++ b/service/src/main/inse/models/openalex/subfields_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.meta import Meta from inse.models.openalex.subfield import Subfield -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class SubfieldsListResponse(BaseModel): """ SubfieldsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Subfield]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[Subfield] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class SubfieldsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of SubfieldsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class SubfieldsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class SubfieldsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of SubfieldsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/text_classification_response.py b/service/src/main/inse/models/openalex/text_classification_response.py index e72b2ba6..16485b95 100644 --- a/service/src/main/inse/models/openalex/text_classification_response.py +++ b/service/src/main/inse/models/openalex/text_classification_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.openalex.text_classification_response_meta import TextClassificationResponseMeta -from inse.models.openalex.work_topic import WorkTopic -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python +from inse.models.openalex.text_classification_response_meta import ( + TextClassificationResponseMeta, +) +from inse.models.openalex.work_topic import WorkTopic + + class TextClassificationResponse(BaseModel): """ TextClassificationResponse - """ # noqa: E501 - meta: Optional[TextClassificationResponseMeta] = None - results: Optional[List[WorkTopic]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: TextClassificationResponseMeta | None = None + results: list[WorkTopic] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +53,11 @@ class TextClassificationResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TextClassificationResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +67,7 @@ class TextClassificationResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +88,7 @@ class TextClassificationResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TextClassificationResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/text_classification_response_meta.py b/service/src/main/inse/models/openalex/text_classification_response_meta.py index 86c76ee1..65048451 100644 --- a/service/src/main/inse/models/openalex/text_classification_response_meta.py +++ b/service/src/main/inse/models/openalex/text_classification_response_meta.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,26 +9,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class TextClassificationResponseMeta(BaseModel): """ TextClassificationResponseMeta - """ # noqa: E501 - count: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["count"] + """ + count: StrictInt | None = None + __properties: ClassVar[list[str]] = ["count"] model_config = ConfigDict( validate_by_name=True, @@ -48,11 +47,11 @@ class TextClassificationResponseMeta(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TextClassificationResponseMeta from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -62,7 +61,7 @@ class TextClassificationResponseMeta(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -73,7 +72,7 @@ class TextClassificationResponseMeta(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TextClassificationResponseMeta from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/topic.py b/service/src/main/inse/models/openalex/topic.py index 2085a784..3527d9b2 100644 --- a/service/src/main/inse/models/openalex/topic.py +++ b/service/src/main/inse/models/openalex/topic.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,44 +9,45 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.topic_domain import TopicDomain from inse.models.openalex.topic_field import TopicField from inse.models.openalex.topic_ids import TopicIds from inse.models.openalex.topic_subfield import TopicSubfield -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Topic(BaseModel): """ A research topic automatically assigned to works - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this topic.") - display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the topic.") - description: Optional[StrictStr] = Field(default=None, description="A description of this topic, generated by AI.") - keywords: Optional[List[StrictStr]] = Field(default=None, description="Keywords representing the content of papers in the topic.") - subfield: Optional[TopicSubfield] = None - var_field: Optional[TopicField] = Field(default=None, alias="field") - field: Optional[TopicField] = Field(default=None) - domain: Optional[TopicDomain] = None - works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with this topic.") - cited_by_count: Optional[StrictInt] = None - ids: Optional[TopicIds] = None - works_api_url: Optional[StrictStr] = None - created_date: Optional[date] = None - updated_date: Optional[datetime] = Field(default=None, description="When this topic was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "keywords", "subfield", "field", "domain", "works_count", "cited_by_count", "ids", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this topic.") + display_name: StrictStr | None = Field(default=None, description="The English-language label of the topic.") + description: StrictStr | None = Field(default=None, description="A description of this topic, generated by AI.") + keywords: list[StrictStr] | None = Field(default=None, description="Keywords representing the content of papers in the topic.") + subfield: TopicSubfield | None = None + var_field: TopicField | None = Field(default=None, alias="field") + field: TopicField | None = Field(default=None) + domain: TopicDomain | None = None + works_count: StrictInt | None = Field(default=None, description="The number of works tagged with this topic.") + cited_by_count: StrictInt | None = None + ids: TopicIds | None = None + works_api_url: StrictStr | None = None + created_date: date | None = None + updated_date: datetime | None = Field(default=None, description="When this topic was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "keywords", "subfield", "field", "domain", "works_count", "cited_by_count", "ids", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -66,11 +66,11 @@ class Topic(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Topic from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -80,7 +80,7 @@ class Topic(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -103,7 +103,7 @@ class Topic(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Topic from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/topic_count.py b/service/src/main/inse/models/openalex/topic_count.py index 8d6be897..dc53212f 100644 --- a/service/src/main/inse/models/openalex/topic_count.py +++ b/service/src/main/inse/models/openalex/topic_count.py @@ -1,46 +1,45 @@ -from typing import Optional from pydantic import BaseModel, Field class TopicCount(BaseModel): - id: Optional[str] = Field(default=None, description="The topic id.") + id: str | None = Field(default=None, description="The topic id.") name: str = Field(description="The topic display name.") count: int = Field(default=0, description="The number of occurrences.") - description: Optional[str] = Field(default=None, description="The topic description.") - subfield_id: Optional[str] = Field( + description: str | None = Field(default=None, description="The topic description.") + subfield_id: str | None = Field( default=None, description="The topic subfield id.", ) - subfield_name: Optional[str] = Field( + subfield_name: str | None = Field( default=None, description="The topic subfield display name.", ) - subfield_description: Optional[str] = Field( + subfield_description: str | None = Field( default=None, description="The topic subfield description.", ) - field_id: Optional[str] = Field( + field_id: str | None = Field( default=None, description="The topic field id.", ) - field_name: Optional[str] = Field( + field_name: str | None = Field( default=None, description="The topic field display name.", ) - field_description: Optional[str] = Field( + field_description: str | None = Field( default=None, description="The topic field description.", ) - domain_id: Optional[str] = Field( + domain_id: str | None = Field( default=None, description="The topic domain id.", ) - domain_name: Optional[str] = Field( + domain_name: str | None = Field( default=None, description="The topic domain display name.", ) - domain_description: Optional[str] = Field( + domain_description: str | None = Field( default=None, description="The topic domain description.", ) diff --git a/service/src/main/inse/models/openalex/topic_domain.py b/service/src/main/inse/models/openalex/topic_domain.py index 75546c88..080323db 100644 --- a/service/src/main/inse/models/openalex/topic_domain.py +++ b/service/src/main/inse/models/openalex/topic_domain.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class TopicDomain(BaseModel): """ The domain (highest level) containing this topic: - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class TopicDomain(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TopicDomain from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class TopicDomain(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class TopicDomain(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TopicDomain from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/topic_field.py b/service/src/main/inse/models/openalex/topic_field.py index 939f5016..f0f090c6 100644 --- a/service/src/main/inse/models/openalex/topic_field.py +++ b/service/src/main/inse/models/openalex/topic_field.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class TopicField(BaseModel): """ The field (second level) containing this topic: - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class TopicField(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TopicField from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class TopicField(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class TopicField(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TopicField from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/topic_ids.py b/service/src/main/inse/models/openalex/topic_ids.py index b4de5f84..d6250f81 100644 --- a/service/src/main/inse/models/openalex/topic_ids.py +++ b/service/src/main/inse/models/openalex/topic_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class TopicIds(BaseModel): """ External identifiers: - """ # noqa: E501 - openalex: Optional[StrictStr] = None - wikipedia: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "wikipedia"] + """ + openalex: StrictStr | None = None + wikipedia: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "wikipedia"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class TopicIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TopicIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class TopicIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class TopicIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TopicIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/topic_subfield.py b/service/src/main/inse/models/openalex/topic_subfield.py index 0dc545bc..15335e01 100644 --- a/service/src/main/inse/models/openalex/topic_subfield.py +++ b/service/src/main/inse/models/openalex/topic_subfield.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class TopicSubfield(BaseModel): """ The subfield (third level) containing this topic: - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class TopicSubfield(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TopicSubfield from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class TopicSubfield(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class TopicSubfield(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TopicSubfield from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/topics_by_time.py b/service/src/main/inse/models/openalex/topics_by_time.py index e02863bb..9bfb258b 100644 --- a/service/src/main/inse/models/openalex/topics_by_time.py +++ b/service/src/main/inse/models/openalex/topics_by_time.py @@ -1,4 +1,3 @@ -from typing import List from pydantic import BaseModel, Field @@ -6,7 +5,7 @@ from inse.models.openalex.topics_by_year import TopicsByYear class TopicsByTime(BaseModel): - elements: List[TopicsByYear] = Field( + elements: list[TopicsByYear] = Field( default_factory=list, description="Topics grouped by year.", ) diff --git a/service/src/main/inse/models/openalex/topics_by_year.py b/service/src/main/inse/models/openalex/topics_by_year.py index 48fd0f6e..0ef39be4 100644 --- a/service/src/main/inse/models/openalex/topics_by_year.py +++ b/service/src/main/inse/models/openalex/topics_by_year.py @@ -1,4 +1,3 @@ -from typing import List from pydantic import BaseModel, Field @@ -8,5 +7,5 @@ from inse.models.openalex.topic_count import TopicCount class TopicsByYear(BaseModel): year: int = Field(description="The publication year.") publication_count: int = Field(default=0, description="The number of works in this year.") - topics: List[TopicCount] = Field(default_factory=list, description="The topics in this year.") - primary_topics: List[TopicCount] = Field(default_factory=list, description="The primary topics in this year.") + topics: list[TopicCount] = Field(default_factory=list, description="The topics in this year.") + primary_topics: list[TopicCount] = Field(default_factory=list, description="The primary topics in this year.") diff --git a/service/src/main/inse/models/openalex/topics_list_response.py b/service/src/main/inse/models/openalex/topics_list_response.py index 7ea968cc..095f738f 100644 --- a/service/src/main/inse/models/openalex/topics_list_response.py +++ b/service/src/main/inse/models/openalex/topics_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.meta import Meta from inse.models.openalex.topic import Topic -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class TopicsListResponse(BaseModel): """ TopicsListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Topic]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Topic] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class TopicsListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of TopicsListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class TopicsListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class TopicsListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of TopicsListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/ude_organization.py b/service/src/main/inse/models/openalex/ude_organization.py index 33b3ddcb..5ce38ce3 100644 --- a/service/src/main/inse/models/openalex/ude_organization.py +++ b/service/src/main/inse/models/openalex/ude_organization.py @@ -1,18 +1,17 @@ -from typing import List, Optional, Union from pydantic import BaseModel, Field, StrictStr class UdeStaff(BaseModel): - research_interests: Union[List[StrictStr], StrictStr] = Field( + research_interests: list[StrictStr] | StrictStr = Field( description="Research interests of the staff member" ) - keywords: List[StrictStr] = Field( + keywords: list[StrictStr] = Field( description="Keywords associated with the staff member" ) telefon: StrictStr = Field(description="Phone number of the staff member") name: StrictStr = Field(description="Name of the staff member") - links: List[StrictStr] = Field(description="Links associated with the staff member") + links: list[StrictStr] = Field(description="Links associated with the staff member") email: StrictStr = Field(description="Email address of the staff member") @classmethod @@ -30,11 +29,11 @@ class UdeStaff(BaseModel): class UdeProject(BaseModel): project_type: StrictStr = Field(description="Type of the project") names: StrictStr = Field(description="Names associated with the project") - keywords: List[StrictStr] = Field( + keywords: list[StrictStr] = Field( description="Keywords associated with the project" ) topic: StrictStr = Field(description="Topic of the project") - links: List[StrictStr] = Field(description="Links associated with the project") + links: list[StrictStr] = Field(description="Links associated with the project") title: StrictStr = Field(description="Title of the project") @classmethod @@ -50,10 +49,10 @@ class UdeProject(BaseModel): class UdeNews(BaseModel): - date: Optional[StrictStr] = Field(description="Date of the news") - keywords: List[StrictStr] = Field(description="Keywords associated with the news") + date: StrictStr | None = Field(description="Date of the news") + keywords: list[StrictStr] = Field(description="Keywords associated with the news") topic: StrictStr = Field(description="Topic of the news") - links: List[StrictStr] = Field(description="Links associated with the news") + links: list[StrictStr] = Field(description="Links associated with the news") title: StrictStr = Field(description="Title of the news") @classmethod @@ -81,16 +80,16 @@ class UdeKeyword(BaseModel): class UdeOrganization(BaseModel): uri: StrictStr = Field(description="URI of the organization") - staff: List[UdeStaff] = Field( + staff: list[UdeStaff] = Field( description="List of staff members in the organization" ) - projects: List[UdeProject] = Field( + projects: list[UdeProject] = Field( description="List of projects associated with the organization" ) - news: List[UdeNews] = Field( + news: list[UdeNews] = Field( description="List of news items associated with the organization" ) - keywords: List[UdeKeyword] = Field( + keywords: list[UdeKeyword] = Field( description="List of keywords associated with the organization" ) diff --git a/service/src/main/inse/models/openalex/work.py b/service/src/main/inse/models/openalex/work.py index 4661f664..31934220 100644 --- a/service/src/main/inse/models/openalex/work.py +++ b/service/src/main/inse/models/openalex/work.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,79 +9,92 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictInt, + StrictStr, +) +from pydantic_core import to_jsonable_python + from inse.models.openalex.authorship import Authorship from inse.models.openalex.award import Award from inse.models.openalex.dehydrated_funder import DehydratedFunder from inse.models.openalex.location import Location from inse.models.openalex.open_access import OpenAccess from inse.models.openalex.work_biblio import WorkBiblio -from inse.models.openalex.work_citation_normalized_percentile import WorkCitationNormalizedPercentile +from inse.models.openalex.work_citation_normalized_percentile import ( + WorkCitationNormalizedPercentile, +) from inse.models.openalex.work_cited_by_percentile_year import WorkCitedByPercentileYear from inse.models.openalex.work_counts_by_year_inner import WorkCountsByYearInner from inse.models.openalex.work_has_content import WorkHasContent from inse.models.openalex.work_ids import WorkIds from inse.models.openalex.work_keyword import WorkKeyword from inse.models.openalex.work_mesh_inner import WorkMeshInner -from inse.models.openalex.work_sustainable_development_goals_inner import WorkSustainableDevelopmentGoalsInner +from inse.models.openalex.work_sustainable_development_goals_inner import ( + WorkSustainableDevelopmentGoalsInner, +) from inse.models.openalex.work_topic import WorkTopic -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class Work(BaseModel): """ A scholarly document (article, book, dataset, thesis, etc.) - """ # noqa: E501 - id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this work.") - doi: Optional[StrictStr] = Field(default=None, description="The DOI for the work. This is the Canonical External ID for works.") - title: Optional[StrictStr] = Field(default=None, description="The title of this work.") - display_name: Optional[StrictStr] = Field(default=None, description="Same as `title`. Included for consistency with other entities.") - publication_year: Optional[StrictInt] = Field(default=None, description="The year this work was published.") - publication_date: Optional[date] = Field(default=None, description="The day when this work was published (ISO 8601 format).") - type: Optional[StrictStr] = Field(default=None, description="The type of the work. Common values: `article`, `book`, `dataset`, `preprint`, `dissertation`, `book-chapter`.") - language: Optional[StrictStr] = Field(default=None, description="[Language](/api-reference/languages) in ISO 639-1 format") - cited_by_count: Optional[StrictInt] = Field(default=None, description="The number of citations to this work.") - is_retracted: Optional[StrictBool] = Field(default=None, description="True if this work has been retracted (from Retraction Watch database).") - is_paratext: Optional[StrictBool] = Field(default=None, description="True if this work is paratext (e.g., front cover, table of contents).") - primary_location: Optional[Location] = Field(default=None, description="A Location object with the primary location of this work (closest to the version of record). Includes `source`, `landing_page_url`, `pdf_url`, `is_oa`, `license`, and `version`.") - locations: Optional[List[Location]] = Field(default=None, description="List of Location objects describing all unique places where this work lives.") - best_oa_location: Optional[Location] = Field(default=None, description="A Location object with the best available open access location for this work.") - open_access: Optional[OpenAccess] = Field(default=None, description="Information about the access status of this work:") - authorships: Optional[List[Authorship]] = Field(default=None, description="List of Authorship objects representing authors and their institutions. Limited to the first 100 authors. Each authorship includes `author`, `institutions`, `author_position`, `is_corresponding`, and other fields.") - ids: Optional[WorkIds] = None - biblio: Optional[WorkBiblio] = None - abstract_inverted_index: Optional[Dict[str, Any]] = Field(default=None, description="The abstract as an inverted index (word positions). OpenAlex doesn't include plaintext abstracts due to legal constraints. Use the `has_abstract` filter to get works with or without abstracts.") - referenced_works: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs for works that this work cites.") - referenced_works_count: Optional[StrictInt] = Field(default=None, description="The number of works that this work cites.") - related_works: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs for works related to this work (computed algorithmically).") - topics: Optional[List[WorkTopic]] = Field(default=None, description="List of up to 3 Topics for this work, each with a relevance score.") - primary_topic: Optional[WorkTopic] = Field(default=None, description="The top ranked Topic for this work, with `id`, `display_name`, `score`, and hierarchy (`subfield`, `field`, `domain`).") - keywords: Optional[List[WorkKeyword]] = Field(default=None, description="Keywords identified based on the work's topics, with relevance scores.") - funders: Optional[List[DehydratedFunder]] = Field(default=None, description="Dehydrated Funder objects representing the funders of this work.") - awards: Optional[List[Award]] = Field(default=None, description="Dehydrated Award objects representing grants associated with this work.") - fwci: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Field-weighted Citation Impact, calculated as citations received / citations expected.") - citation_normalized_percentile: Optional[WorkCitationNormalizedPercentile] = None - cited_by_percentile_year: Optional[WorkCitedByPercentileYear] = None - counts_by_year: Optional[List[WorkCountsByYearInner]] = Field(default=None, description="`cited_by_count` for each of the last ten years.") - sustainable_development_goals: Optional[List[WorkSustainableDevelopmentGoalsInner]] = Field(default=None, description="UN Sustainable Development Goals relevant to this work, with prediction scores.") - mesh: Optional[List[WorkMeshInner]] = Field(default=None, description="MeSH tags for works found in PubMed.") - indexed_in: Optional[List[StrictStr]] = Field(default=None, description="Sources this work is indexed in. Values: `arxiv`, `crossref`, `doaj`, `pubmed`.") - has_content: Optional[WorkHasContent] = None - content_url: Optional[StrictStr] = Field(default=None, description="URL for downloading full-text content. Only present when `has_content.pdf` or `has_content.grobid_xml` is true.") - created_date: Optional[date] = Field(default=None, description="When this work was added to OpenAlex (ISO 8601 date).") - updated_date: Optional[datetime] = Field(default=None, description="When this work was last updated (ISO 8601 datetime).") - __properties: ClassVar[List[str]] = ["id", "doi", "title", "display_name", "publication_year", "publication_date", "type", "language", "cited_by_count", "is_retracted", "is_paratext", "primary_location", "locations", "best_oa_location", "open_access", "authorships", "ids", "biblio", "abstract_inverted_index", "referenced_works", "referenced_works_count", "related_works", "topics", "primary_topic", "keywords", "funders", "awards", "fwci", "citation_normalized_percentile", "cited_by_percentile_year", "counts_by_year", "sustainable_development_goals", "mesh", "indexed_in", "has_content", "content_url", "created_date", "updated_date"] + """ + id: StrictStr | None = Field(default=None, description="The OpenAlex ID for this work.") + doi: StrictStr | None = Field(default=None, description="The DOI for the work. This is the Canonical External ID for works.") + title: StrictStr | None = Field(default=None, description="The title of this work.") + display_name: StrictStr | None = Field(default=None, description="Same as `title`. Included for consistency with other entities.") + publication_year: StrictInt | None = Field(default=None, description="The year this work was published.") + publication_date: date | None = Field(default=None, description="The day when this work was published (ISO 8601 format).") + type: StrictStr | None = Field(default=None, description="The type of the work. Common values: `article`, `book`, `dataset`, `preprint`, `dissertation`, `book-chapter`.") + language: StrictStr | None = Field(default=None, description="[Language](/api-reference/languages) in ISO 639-1 format") + cited_by_count: StrictInt | None = Field(default=None, description="The number of citations to this work.") + is_retracted: StrictBool | None = Field(default=None, description="True if this work has been retracted (from Retraction Watch database).") + is_paratext: StrictBool | None = Field(default=None, description="True if this work is paratext (e.g., front cover, table of contents).") + primary_location: Location | None = Field(default=None, description="A Location object with the primary location of this work (closest to the version of record). Includes `source`, `landing_page_url`, `pdf_url`, `is_oa`, `license`, and `version`.") + locations: list[Location] | None = Field(default=None, description="List of Location objects describing all unique places where this work lives.") + best_oa_location: Location | None = Field(default=None, description="A Location object with the best available open access location for this work.") + open_access: OpenAccess | None = Field(default=None, description="Information about the access status of this work:") + authorships: list[Authorship] | None = Field(default=None, description="List of Authorship objects representing authors and their institutions. Limited to the first 100 authors. Each authorship includes `author`, `institutions`, `author_position`, `is_corresponding`, and other fields.") + ids: WorkIds | None = None + biblio: WorkBiblio | None = None + abstract_inverted_index: dict[str, Any] | None = Field(default=None, description="The abstract as an inverted index (word positions). OpenAlex doesn't include plaintext abstracts due to legal constraints. Use the `has_abstract` filter to get works with or without abstracts.") + referenced_works: list[StrictStr] | None = Field(default=None, description="OpenAlex IDs for works that this work cites.") + referenced_works_count: StrictInt | None = Field(default=None, description="The number of works that this work cites.") + related_works: list[StrictStr] | None = Field(default=None, description="OpenAlex IDs for works related to this work (computed algorithmically).") + topics: list[WorkTopic] | None = Field(default=None, description="List of up to 3 Topics for this work, each with a relevance score.") + primary_topic: WorkTopic | None = Field(default=None, description="The top ranked Topic for this work, with `id`, `display_name`, `score`, and hierarchy (`subfield`, `field`, `domain`).") + keywords: list[WorkKeyword] | None = Field(default=None, description="Keywords identified based on the work's topics, with relevance scores.") + funders: list[DehydratedFunder] | None = Field(default=None, description="Dehydrated Funder objects representing the funders of this work.") + awards: list[Award] | None = Field(default=None, description="Dehydrated Award objects representing grants associated with this work.") + fwci: StrictFloat | StrictInt | None = Field(default=None, description="Field-weighted Citation Impact, calculated as citations received / citations expected.") + citation_normalized_percentile: WorkCitationNormalizedPercentile | None = None + cited_by_percentile_year: WorkCitedByPercentileYear | None = None + counts_by_year: list[WorkCountsByYearInner] | None = Field(default=None, description="`cited_by_count` for each of the last ten years.") + sustainable_development_goals: list[WorkSustainableDevelopmentGoalsInner] | None = Field(default=None, description="UN Sustainable Development Goals relevant to this work, with prediction scores.") + mesh: list[WorkMeshInner] | None = Field(default=None, description="MeSH tags for works found in PubMed.") + indexed_in: list[StrictStr] | None = Field(default=None, description="Sources this work is indexed in. Values: `arxiv`, `crossref`, `doaj`, `pubmed`.") + has_content: WorkHasContent | None = None + content_url: StrictStr | None = Field(default=None, description="URL for downloading full-text content. Only present when `has_content.pdf` or `has_content.grobid_xml` is true.") + created_date: date | None = Field(default=None, description="When this work was added to OpenAlex (ISO 8601 date).") + updated_date: datetime | None = Field(default=None, description="When this work was last updated (ISO 8601 datetime).") + __properties: ClassVar[list[str]] = ["id", "doi", "title", "display_name", "publication_year", "publication_date", "type", "language", "cited_by_count", "is_retracted", "is_paratext", "primary_location", "locations", "best_oa_location", "open_access", "authorships", "ids", "biblio", "abstract_inverted_index", "referenced_works", "referenced_works_count", "related_works", "topics", "primary_topic", "keywords", "funders", "awards", "fwci", "citation_normalized_percentile", "cited_by_percentile_year", "counts_by_year", "sustainable_development_goals", "mesh", "indexed_in", "has_content", "content_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -101,11 +113,11 @@ class Work(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Work from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -115,7 +127,7 @@ class Work(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -216,7 +228,7 @@ class Work(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Work from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_biblio.py b/service/src/main/inse/models/openalex/work_biblio.py index 8d0c7506..eaf3a791 100644 --- a/service/src/main/inse/models/openalex/work_biblio.py +++ b/service/src/main/inse/models/openalex/work_biblio.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkBiblio(BaseModel): """ Bibliographic info: `volume`, `issue`, `first_page`, `last_page`. - """ # noqa: E501 - volume: Optional[StrictStr] = None - issue: Optional[StrictStr] = None - first_page: Optional[StrictStr] = None - last_page: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["volume", "issue", "first_page", "last_page"] + """ + volume: StrictStr | None = None + issue: StrictStr | None = None + first_page: StrictStr | None = None + last_page: StrictStr | None = None + __properties: ClassVar[list[str]] = ["volume", "issue", "first_page", "last_page"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +50,11 @@ class WorkBiblio(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkBiblio from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +64,7 @@ class WorkBiblio(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -76,7 +75,7 @@ class WorkBiblio(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkBiblio from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_citation_normalized_percentile.py b/service/src/main/inse/models/openalex/work_citation_normalized_percentile.py index bf72a965..e8b2e1bb 100644 --- a/service/src/main/inse/models/openalex/work_citation_normalized_percentile.py +++ b/service/src/main/inse/models/openalex/work_citation_normalized_percentile.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkCitationNormalizedPercentile(BaseModel): """ Percentile of citation count normalized by work type, year, and subfield. Includes `value`, `is_in_top_1_percent`, `is_in_top_10_percent`. - """ # noqa: E501 - value: Optional[Union[StrictFloat, StrictInt]] = None - is_in_top_1_percent: Optional[StrictBool] = None - is_in_top_10_percent: Optional[StrictBool] = None - __properties: ClassVar[List[str]] = ["value", "is_in_top_1_percent", "is_in_top_10_percent"] + """ + value: StrictFloat | StrictInt | None = None + is_in_top_1_percent: StrictBool | None = None + is_in_top_10_percent: StrictBool | None = None + __properties: ClassVar[list[str]] = ["value", "is_in_top_1_percent", "is_in_top_10_percent"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class WorkCitationNormalizedPercentile(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkCitationNormalizedPercentile from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class WorkCitationNormalizedPercentile(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class WorkCitationNormalizedPercentile(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkCitationNormalizedPercentile from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_cited_by_percentile_year.py b/service/src/main/inse/models/openalex/work_cited_by_percentile_year.py index 6a0a3aab..d244c7a5 100644 --- a/service/src/main/inse/models/openalex/work_cited_by_percentile_year.py +++ b/service/src/main/inse/models/openalex/work_cited_by_percentile_year.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkCitedByPercentileYear(BaseModel): """ Percentile rank compared to other works published in the same year. Contains `min` and `max`. - """ # noqa: E501 - min: Optional[StrictInt] = None - max: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["min", "max"] + """ + min: StrictInt | None = None + max: StrictInt | None = None + __properties: ClassVar[list[str]] = ["min", "max"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class WorkCitedByPercentileYear(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkCitedByPercentileYear from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class WorkCitedByPercentileYear(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class WorkCitedByPercentileYear(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkCitedByPercentileYear from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_counts_by_year_inner.py b/service/src/main/inse/models/openalex/work_counts_by_year_inner.py index 592a8684..2f2db9b9 100644 --- a/service/src/main/inse/models/openalex/work_counts_by_year_inner.py +++ b/service/src/main/inse/models/openalex/work_counts_by_year_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkCountsByYearInner(BaseModel): """ WorkCountsByYearInner - """ # noqa: E501 - year: Optional[StrictInt] = None - cited_by_count: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["year", "cited_by_count"] + """ + year: StrictInt | None = None + cited_by_count: StrictInt | None = None + __properties: ClassVar[list[str]] = ["year", "cited_by_count"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class WorkCountsByYearInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkCountsByYearInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class WorkCountsByYearInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class WorkCountsByYearInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkCountsByYearInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_has_content.py b/service/src/main/inse/models/openalex/work_has_content.py index cf2e07d7..b5b80649 100644 --- a/service/src/main/inse/models/openalex/work_has_content.py +++ b/service/src/main/inse/models/openalex/work_has_content.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkHasContent(BaseModel): """ Information about downloadable full-text content: - """ # noqa: E501 - pdf: Optional[StrictBool] = None - grobid_xml: Optional[StrictBool] = None - __properties: ClassVar[List[str]] = ["pdf", "grobid_xml"] + """ + pdf: StrictBool | None = None + grobid_xml: StrictBool | None = None + __properties: ClassVar[list[str]] = ["pdf", "grobid_xml"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class WorkHasContent(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkHasContent from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class WorkHasContent(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class WorkHasContent(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkHasContent from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_ids.py b/service/src/main/inse/models/openalex/work_ids.py index f4478c3e..85fdba93 100644 --- a/service/src/main/inse/models/openalex/work_ids.py +++ b/service/src/main/inse/models/openalex/work_ids.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,30 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkIds(BaseModel): """ External identifiers: `openalex`, `doi`, `mag`, `pmid`, `pmcid`. - """ # noqa: E501 - openalex: Optional[StrictStr] = None - doi: Optional[StrictStr] = None - mag: Optional[StrictInt] = None - pmid: Optional[StrictStr] = None - pmcid: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["openalex", "doi", "mag", "pmid", "pmcid"] + """ + openalex: StrictStr | None = None + doi: StrictStr | None = None + mag: StrictInt | None = None + pmid: StrictStr | None = None + pmcid: StrictStr | None = None + __properties: ClassVar[list[str]] = ["openalex", "doi", "mag", "pmid", "pmcid"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class WorkIds(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkIds from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class WorkIds(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class WorkIds(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkIds from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_keyword.py b/service/src/main/inse/models/openalex/work_keyword.py index 55feaab6..aaf75451 100644 --- a/service/src/main/inse/models/openalex/work_keyword.py +++ b/service/src/main/inse/models/openalex/work_keyword.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkKeyword(BaseModel): """ WorkKeyword - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - score: Optional[Union[StrictFloat, StrictInt]] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "score"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + score: StrictFloat | StrictInt | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "score"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class WorkKeyword(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkKeyword from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class WorkKeyword(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class WorkKeyword(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkKeyword from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_mesh_inner.py b/service/src/main/inse/models/openalex/work_mesh_inner.py index 73d67064..ccedf595 100644 --- a/service/src/main/inse/models/openalex/work_mesh_inner.py +++ b/service/src/main/inse/models/openalex/work_mesh_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,30 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkMeshInner(BaseModel): """ WorkMeshInner - """ # noqa: E501 - descriptor_ui: Optional[StrictStr] = None - descriptor_name: Optional[StrictStr] = None - qualifier_ui: Optional[StrictStr] = None - qualifier_name: Optional[StrictStr] = None - is_major_topic: Optional[StrictBool] = None - __properties: ClassVar[List[str]] = ["descriptor_ui", "descriptor_name", "qualifier_ui", "qualifier_name", "is_major_topic"] + """ + descriptor_ui: StrictStr | None = None + descriptor_name: StrictStr | None = None + qualifier_ui: StrictStr | None = None + qualifier_name: StrictStr | None = None + is_major_topic: StrictBool | None = None + __properties: ClassVar[list[str]] = ["descriptor_ui", "descriptor_name", "qualifier_ui", "qualifier_name", "is_major_topic"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class WorkMeshInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkMeshInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class WorkMeshInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class WorkMeshInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkMeshInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_page.py b/service/src/main/inse/models/openalex/work_page.py index f9b3b6f7..9849cf5d 100644 --- a/service/src/main/inse/models/openalex/work_page.py +++ b/service/src/main/inse/models/openalex/work_page.py @@ -1,4 +1,3 @@ -from typing import List from pydantic import BaseModel, Field @@ -7,7 +6,7 @@ from inse.models.openalex.work import Work class WorkPage(BaseModel): total: int = Field(description="Total number of works matching the query") - elements: List[Work] = Field(description="List of works on the current page") + elements: list[Work] = Field(description="List of works on the current page") offset: int = Field(description="Offset of the current page") size: int = Field(description="Size of the current page") last_page: bool = Field( diff --git a/service/src/main/inse/models/openalex/work_sustainable_development_goals_inner.py b/service/src/main/inse/models/openalex/work_sustainable_development_goals_inner.py index 8ebe17d0..93c5b69e 100644 --- a/service/src/main/inse/models/openalex/work_sustainable_development_goals_inner.py +++ b/service/src/main/inse/models/openalex/work_sustainable_development_goals_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,28 +9,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkSustainableDevelopmentGoalsInner(BaseModel): """ WorkSustainableDevelopmentGoalsInner - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - score: Optional[Union[StrictFloat, StrictInt]] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "score"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + score: StrictFloat | StrictInt | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "score"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class WorkSustainableDevelopmentGoalsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkSustainableDevelopmentGoalsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class WorkSustainableDevelopmentGoalsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class WorkSustainableDevelopmentGoalsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkSustainableDevelopmentGoalsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_topic.py b/service/src/main/inse/models/openalex/work_topic.py index e780d369..d18f63cd 100644 --- a/service/src/main/inse/models/openalex/work_topic.py +++ b/service/src/main/inse/models/openalex/work_topic.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,35 +9,36 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union +from pydantic_core import to_jsonable_python + from inse.models.openalex.work_topic_domain import WorkTopicDomain from inse.models.openalex.work_topic_field import WorkTopicField from inse.models.openalex.work_topic_subfield import WorkTopicSubfield -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class WorkTopic(BaseModel): """ WorkTopic - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - description: Optional[StrictStr] = None - score: Optional[Union[StrictFloat, StrictInt]] = None - subfield: Optional[WorkTopicSubfield] = None - var_field: Optional[WorkTopicField] = Field(default=None, alias="field") - domain: Optional[WorkTopicDomain] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "score", "subfield", "field", "domain"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + description: StrictStr | None = None + score: StrictFloat | StrictInt | None = None + subfield: WorkTopicSubfield | None = None + var_field: WorkTopicField | None = Field(default=None, alias="field") + domain: WorkTopicDomain | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "score", "subfield", "field", "domain"] model_config = ConfigDict( validate_by_name=True, @@ -57,11 +57,11 @@ class WorkTopic(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkTopic from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -71,7 +71,7 @@ class WorkTopic(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -91,7 +91,7 @@ class WorkTopic(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkTopic from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_topic_domain.py b/service/src/main/inse/models/openalex/work_topic_domain.py index 0ce6021e..a83b8792 100644 --- a/service/src/main/inse/models/openalex/work_topic_domain.py +++ b/service/src/main/inse/models/openalex/work_topic_domain.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkTopicDomain(BaseModel): """ The parent [domain](/api-reference/domains) - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class WorkTopicDomain(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkTopicDomain from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class WorkTopicDomain(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class WorkTopicDomain(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkTopicDomain from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_topic_field.py b/service/src/main/inse/models/openalex/work_topic_field.py index a62147ab..0073c58b 100644 --- a/service/src/main/inse/models/openalex/work_topic_field.py +++ b/service/src/main/inse/models/openalex/work_topic_field.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkTopicField(BaseModel): """ The parent [field](/api-reference/fields) - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class WorkTopicField(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkTopicField from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class WorkTopicField(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class WorkTopicField(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkTopicField from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_topic_subfield.py b/service/src/main/inse/models/openalex/work_topic_subfield.py index 96af42a8..17e94d12 100644 --- a/service/src/main/inse/models/openalex/work_topic_subfield.py +++ b/service/src/main/inse/models/openalex/work_topic_subfield.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,27 +9,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkTopicSubfield(BaseModel): """ The parent [subfield](/api-reference/subfields) - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "display_name"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "display_name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class WorkTopicSubfield(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkTopicSubfield from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class WorkTopicSubfield(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class WorkTopicSubfield(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkTopicSubfield from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_type.py b/service/src/main/inse/models/openalex/work_type.py index 5377ada0..553f2f9f 100644 --- a/service/src/main/inse/models/openalex/work_type.py +++ b/service/src/main/inse/models/openalex/work_type.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,34 +9,34 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class WorkType(BaseModel): """ Type of scholarly work - """ # noqa: E501 - id: Optional[StrictStr] = None - display_name: Optional[StrictStr] = None - description: Optional[StrictStr] = None - works_count: Optional[StrictInt] = None - cited_by_count: Optional[StrictInt] = None - works_api_url: Optional[StrictStr] = None - created_date: Optional[date] = None - updated_date: Optional[datetime] = None - __properties: ClassVar[List[str]] = ["id", "display_name", "description", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] + """ + id: StrictStr | None = None + display_name: StrictStr | None = None + description: StrictStr | None = None + works_count: StrictInt | None = None + cited_by_count: StrictInt | None = None + works_api_url: StrictStr | None = None + created_date: date | None = None + updated_date: datetime | None = None + __properties: ClassVar[list[str]] = ["id", "display_name", "description", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"] model_config = ConfigDict( validate_by_name=True, @@ -56,11 +55,11 @@ class WorkType(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkType from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -70,7 +69,7 @@ class WorkType(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -81,7 +80,7 @@ class WorkType(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkType from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/work_types_list_response.py b/service/src/main/inse/models/openalex/work_types_list_response.py index 5acec728..33e9a79a 100644 --- a/service/src/main/inse/models/openalex/work_types_list_response.py +++ b/service/src/main/inse/models/openalex/work_types_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,29 +9,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.meta import Meta from inse.models.openalex.work_type import WorkType -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class WorkTypesListResponse(BaseModel): """ WorkTypesListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[WorkType]] = None - __properties: ClassVar[List[str]] = ["meta", "results"] + """ + meta: Meta | None = None + results: list[WorkType] | None = None + __properties: ClassVar[list[str]] = ["meta", "results"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +51,11 @@ class WorkTypesListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorkTypesListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +65,7 @@ class WorkTypesListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +86,7 @@ class WorkTypesListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorkTypesListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/openalex/works_list_response.py b/service/src/main/inse/models/openalex/works_list_response.py index c73cb975..3771280e 100644 --- a/service/src/main/inse/models/openalex/works_list_response.py +++ b/service/src/main/inse/models/openalex/works_list_response.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ OpenAlex API @@ -10,31 +9,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict -from typing import Any, ClassVar, Dict, List, Optional +from pydantic_core import to_jsonable_python + from inse.models.openalex.group_by_result import GroupByResult from inse.models.openalex.meta import Meta from inse.models.openalex.work import Work -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python + class WorksListResponse(BaseModel): """ WorksListResponse - """ # noqa: E501 - meta: Optional[Meta] = None - results: Optional[List[Work]] = None - group_by: Optional[List[GroupByResult]] = None - __properties: ClassVar[List[str]] = ["meta", "results", "group_by"] + """ + meta: Meta | None = None + results: list[Work] | None = None + group_by: list[GroupByResult] | None = None + __properties: ClassVar[list[str]] = ["meta", "results", "group_by"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +53,11 @@ class WorksListResponse(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of WorksListResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +67,7 @@ class WorksListResponse(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +95,7 @@ class WorksListResponse(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of WorksListResponse from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_epo/epo_document.py b/service/src/main/inse/models/patents_epo/epo_document.py index 53975fdc..79454e06 100644 --- a/service/src/main/inse/models/patents_epo/epo_document.py +++ b/service/src/main/inse/models/patents_epo/epo_document.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ EPO Index Backend Models @@ -9,111 +8,111 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.patents_epo.inventor_nested import InventorNested -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from pydantic_core import to_jsonable_python + class EpoDocument(BaseModel): """ Main document model for the epo_index_1.0 index. - """ # noqa: E501 - abstract: Optional[StrictStr] = None - abstract_lang: Optional[StrictStr] = None - action: Optional[StrictStr] = None - applicants: Optional[StrictStr] = None - applicants_adr: Optional[StrictStr] = None - applicants_name: Optional[StrictStr] = None - applicants_name_text: Optional[StrictStr] = None - application_filing_date: Optional[StrictStr] = None - application_number: Optional[StrictStr] = None - claims: Optional[StrictStr] = None - claims_de: Optional[StrictStr] = None - claims_en: Optional[StrictStr] = None - claims_fr: Optional[StrictStr] = None - var_class: Optional[StrictStr] = Field(default=None, alias="class") - classification_value: Optional[StrictStr] = None - country: Optional[StrictStr] = None - cpc: Optional[StrictStr] = None - cpc_text: Optional[StrictStr] = None - data1: Optional[StrictStr] = None - data2: Optional[StrictStr] = None - date_of_despatch_of_1st_exam_report: Optional[StrictStr] = None - date_of_patent_maintained_as_amended: Optional[StrictStr] = None - date_of_request_for_examination: Optional[StrictStr] = None - date_of_resumption_of_proceedings: Optional[StrictStr] = None - date_of_suspension_interruption: Optional[StrictStr] = None - date_publication: Optional[StrictInt] = None - date_publication_year: Optional[StrictInt] = None - description_header: Optional[StrictStr] = None - description_lang: Optional[StrictStr] = None - description_paragraph: Optional[StrictStr] = None - description_text: Optional[StrictStr] = None - doc_number: Optional[StrictStr] = None - extended_states: Optional[StrictStr] = None - extended_states_text: Optional[StrictStr] = None - indicates_the_type_of_suspension_or_interruption: Optional[StrictStr] = None - inventors: Optional[StrictStr] = None - inventors_adr: Optional[StrictStr] = None - inventors_name: Optional[StrictStr] = None - inventors_name_nested: Optional[List[InventorNested]] = None - inventors_name_text: Optional[StrictStr] = None - ipc: Optional[StrictStr] = None - ipc_text: Optional[StrictStr] = None - ipc_text_without: Optional[StrictStr] = None - ipc_without: Optional[StrictStr] = None - keywords_and_descriptors: Optional[StrictStr] = None - kind: Optional[StrictStr] = None - level: Optional[StrictStr] = None - linked_indexing_code: Optional[StrictStr] = None - main_group: Optional[StrictStr] = None - non_obligatory_suppl_class: Optional[StrictStr] = None - office: Optional[StrictStr] = None - position: Optional[StrictStr] = None - representatives: Optional[StrictStr] = None - representatives_adr: Optional[StrictStr] = None - representatives_name: Optional[StrictStr] = None - representatives_name_text: Optional[StrictStr] = None - request_for_conversion_to_natl_appl_country: Optional[StrictStr] = None - request_for_conversion_to_natl_appl_date: Optional[StrictStr] = None - section: Optional[StrictStr] = None - srep_abs_approval: Optional[StrictStr] = None - srep_abstract: Optional[StrictStr] = None - srep_date_produced: Optional[StrictStr] = None - srep_established: Optional[StrictStr] = None - srep_file_reference_id: Optional[StrictStr] = None - srep_invention_title: Optional[StrictStr] = None - srep_invention_title_approval: Optional[StrictStr] = None - srep_lang: Optional[StrictStr] = None - srep_office: Optional[StrictStr] = None - srep_protest_fees: Optional[StrictStr] = None - srep_status: Optional[StrictStr] = None - srep_type: Optional[StrictStr] = None - srep_unity_of_invention: Optional[StrictStr] = None - srep_unity_of_invention_fee_1: Optional[StrictStr] = None - srep_unity_of_invention_fee_2: Optional[StrictStr] = None - srep_unity_of_invention_fee_3: Optional[StrictStr] = None - srep_unity_of_invention_fee_4: Optional[StrictStr] = None - states: Optional[StrictStr] = None - states_text: Optional[StrictStr] = None - sub_group: Optional[StrictStr] = None - subclass: Optional[StrictStr] = None - title_de: Optional[StrictStr] = None - title_en: Optional[StrictStr] = None - title_fr: Optional[StrictStr] = None - unlinked_indexing_code: Optional[StrictStr] = None - version: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["abstract", "abstract_lang", "action", "applicants", "applicants_adr", "applicants_name", "applicants_name_text", "application_filing_date", "application_number", "claims", "claims_de", "claims_en", "claims_fr", "class", "classification_value", "country", "cpc", "cpc_text", "data1", "data2", "date_of_despatch_of_1st_exam_report", "date_of_patent_maintained_as_amended", "date_of_request_for_examination", "date_of_resumption_of_proceedings", "date_of_suspension_interruption", "date_publication", "date_publication_year", "description_header", "description_lang", "description_paragraph", "description_text", "doc_number", "extended_states", "extended_states_text", "indicates_the_type_of_suspension_or_interruption", "inventors", "inventors_adr", "inventors_name", "inventors_name_nested", "inventors_name_text", "ipc", "ipc_text", "ipc_text_without", "ipc_without", "keywords_and_descriptors", "kind", "level", "linked_indexing_code", "main_group", "non_obligatory_suppl_class", "office", "position", "representatives", "representatives_adr", "representatives_name", "representatives_name_text", "request_for_conversion_to_natl_appl_country", "request_for_conversion_to_natl_appl_date", "section", "srep_abs_approval", "srep_abstract", "srep_date_produced", "srep_established", "srep_file_reference_id", "srep_invention_title", "srep_invention_title_approval", "srep_lang", "srep_office", "srep_protest_fees", "srep_status", "srep_type", "srep_unity_of_invention", "srep_unity_of_invention_fee_1", "srep_unity_of_invention_fee_2", "srep_unity_of_invention_fee_3", "srep_unity_of_invention_fee_4", "states", "states_text", "sub_group", "subclass", "title_de", "title_en", "title_fr", "unlinked_indexing_code", "version"] + """ + abstract: StrictStr | None = None + abstract_lang: StrictStr | None = None + action: StrictStr | None = None + applicants: StrictStr | None = None + applicants_adr: StrictStr | None = None + applicants_name: StrictStr | None = None + applicants_name_text: StrictStr | None = None + application_filing_date: StrictStr | None = None + application_number: StrictStr | None = None + claims: StrictStr | None = None + claims_de: StrictStr | None = None + claims_en: StrictStr | None = None + claims_fr: StrictStr | None = None + var_class: StrictStr | None = Field(default=None, alias="class") + classification_value: StrictStr | None = None + country: StrictStr | None = None + cpc: StrictStr | None = None + cpc_text: StrictStr | None = None + data1: StrictStr | None = None + data2: StrictStr | None = None + date_of_despatch_of_1st_exam_report: StrictStr | None = None + date_of_patent_maintained_as_amended: StrictStr | None = None + date_of_request_for_examination: StrictStr | None = None + date_of_resumption_of_proceedings: StrictStr | None = None + date_of_suspension_interruption: StrictStr | None = None + date_publication: StrictInt | None = None + date_publication_year: StrictInt | None = None + description_header: StrictStr | None = None + description_lang: StrictStr | None = None + description_paragraph: StrictStr | None = None + description_text: StrictStr | None = None + doc_number: StrictStr | None = None + extended_states: StrictStr | None = None + extended_states_text: StrictStr | None = None + indicates_the_type_of_suspension_or_interruption: StrictStr | None = None + inventors: StrictStr | None = None + inventors_adr: StrictStr | None = None + inventors_name: StrictStr | None = None + inventors_name_nested: list[InventorNested] | None = None + inventors_name_text: StrictStr | None = None + ipc: StrictStr | None = None + ipc_text: StrictStr | None = None + ipc_text_without: StrictStr | None = None + ipc_without: StrictStr | None = None + keywords_and_descriptors: StrictStr | None = None + kind: StrictStr | None = None + level: StrictStr | None = None + linked_indexing_code: StrictStr | None = None + main_group: StrictStr | None = None + non_obligatory_suppl_class: StrictStr | None = None + office: StrictStr | None = None + position: StrictStr | None = None + representatives: StrictStr | None = None + representatives_adr: StrictStr | None = None + representatives_name: StrictStr | None = None + representatives_name_text: StrictStr | None = None + request_for_conversion_to_natl_appl_country: StrictStr | None = None + request_for_conversion_to_natl_appl_date: StrictStr | None = None + section: StrictStr | None = None + srep_abs_approval: StrictStr | None = None + srep_abstract: StrictStr | None = None + srep_date_produced: StrictStr | None = None + srep_established: StrictStr | None = None + srep_file_reference_id: StrictStr | None = None + srep_invention_title: StrictStr | None = None + srep_invention_title_approval: StrictStr | None = None + srep_lang: StrictStr | None = None + srep_office: StrictStr | None = None + srep_protest_fees: StrictStr | None = None + srep_status: StrictStr | None = None + srep_type: StrictStr | None = None + srep_unity_of_invention: StrictStr | None = None + srep_unity_of_invention_fee_1: StrictStr | None = None + srep_unity_of_invention_fee_2: StrictStr | None = None + srep_unity_of_invention_fee_3: StrictStr | None = None + srep_unity_of_invention_fee_4: StrictStr | None = None + states: StrictStr | None = None + states_text: StrictStr | None = None + sub_group: StrictStr | None = None + subclass: StrictStr | None = None + title_de: StrictStr | None = None + title_en: StrictStr | None = None + title_fr: StrictStr | None = None + unlinked_indexing_code: StrictStr | None = None + version: StrictStr | None = None + __properties: ClassVar[list[str]] = ["abstract", "abstract_lang", "action", "applicants", "applicants_adr", "applicants_name", "applicants_name_text", "application_filing_date", "application_number", "claims", "claims_de", "claims_en", "claims_fr", "class", "classification_value", "country", "cpc", "cpc_text", "data1", "data2", "date_of_despatch_of_1st_exam_report", "date_of_patent_maintained_as_amended", "date_of_request_for_examination", "date_of_resumption_of_proceedings", "date_of_suspension_interruption", "date_publication", "date_publication_year", "description_header", "description_lang", "description_paragraph", "description_text", "doc_number", "extended_states", "extended_states_text", "indicates_the_type_of_suspension_or_interruption", "inventors", "inventors_adr", "inventors_name", "inventors_name_nested", "inventors_name_text", "ipc", "ipc_text", "ipc_text_without", "ipc_without", "keywords_and_descriptors", "kind", "level", "linked_indexing_code", "main_group", "non_obligatory_suppl_class", "office", "position", "representatives", "representatives_adr", "representatives_name", "representatives_name_text", "request_for_conversion_to_natl_appl_country", "request_for_conversion_to_natl_appl_date", "section", "srep_abs_approval", "srep_abstract", "srep_date_produced", "srep_established", "srep_file_reference_id", "srep_invention_title", "srep_invention_title_approval", "srep_lang", "srep_office", "srep_protest_fees", "srep_status", "srep_type", "srep_unity_of_invention", "srep_unity_of_invention_fee_1", "srep_unity_of_invention_fee_2", "srep_unity_of_invention_fee_3", "srep_unity_of_invention_fee_4", "states", "states_text", "sub_group", "subclass", "title_de", "title_en", "title_fr", "unlinked_indexing_code", "version"] model_config = ConfigDict( validate_by_name=True, @@ -132,11 +131,11 @@ class EpoDocument(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of EpoDocument from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -146,7 +145,7 @@ class EpoDocument(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -164,7 +163,7 @@ class EpoDocument(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of EpoDocument from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_epo/inventor_nested.py b/service/src/main/inse/models/patents_epo/inventor_nested.py index 4ff818cb..b6c35598 100644 --- a/service/src/main/inse/models/patents_epo/inventor_nested.py +++ b/service/src/main/inse/models/patents_epo/inventor_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ EPO Index Backend Models @@ -9,26 +8,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class InventorNested(BaseModel): """ Nested inventor name object. - """ # noqa: E501 - inventor: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["inventor"] + """ + inventor: StrictStr | None = None + __properties: ClassVar[list[str]] = ["inventor"] model_config = ConfigDict( validate_by_name=True, @@ -47,11 +46,11 @@ class InventorNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of InventorNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,7 +60,7 @@ class InventorNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -72,7 +71,7 @@ class InventorNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of InventorNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/agent_nested.py b/service/src/main/inse/models/patents_uspto/agent_nested.py index d2ed80f9..3991ff11 100644 --- a/service/src/main/inse/models/patents_uspto/agent_nested.py +++ b/service/src/main/inse/models/patents_uspto/agent_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,28 +8,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AgentNested(BaseModel): """ Nested object for patent agents. - """ # noqa: E501 - inventor: Optional[StrictStr] = None - name: Optional[StrictStr] = None - org: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["inventor", "name", "org"] + """ + inventor: StrictStr | None = None + name: StrictStr | None = None + org: StrictStr | None = None + __properties: ClassVar[list[str]] = ["inventor", "name", "org"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class AgentNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AgentNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class AgentNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class AgentNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AgentNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/applicant_nested.py b/service/src/main/inse/models/patents_uspto/applicant_nested.py index 5910b390..4ab2aa97 100644 --- a/service/src/main/inse/models/patents_uspto/applicant_nested.py +++ b/service/src/main/inse/models/patents_uspto/applicant_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,30 +8,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class ApplicantNested(BaseModel): """ Nested object for patent applicants. - """ # noqa: E501 - address: Optional[StrictStr] = None - inventor: Optional[StrictStr] = None - name: Optional[StrictStr] = None - org: Optional[StrictStr] = None - type: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["address", "inventor", "name", "org", "type"] + """ + address: StrictStr | None = None + inventor: StrictStr | None = None + name: StrictStr | None = None + org: StrictStr | None = None + type: StrictStr | None = None + __properties: ClassVar[list[str]] = ["address", "inventor", "name", "org", "type"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +50,11 @@ class ApplicantNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ApplicantNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +64,7 @@ class ApplicantNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -76,7 +75,7 @@ class ApplicantNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ApplicantNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/assistant_examiner_nested.py b/service/src/main/inse/models/patents_uspto/assistant_examiner_nested.py index ffde6099..7d11f741 100644 --- a/service/src/main/inse/models/patents_uspto/assistant_examiner_nested.py +++ b/service/src/main/inse/models/patents_uspto/assistant_examiner_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,26 +8,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class AssistantExaminerNested(BaseModel): """ Nested object for assistant examiners. - """ # noqa: E501 - name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["name"] + """ + name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["name"] model_config = ConfigDict( validate_by_name=True, @@ -47,11 +46,11 @@ class AssistantExaminerNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AssistantExaminerNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,7 +60,7 @@ class AssistantExaminerNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -72,7 +71,7 @@ class AssistantExaminerNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of AssistantExaminerNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/citation_object.py b/service/src/main/inse/models/patents_uspto/citation_object.py index 80d0e75f..1f4d3e71 100644 --- a/service/src/main/inse/models/patents_uspto/citation_object.py +++ b/service/src/main/inse/models/patents_uspto/citation_object.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class CitationObject(BaseModel): """ Object structure for patent citations. - """ # noqa: E501 - country: Optional[StrictStr] = None - var_date: Optional[StrictStr] = Field(default=None, alias="date") - doc_number: Optional[StrictStr] = None - kind: Optional[StrictStr] = None - main_classification: Optional[StrictStr] = None - name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["country", "date", "doc_number", "kind", "main_classification", "name"] + """ + country: StrictStr | None = None + var_date: StrictStr | None = Field(default=None, alias="date") + doc_number: StrictStr | None = None + kind: StrictStr | None = None + main_classification: StrictStr | None = None + name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["country", "date", "doc_number", "kind", "main_classification", "name"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class CitationObject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of CitationObject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class CitationObject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class CitationObject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of CitationObject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/inventor_nested.py b/service/src/main/inse/models/patents_uspto/inventor_nested.py index accdeb7b..1388c86a 100644 --- a/service/src/main/inse/models/patents_uspto/inventor_nested.py +++ b/service/src/main/inse/models/patents_uspto/inventor_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,27 +8,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class InventorNested(BaseModel): """ Nested object for inventors. - """ # noqa: E501 - address: Optional[StrictStr] = None - name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["address", "name"] + """ + address: StrictStr | None = None + name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["address", "name"] model_config = ConfigDict( validate_by_name=True, @@ -48,11 +47,11 @@ class InventorNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of InventorNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -62,7 +61,7 @@ class InventorNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -73,7 +72,7 @@ class InventorNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of InventorNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/primary_examiner_nested.py b/service/src/main/inse/models/patents_uspto/primary_examiner_nested.py index 2361488e..c7ea32a6 100644 --- a/service/src/main/inse/models/patents_uspto/primary_examiner_nested.py +++ b/service/src/main/inse/models/patents_uspto/primary_examiner_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,28 +8,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class PrimaryExaminerNested(BaseModel): """ Nested object for primary examiners. - """ # noqa: E501 - department: Optional[StrictStr] = None - inventor: Optional[StrictStr] = None - name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["department", "inventor", "name"] + """ + department: StrictStr | None = None + inventor: StrictStr | None = None + name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["department", "inventor", "name"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class PrimaryExaminerNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of PrimaryExaminerNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class PrimaryExaminerNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class PrimaryExaminerNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of PrimaryExaminerNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/priority_claim_nested.py b/service/src/main/inse/models/patents_uspto/priority_claim_nested.py index 0685ba08..60dee10c 100644 --- a/service/src/main/inse/models/patents_uspto/priority_claim_nested.py +++ b/service/src/main/inse/models/patents_uspto/priority_claim_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,29 +8,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class PriorityClaimNested(BaseModel): """ Nested object for priority claims. - """ # noqa: E501 - country: Optional[StrictStr] = None - var_date: Optional[StrictStr] = Field(default=None, alias="date") - inventor: Optional[StrictStr] = None - number: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["country", "date", "inventor", "number"] + """ + country: StrictStr | None = None + var_date: StrictStr | None = Field(default=None, alias="date") + inventor: StrictStr | None = None + number: StrictStr | None = None + __properties: ClassVar[list[str]] = ["country", "date", "inventor", "number"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class PriorityClaimNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of PriorityClaimNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class PriorityClaimNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class PriorityClaimNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of PriorityClaimNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/related_documents_object.py b/service/src/main/inse/models/patents_uspto/related_documents_object.py index 0df5d267..37e58036 100644 --- a/service/src/main/inse/models/patents_uspto/related_documents_object.py +++ b/service/src/main/inse/models/patents_uspto/related_documents_object.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class RelatedDocumentsObject(BaseModel): """ Object structure for related parent and child documents. - """ # noqa: E501 - child_country: Optional[StrictStr] = None - child_date: Optional[StrictStr] = None - child_doc_number: Optional[StrictStr] = None - parent_country: Optional[StrictStr] = None - parent_date: Optional[StrictStr] = None - parent_doc_number: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["child_country", "child_date", "child_doc_number", "parent_country", "parent_date", "parent_doc_number"] + """ + child_country: StrictStr | None = None + child_date: StrictStr | None = None + child_doc_number: StrictStr | None = None + parent_country: StrictStr | None = None + parent_date: StrictStr | None = None + parent_doc_number: StrictStr | None = None + __properties: ClassVar[list[str]] = ["child_country", "child_date", "child_doc_number", "parent_country", "parent_date", "parent_doc_number"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class RelatedDocumentsObject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of RelatedDocumentsObject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class RelatedDocumentsObject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class RelatedDocumentsObject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of RelatedDocumentsObject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/patents_uspto/uspto_patent.py b/service/src/main/inse/models/patents_uspto/uspto_patent.py index 179d5b55..7418d736 100644 --- a/service/src/main/inse/models/patents_uspto/uspto_patent.py +++ b/service/src/main/inse/models/patents_uspto/uspto_patent.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ USPTO Patents Index Backend Models @@ -9,16 +8,16 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.patents_uspto.agent_nested import AgentNested from inse.models.patents_uspto.applicant_nested import ApplicantNested from inse.models.patents_uspto.assistant_examiner_nested import AssistantExaminerNested @@ -27,123 +26,123 @@ from inse.models.patents_uspto.inventor_nested import InventorNested from inse.models.patents_uspto.primary_examiner_nested import PrimaryExaminerNested from inse.models.patents_uspto.priority_claim_nested import PriorityClaimNested from inse.models.patents_uspto.related_documents_object import RelatedDocumentsObject -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from pydantic_core import to_jsonable_python + class UsptoPatent(BaseModel): """ Main document model for the uspto_patents_1.0 index. - """ # noqa: E501 - abstract: Optional[StrictStr] = None - agents: Optional[List[AgentNested]] = None - agents_names: Optional[StrictStr] = None - agents_names_text: Optional[StrictStr] = None - agents_orgs: Optional[StrictStr] = None - agents_orgs_text: Optional[StrictStr] = None - applicants: Optional[List[ApplicantNested]] = None - applicants_addresses: Optional[StrictStr] = None - applicants_addresses_text: Optional[StrictStr] = None - applicants_names: Optional[StrictStr] = None - applicants_names_text: Optional[StrictStr] = None - applicants_orgs: Optional[StrictStr] = None - applicants_orgs_text: Optional[StrictStr] = None - application_country: Optional[StrictStr] = None - application_date: Optional[StrictInt] = None - application_number: Optional[StrictStr] = None - application_type: Optional[StrictStr] = None - assignees: Optional[StrictStr] = None - assignees_addresses: Optional[StrictStr] = None - assignees_addresses_text: Optional[StrictStr] = None - assignees_orgs: Optional[StrictStr] = None - assignees_orgs_text: Optional[StrictStr] = None - assignees_text: Optional[StrictStr] = None - assistant_examiners: Optional[List[AssistantExaminerNested]] = None - assistant_examiners_departments: Optional[StrictStr] = None - assistant_examiners_departments_text: Optional[StrictStr] = None - assistant_examiners_names: Optional[StrictStr] = None - assistant_examiners_names_text: Optional[StrictStr] = None - citations: Optional[CitationObject] = None - citations_names: Optional[StrictStr] = None - citations_names_text: Optional[StrictStr] = None - claims: Optional[StrictStr] = None - claims_text: Optional[StrictStr] = None - country: Optional[StrictStr] = None - cpc: Optional[StrictStr] = None - cpc_action: Optional[StrictStr] = None - cpc_class: Optional[StrictStr] = None - cpc_classification_value: Optional[StrictStr] = None - cpc_data1: Optional[StrictStr] = None - cpc_data2: Optional[StrictStr] = None - cpc_main_group: Optional[StrictStr] = None - cpc_office: Optional[StrictStr] = None - cpc_position: Optional[StrictStr] = None - cpc_scheme: Optional[StrictStr] = None - cpc_section: Optional[StrictStr] = None - cpc_subclass: Optional[StrictStr] = None - cpc_subgroup: Optional[StrictStr] = None - cpc_text: Optional[StrictStr] = None - cpc_text_without: Optional[StrictStr] = None - cpc_version: Optional[StrictStr] = None - date_produced: Optional[StrictInt] = Field(default=None, alias="date-produced") - date_publ: Optional[StrictInt] = Field(default=None, alias="date-publ") - description_header: Optional[StrictStr] = None - description_paragraph: Optional[StrictStr] = None - description_text: Optional[StrictStr] = None - disclaimer: Optional[StrictStr] = None - dtd_version: Optional[StrictStr] = Field(default=None, alias="dtd-version") - field_of_clasification_cpc: Optional[StrictStr] = None - field_of_clasification_cpc_text: Optional[StrictStr] = None - field_of_clasification_cpc_text_without: Optional[StrictStr] = None - field_of_clasification_uspc: Optional[StrictStr] = None - field_of_clasification_uspc_text: Optional[StrictStr] = None - field_of_clasification_uspc_text_without: Optional[StrictStr] = None - file: Optional[StrictStr] = None - further_classifications: Optional[StrictStr] = None - id: Optional[StrictStr] = None - inventors: Optional[List[InventorNested]] = None - inventors_addresses: Optional[StrictStr] = None - inventors_addresses_text: Optional[StrictStr] = None - inventors_names: Optional[StrictStr] = None - inventors_names_text: Optional[StrictStr] = None - ipcr: Optional[StrictStr] = None - ipcr_action: Optional[StrictStr] = None - ipcr_class: Optional[StrictStr] = None - ipcr_classification_value: Optional[StrictStr] = None - ipcr_data1: Optional[StrictStr] = None - ipcr_data2: Optional[StrictStr] = None - ipcr_level: Optional[StrictStr] = None - ipcr_main_group: Optional[StrictStr] = None - ipcr_office: Optional[StrictStr] = None - ipcr_position: Optional[StrictStr] = None - ipcr_section: Optional[StrictStr] = None - ipcr_subclass: Optional[StrictStr] = None - ipcr_subgroup: Optional[StrictStr] = None - ipcr_text: Optional[StrictStr] = None - ipcr_text_without: Optional[StrictStr] = None - ipcr_version: Optional[StrictStr] = None - lang: Optional[StrictStr] = None - length_of_grant: Optional[StrictInt] = None - loc: Optional[StrictStr] = None - number_of_claims: Optional[StrictInt] = None - primary_examiners: Optional[List[PrimaryExaminerNested]] = None - primary_examiners_departments: Optional[StrictStr] = None - primary_examiners_departments_text: Optional[StrictStr] = None - primary_examiners_names: Optional[StrictStr] = None - primary_examiners_names_text: Optional[StrictStr] = None - priority_claims: Optional[List[PriorityClaimNested]] = None - publication_country: Optional[StrictStr] = None - publication_date: Optional[StrictInt] = None - publication_kind: Optional[StrictStr] = None - publication_number: Optional[StrictStr] = None - publication_year: Optional[StrictInt] = None - related_documents: Optional[RelatedDocumentsObject] = None - series_code: Optional[StrictStr] = None - status: Optional[StrictStr] = None - term_extension: Optional[StrictInt] = None - title: Optional[StrictStr] = None - uspc: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["abstract", "agents", "agents_names", "agents_names_text", "agents_orgs", "agents_orgs_text", "applicants", "applicants_addresses", "applicants_addresses_text", "applicants_names", "applicants_names_text", "applicants_orgs", "applicants_orgs_text", "application_country", "application_date", "application_number", "application_type", "assignees", "assignees_addresses", "assignees_addresses_text", "assignees_orgs", "assignees_orgs_text", "assignees_text", "assistant_examiners", "assistant_examiners_departments", "assistant_examiners_departments_text", "assistant_examiners_names", "assistant_examiners_names_text", "citations", "citations_names", "citations_names_text", "claims", "claims_text", "country", "cpc", "cpc_action", "cpc_class", "cpc_classification_value", "cpc_data1", "cpc_data2", "cpc_main_group", "cpc_office", "cpc_position", "cpc_scheme", "cpc_section", "cpc_subclass", "cpc_subgroup", "cpc_text", "cpc_text_without", "cpc_version", "date-produced", "date-publ", "description_header", "description_paragraph", "description_text", "disclaimer", "dtd-version", "field_of_clasification_cpc", "field_of_clasification_cpc_text", "field_of_clasification_cpc_text_without", "field_of_clasification_uspc", "field_of_clasification_uspc_text", "field_of_clasification_uspc_text_without", "file", "further_classifications", "id", "inventors", "inventors_addresses", "inventors_addresses_text", "inventors_names", "inventors_names_text", "ipcr", "ipcr_action", "ipcr_class", "ipcr_classification_value", "ipcr_data1", "ipcr_data2", "ipcr_level", "ipcr_main_group", "ipcr_office", "ipcr_position", "ipcr_section", "ipcr_subclass", "ipcr_subgroup", "ipcr_text", "ipcr_text_without", "ipcr_version", "lang", "length_of_grant", "loc", "number_of_claims", "primary_examiners", "primary_examiners_departments", "primary_examiners_departments_text", "primary_examiners_names", "primary_examiners_names_text", "priority_claims", "publication_country", "publication_date", "publication_kind", "publication_number", "publication_year", "related_documents", "series_code", "status", "term_extension", "title", "uspc"] + """ + abstract: StrictStr | None = None + agents: list[AgentNested] | None = None + agents_names: StrictStr | None = None + agents_names_text: StrictStr | None = None + agents_orgs: StrictStr | None = None + agents_orgs_text: StrictStr | None = None + applicants: list[ApplicantNested] | None = None + applicants_addresses: StrictStr | None = None + applicants_addresses_text: StrictStr | None = None + applicants_names: StrictStr | None = None + applicants_names_text: StrictStr | None = None + applicants_orgs: StrictStr | None = None + applicants_orgs_text: StrictStr | None = None + application_country: StrictStr | None = None + application_date: StrictInt | None = None + application_number: StrictStr | None = None + application_type: StrictStr | None = None + assignees: StrictStr | None = None + assignees_addresses: StrictStr | None = None + assignees_addresses_text: StrictStr | None = None + assignees_orgs: StrictStr | None = None + assignees_orgs_text: StrictStr | None = None + assignees_text: StrictStr | None = None + assistant_examiners: list[AssistantExaminerNested] | None = None + assistant_examiners_departments: StrictStr | None = None + assistant_examiners_departments_text: StrictStr | None = None + assistant_examiners_names: StrictStr | None = None + assistant_examiners_names_text: StrictStr | None = None + citations: CitationObject | None = None + citations_names: StrictStr | None = None + citations_names_text: StrictStr | None = None + claims: StrictStr | None = None + claims_text: StrictStr | None = None + country: StrictStr | None = None + cpc: StrictStr | None = None + cpc_action: StrictStr | None = None + cpc_class: StrictStr | None = None + cpc_classification_value: StrictStr | None = None + cpc_data1: StrictStr | None = None + cpc_data2: StrictStr | None = None + cpc_main_group: StrictStr | None = None + cpc_office: StrictStr | None = None + cpc_position: StrictStr | None = None + cpc_scheme: StrictStr | None = None + cpc_section: StrictStr | None = None + cpc_subclass: StrictStr | None = None + cpc_subgroup: StrictStr | None = None + cpc_text: StrictStr | None = None + cpc_text_without: StrictStr | None = None + cpc_version: StrictStr | None = None + date_produced: StrictInt | None = Field(default=None, alias="date-produced") + date_publ: StrictInt | None = Field(default=None, alias="date-publ") + description_header: StrictStr | None = None + description_paragraph: StrictStr | None = None + description_text: StrictStr | None = None + disclaimer: StrictStr | None = None + dtd_version: StrictStr | None = Field(default=None, alias="dtd-version") + field_of_clasification_cpc: StrictStr | None = None + field_of_clasification_cpc_text: StrictStr | None = None + field_of_clasification_cpc_text_without: StrictStr | None = None + field_of_clasification_uspc: StrictStr | None = None + field_of_clasification_uspc_text: StrictStr | None = None + field_of_clasification_uspc_text_without: StrictStr | None = None + file: StrictStr | None = None + further_classifications: StrictStr | None = None + id: StrictStr | None = None + inventors: list[InventorNested] | None = None + inventors_addresses: StrictStr | None = None + inventors_addresses_text: StrictStr | None = None + inventors_names: StrictStr | None = None + inventors_names_text: StrictStr | None = None + ipcr: StrictStr | None = None + ipcr_action: StrictStr | None = None + ipcr_class: StrictStr | None = None + ipcr_classification_value: StrictStr | None = None + ipcr_data1: StrictStr | None = None + ipcr_data2: StrictStr | None = None + ipcr_level: StrictStr | None = None + ipcr_main_group: StrictStr | None = None + ipcr_office: StrictStr | None = None + ipcr_position: StrictStr | None = None + ipcr_section: StrictStr | None = None + ipcr_subclass: StrictStr | None = None + ipcr_subgroup: StrictStr | None = None + ipcr_text: StrictStr | None = None + ipcr_text_without: StrictStr | None = None + ipcr_version: StrictStr | None = None + lang: StrictStr | None = None + length_of_grant: StrictInt | None = None + loc: StrictStr | None = None + number_of_claims: StrictInt | None = None + primary_examiners: list[PrimaryExaminerNested] | None = None + primary_examiners_departments: StrictStr | None = None + primary_examiners_departments_text: StrictStr | None = None + primary_examiners_names: StrictStr | None = None + primary_examiners_names_text: StrictStr | None = None + priority_claims: list[PriorityClaimNested] | None = None + publication_country: StrictStr | None = None + publication_date: StrictInt | None = None + publication_kind: StrictStr | None = None + publication_number: StrictStr | None = None + publication_year: StrictInt | None = None + related_documents: RelatedDocumentsObject | None = None + series_code: StrictStr | None = None + status: StrictStr | None = None + term_extension: StrictInt | None = None + title: StrictStr | None = None + uspc: StrictStr | None = None + __properties: ClassVar[list[str]] = ["abstract", "agents", "agents_names", "agents_names_text", "agents_orgs", "agents_orgs_text", "applicants", "applicants_addresses", "applicants_addresses_text", "applicants_names", "applicants_names_text", "applicants_orgs", "applicants_orgs_text", "application_country", "application_date", "application_number", "application_type", "assignees", "assignees_addresses", "assignees_addresses_text", "assignees_orgs", "assignees_orgs_text", "assignees_text", "assistant_examiners", "assistant_examiners_departments", "assistant_examiners_departments_text", "assistant_examiners_names", "assistant_examiners_names_text", "citations", "citations_names", "citations_names_text", "claims", "claims_text", "country", "cpc", "cpc_action", "cpc_class", "cpc_classification_value", "cpc_data1", "cpc_data2", "cpc_main_group", "cpc_office", "cpc_position", "cpc_scheme", "cpc_section", "cpc_subclass", "cpc_subgroup", "cpc_text", "cpc_text_without", "cpc_version", "date-produced", "date-publ", "description_header", "description_paragraph", "description_text", "disclaimer", "dtd-version", "field_of_clasification_cpc", "field_of_clasification_cpc_text", "field_of_clasification_cpc_text_without", "field_of_clasification_uspc", "field_of_clasification_uspc_text", "field_of_clasification_uspc_text_without", "file", "further_classifications", "id", "inventors", "inventors_addresses", "inventors_addresses_text", "inventors_names", "inventors_names_text", "ipcr", "ipcr_action", "ipcr_class", "ipcr_classification_value", "ipcr_data1", "ipcr_data2", "ipcr_level", "ipcr_main_group", "ipcr_office", "ipcr_position", "ipcr_section", "ipcr_subclass", "ipcr_subgroup", "ipcr_text", "ipcr_text_without", "ipcr_version", "lang", "length_of_grant", "loc", "number_of_claims", "primary_examiners", "primary_examiners_departments", "primary_examiners_departments_text", "primary_examiners_names", "primary_examiners_names_text", "priority_claims", "publication_country", "publication_date", "publication_kind", "publication_number", "publication_year", "related_documents", "series_code", "status", "term_extension", "title", "uspc"] model_config = ConfigDict( validate_by_name=True, @@ -162,11 +161,11 @@ class UsptoPatent(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of UsptoPatent from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -176,7 +175,7 @@ class UsptoPatent(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -235,7 +234,7 @@ class UsptoPatent(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of UsptoPatent from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_bund/arb.py b/service/src/main/inse/models/projects_bund/arb.py index 3535b484..a8d164b1 100644 --- a/service/src/main/inse/models/projects_bund/arb.py +++ b/service/src/main/inse/models/projects_bund/arb.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects Bund Index Backend Models @@ -9,26 +8,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Arb(BaseModel): """ Nested Arb object. - """ # noqa: E501 - einh: Optional[StrictStr] = Field(default=None, alias="-Einh") - __properties: ClassVar[List[str]] = ["-Einh"] + """ + einh: StrictStr | None = Field(default=None, alias="-Einh") + __properties: ClassVar[list[str]] = ["-Einh"] model_config = ConfigDict( validate_by_name=True, @@ -47,11 +46,11 @@ class Arb(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Arb from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,7 +60,7 @@ class Arb(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -72,7 +71,7 @@ class Arb(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Arb from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_bund/project_bund.py b/service/src/main/inse/models/projects_bund/project_bund.py index 65ab7ae8..1a08d855 100644 --- a/service/src/main/inse/models/projects_bund/project_bund.py +++ b/service/src/main/inse/models/projects_bund/project_bund.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects Bund Index Backend Models @@ -9,56 +8,56 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional +from typing import Any, ClassVar, Self + from inse.models.projects_bund.arb import Arb -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, Field, StrictStr from pydantic_core import to_jsonable_python + class ProjectBund(BaseModel): """ Main document model for the projects_bund index. - """ # noqa: E501 - arb: Optional[Arb] = Field(default=None, alias="Arb") - ausfhrende_stelle: Optional[StrictStr] = Field(default=None, alias="Ausführende Stelle") - bundesland: Optional[StrictStr] = Field(default=None, alias="Bundesland") - frderart: Optional[StrictStr] = Field(default=None, alias="Förderart") - frderkennzeichen: Optional[StrictStr] = Field(default=None, alias="Förderkennzeichen") - frderprofil: Optional[StrictStr] = Field(default=None, alias="Förderprofil") - frdersumme: Optional[StrictStr] = Field(default=None, alias="Fördersumme") - gemeindekennziffer: Optional[StrictStr] = Field(default=None, alias="Gemeindekennziffer") - klartext_leistungsplansystematik: Optional[StrictStr] = Field(default=None, alias="Klartext Leistungsplansystematik") - laufzeit: Optional[StrictStr] = Field(default=None, alias="Laufzeit") - leistungsplansystematik: Optional[StrictStr] = Field(default=None, alias="Leistungsplansystematik") - leistungsplansystematik_fullname: Optional[StrictStr] = Field(default=None, alias="Leistungsplansystematik_fullname") - ort: Optional[StrictStr] = Field(default=None, alias="Ort") - pt_fullname: Optional[StrictStr] = Field(default=None, alias="PT_fullname") - projekttrger: Optional[StrictStr] = Field(default=None, alias="Projektträger") - publikationsdatum: Optional[StrictStr] = Field(default=None, alias="Publikationsdatum") - referat: Optional[StrictStr] = Field(default=None, alias="Referat") - ressort: Optional[StrictStr] = Field(default=None, alias="Ressort") - ressort_fullname: Optional[StrictStr] = Field(default=None, alias="Ressort_fullname") - staat: Optional[StrictStr] = Field(default=None, alias="Staat") - stadt_gemeinde: Optional[StrictStr] = Field(default=None, alias="Stadt/Gemeinde") - thema: Optional[StrictStr] = Field(default=None, alias="Thema") - verbundprojekt: Optional[StrictStr] = Field(default=None, alias="Verbundprojekt") - zuwendungsempfnger: Optional[StrictStr] = Field(default=None, alias="Zuwendungsempfänger") - datum: Optional[StrictStr] = None - funding_end: Optional[date] = Field(default=None, description="Expected format is dd.MM.yyyy based on ES mapping.") - funding_start: Optional[date] = Field(default=None, description="Expected format is dd.MM.yyyy based on ES mapping.") - new: Optional[StrictStr] = None - unix_timestamp: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["Arb", "Ausführende Stelle", "Bundesland", "Förderart", "Förderkennzeichen", "Förderprofil", "Fördersumme", "Gemeindekennziffer", "Klartext Leistungsplansystematik", "Laufzeit", "Leistungsplansystematik", "Leistungsplansystematik_fullname", "Ort", "PT_fullname", "Projektträger", "Publikationsdatum", "Referat", "Ressort", "Ressort_fullname", "Staat", "Stadt/Gemeinde", "Thema", "Verbundprojekt", "Zuwendungsempfänger", "datum", "funding_end", "funding_start", "new", "unix_timestamp"] + """ + arb: Arb | None = Field(default=None, alias="Arb") + ausfhrende_stelle: StrictStr | None = Field(default=None, alias="Ausführende Stelle") + bundesland: StrictStr | None = Field(default=None, alias="Bundesland") + frderart: StrictStr | None = Field(default=None, alias="Förderart") + frderkennzeichen: StrictStr | None = Field(default=None, alias="Förderkennzeichen") + frderprofil: StrictStr | None = Field(default=None, alias="Förderprofil") + frdersumme: StrictStr | None = Field(default=None, alias="Fördersumme") + gemeindekennziffer: StrictStr | None = Field(default=None, alias="Gemeindekennziffer") + klartext_leistungsplansystematik: StrictStr | None = Field(default=None, alias="Klartext Leistungsplansystematik") + laufzeit: StrictStr | None = Field(default=None, alias="Laufzeit") + leistungsplansystematik: StrictStr | None = Field(default=None, alias="Leistungsplansystematik") + leistungsplansystematik_fullname: StrictStr | None = Field(default=None, alias="Leistungsplansystematik_fullname") + ort: StrictStr | None = Field(default=None, alias="Ort") + pt_fullname: StrictStr | None = Field(default=None, alias="PT_fullname") + projekttrger: StrictStr | None = Field(default=None, alias="Projektträger") + publikationsdatum: StrictStr | None = Field(default=None, alias="Publikationsdatum") + referat: StrictStr | None = Field(default=None, alias="Referat") + ressort: StrictStr | None = Field(default=None, alias="Ressort") + ressort_fullname: StrictStr | None = Field(default=None, alias="Ressort_fullname") + staat: StrictStr | None = Field(default=None, alias="Staat") + stadt_gemeinde: StrictStr | None = Field(default=None, alias="Stadt/Gemeinde") + thema: StrictStr | None = Field(default=None, alias="Thema") + verbundprojekt: StrictStr | None = Field(default=None, alias="Verbundprojekt") + zuwendungsempfnger: StrictStr | None = Field(default=None, alias="Zuwendungsempfänger") + datum: StrictStr | None = None + funding_end: date | None = Field(default=None, description="Expected format is dd.MM.yyyy based on ES mapping.") + funding_start: date | None = Field(default=None, description="Expected format is dd.MM.yyyy based on ES mapping.") + new: StrictStr | None = None + unix_timestamp: StrictStr | None = None + __properties: ClassVar[list[str]] = ["Arb", "Ausführende Stelle", "Bundesland", "Förderart", "Förderkennzeichen", "Förderprofil", "Fördersumme", "Gemeindekennziffer", "Klartext Leistungsplansystematik", "Laufzeit", "Leistungsplansystematik", "Leistungsplansystematik_fullname", "Ort", "PT_fullname", "Projektträger", "Publikationsdatum", "Referat", "Ressort", "Ressort_fullname", "Staat", "Stadt/Gemeinde", "Thema", "Verbundprojekt", "Zuwendungsempfänger", "datum", "funding_end", "funding_start", "new", "unix_timestamp"] model_config = ConfigDict( validate_by_name=True, @@ -77,11 +76,11 @@ class ProjectBund(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ProjectBund from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -91,7 +90,7 @@ class ProjectBund(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -105,7 +104,7 @@ class ProjectBund(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ProjectBund from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg/auslaend.py b/service/src/main/inse/models/projects_dfg/auslaend.py index 85b261b3..e5d77adf 100644 --- a/service/src/main/inse/models/projects_dfg/auslaend.py +++ b/service/src/main/inse/models/projects_dfg/auslaend.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects DFG All Index Backend Models @@ -9,28 +8,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Auslaend(BaseModel): """ Nested object for international co-applicants. - """ # noqa: E501 - mitantragstellerin: Optional[StrictStr] = Field(default=None, alias=" Mitantragstellerin") - mitantragstellerinnen: Optional[StrictStr] = Field(default=None, alias=" Mitantragstellerinnen") - mitantragstellerinnen___auslndische_mitantragsteller: Optional[StrictStr] = Field(default=None, alias=" Mitantragstellerinnen / ausländische Mitantragsteller") - __properties: ClassVar[List[str]] = [" Mitantragstellerin", " Mitantragstellerinnen", " Mitantragstellerinnen / ausländische Mitantragsteller"] + """ + mitantragstellerin: StrictStr | None = Field(default=None, alias=" Mitantragstellerin") + mitantragstellerinnen: StrictStr | None = Field(default=None, alias=" Mitantragstellerinnen") + mitantragstellerinnen___auslndische_mitantragsteller: StrictStr | None = Field(default=None, alias=" Mitantragstellerinnen / ausländische Mitantragsteller") + __properties: ClassVar[list[str]] = [" Mitantragstellerin", " Mitantragstellerinnen", " Mitantragstellerinnen / ausländische Mitantragsteller"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class Auslaend(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Auslaend from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class Auslaend(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class Auslaend(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Auslaend from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg/project_dfg.py b/service/src/main/inse/models/projects_dfg/project_dfg.py index 6295f004..86c68045 100644 --- a/service/src/main/inse/models/projects_dfg/project_dfg.py +++ b/service/src/main/inse/models/projects_dfg/project_dfg.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects DFG All Index Backend Models @@ -9,106 +8,106 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.projects_dfg.auslaend import Auslaend from inse.models.projects_dfg.stellvertr import Stellvertr -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, Field, StrictStr from pydantic_core import to_jsonable_python + class ProjectDfg(BaseModel): """ Main document model for the projects_dfg_all index. - """ # noqa: E501 - antragstellende_institution: Optional[StrictStr] = Field(default=None, alias="Antragstellende Institution") - antragsteller: Optional[StrictStr] = Field(default=None, alias="Antragsteller") - antragstellerin: Optional[StrictStr] = Field(default=None, alias="Antragstellerin") - antragstellerinnen: Optional[StrictStr] = Field(default=None, alias="Antragstellerinnen") - antragstellerinnen___antragsteller: Optional[StrictStr] = Field(default=None, alias="Antragstellerinnen / Antragsteller") - anwendungspartner: Optional[StrictStr] = Field(default=None, alias="Anwendungspartner") - beteiligte_einrichtung: Optional[StrictStr] = Field(default=None, alias="Beteiligte Einrichtung") - beteiligte_hochschule: Optional[StrictStr] = Field(default=None, alias="Beteiligte Hochschule") - beteiligte_institution: Optional[StrictStr] = Field(default=None, alias="Beteiligte Institution") - beteiligte_person: Optional[StrictStr] = Field(default=None, alias="Beteiligte Person") - beteiligte_personen: Optional[StrictStr] = Field(default=None, alias="Beteiligte Personen") - co_sprecher: Optional[StrictStr] = Field(default=None, alias="Co-Sprecher") - co_sprecherinnen___co_sprecher: Optional[StrictStr] = Field(default=None, alias="Co-Sprecherinnen / Co-Sprecher") - dfg_verfahren: Optional[StrictStr] = Field(default=None, alias="DFG-Verfahren") - ehemalige_antragsteller: Optional[StrictStr] = Field(default=None, alias="Ehemalige Antragsteller") - ehemalige_antragstellerin: Optional[StrictStr] = Field(default=None, alias="Ehemalige Antragstellerin") - ehemalige_antragstellerinnen: Optional[StrictStr] = Field(default=None, alias="Ehemalige Antragstellerinnen") - ehemalige_antragstellerinnen___ehemalige_antragsteller: Optional[StrictStr] = Field(default=None, alias="Ehemalige Antragstellerinnen / Ehemalige Antragsteller") - ehemaliger_antragsteller: Optional[StrictStr] = Field(default=None, alias="Ehemaliger Antragsteller") - fachliche_zuordnung: Optional[StrictStr] = Field(default=None, alias="Fachliche Zuordnung") - frderung: Optional[StrictStr] = Field(default=None, alias="Förderung") - gastgeber: Optional[StrictStr] = Field(default=None, alias="Gastgeber") - gastgeberin: Optional[StrictStr] = Field(default=None, alias="Gastgeberin") - gastgeberinnen: Optional[StrictStr] = Field(default=None, alias="Gastgeberinnen") - gastgeberinnen___gastgeber: Optional[StrictStr] = Field(default=None, alias="Gastgeberinnen / Gastgeber") - gertegruppe: Optional[StrictStr] = Field(default=None, alias="Gerätegruppe") - grogerte: Optional[StrictStr] = Field(default=None, alias="Großgeräte") - igk_partnerinstitution: Optional[StrictStr] = Field(default=None, alias="IGK-Partnerinstitution") - internationaler_bezug: Optional[StrictStr] = Field(default=None, alias="Internationaler Bezug") - kooperationspartner: Optional[StrictStr] = Field(default=None, alias="Kooperationspartner") - kooperationspartnerin: Optional[StrictStr] = Field(default=None, alias="Kooperationspartnerin") - kooperationspartnerinnen: Optional[StrictStr] = Field(default=None, alias="Kooperationspartnerinnen") - kooperationspartnerinnen___kooperationspartner: Optional[StrictStr] = Field(default=None, alias="Kooperationspartnerinnen / Kooperationspartner") - leiter: Optional[StrictStr] = Field(default=None, alias="Leiter") - leiterin: Optional[StrictStr] = Field(default=None, alias="Leiterin") - leiterinnen: Optional[StrictStr] = Field(default=None, alias="Leiterinnen") - leiterinnen___leiter: Optional[StrictStr] = Field(default=None, alias="Leiterinnen / Leiter") - mitantragstellende_institution: Optional[StrictStr] = Field(default=None, alias="Mitantragstellende Institution") - mitantragsteller: Optional[StrictStr] = Field(default=None, alias="Mitantragsteller") - mitantragstellerin: Optional[StrictStr] = Field(default=None, alias="Mitantragstellerin") - mitantragstellerinnen: Optional[StrictStr] = Field(default=None, alias="Mitantragstellerinnen") - mitantragstellerinnen___mitantragsteller: Optional[StrictStr] = Field(default=None, alias="Mitantragstellerinnen / Mitantragsteller") - mitverantwortlich: Optional[StrictStr] = Field(default=None, alias="Mitverantwortlich") - mitverantwortlich_e: Optional[StrictStr] = Field(default=None, alias="Mitverantwortlich(e)") - mitverantwortliche: Optional[StrictStr] = Field(default=None, alias="Mitverantwortliche") - partnerorganisation: Optional[StrictStr] = Field(default=None, alias="Partnerorganisation") - projektkennung: Optional[StrictStr] = Field(default=None, alias="Projektkennung") - sprecher: Optional[StrictStr] = Field(default=None, alias="Sprecher") - sprecher__igk_partner: Optional[StrictStr] = Field(default=None, alias="Sprecher (IGK-Partner)") - sprecherin: Optional[StrictStr] = Field(default=None, alias="Sprecherin") - sprecherin__igk_partner: Optional[StrictStr] = Field(default=None, alias="Sprecherin (IGK-Partner)") - sprecherinnen: Optional[StrictStr] = Field(default=None, alias="Sprecherinnen") - sprecherinnen__igk_partner___sprecher__igk_partner: Optional[StrictStr] = Field(default=None, alias="Sprecherinnen (IGK-Partner) / Sprecher (IGK-Partner)") - sprecherinnen___sprecher: Optional[StrictStr] = Field(default=None, alias="Sprecherinnen / Sprecher") - teilprojekt_zu: Optional[StrictStr] = Field(default=None, alias="Teilprojekt zu") - teilprojektleiter: Optional[StrictStr] = Field(default=None, alias="Teilprojektleiter") - teilprojektleiterin: Optional[StrictStr] = Field(default=None, alias="Teilprojektleiterin") - teilprojektleiterinnen: Optional[StrictStr] = Field(default=None, alias="Teilprojektleiterinnen") - teilprojektleiterinnen___teilprojektleiter: Optional[StrictStr] = Field(default=None, alias="Teilprojektleiterinnen / Teilprojektleiter") - unternehmen: Optional[StrictStr] = Field(default=None, alias="Unternehmen") - webseite: Optional[StrictStr] = Field(default=None, alias="Webseite") - auslnd: Optional[Auslaend] = Field(default=None, alias="ausländ") - auslndische_mitantragsteller: Optional[StrictStr] = Field(default=None, alias="ausländische Mitantragsteller") - auslndischer_mitantragsteller: Optional[StrictStr] = Field(default=None, alias="ausländischer Mitantragsteller") - beteiligte_wissenschaftler: Optional[StrictStr] = Field(default=None, alias="beteiligte Wissenschaftler") - beteiligte_wissenschaftlerin: Optional[StrictStr] = Field(default=None, alias="beteiligte Wissenschaftlerin") - beteiligte_wissenschaftlerinnen: Optional[StrictStr] = Field(default=None, alias="beteiligte Wissenschaftlerinnen") - beteiligte_wissenschaftlerinnen___beteiligte_wissenschaftler: Optional[StrictStr] = Field(default=None, alias="beteiligte Wissenschaftlerinnen / beteiligte Wissenschaftler") - beteiligter_wissenschaftler: Optional[StrictStr] = Field(default=None, alias="beteiligter Wissenschaftler") - description: Optional[StrictStr] = None - funding_end: Optional[StrictStr] = None - funding_start: Optional[StrictStr] = None - id: Optional[StrictStr] = None - link: Optional[StrictStr] = None - path: Optional[StrictStr] = None - person_creater_address: Optional[StrictStr] = None - person_creater_name: Optional[StrictStr] = None - stellvertr: Optional[Stellvertr] = None - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["Antragstellende Institution", "Antragsteller", "Antragstellerin", "Antragstellerinnen", "Antragstellerinnen / Antragsteller", "Anwendungspartner", "Beteiligte Einrichtung", "Beteiligte Hochschule", "Beteiligte Institution", "Beteiligte Person", "Beteiligte Personen", "Co-Sprecher", "Co-Sprecherinnen / Co-Sprecher", "DFG-Verfahren", "Ehemalige Antragsteller", "Ehemalige Antragstellerin", "Ehemalige Antragstellerinnen", "Ehemalige Antragstellerinnen / Ehemalige Antragsteller", "Ehemaliger Antragsteller", "Fachliche Zuordnung", "Förderung", "Gastgeber", "Gastgeberin", "Gastgeberinnen", "Gastgeberinnen / Gastgeber", "Gerätegruppe", "Großgeräte", "IGK-Partnerinstitution", "Internationaler Bezug", "Kooperationspartner", "Kooperationspartnerin", "Kooperationspartnerinnen", "Kooperationspartnerinnen / Kooperationspartner", "Leiter", "Leiterin", "Leiterinnen", "Leiterinnen / Leiter", "Mitantragstellende Institution", "Mitantragsteller", "Mitantragstellerin", "Mitantragstellerinnen", "Mitantragstellerinnen / Mitantragsteller", "Mitverantwortlich", "Mitverantwortlich(e)", "Mitverantwortliche", "Partnerorganisation", "Projektkennung", "Sprecher", "Sprecher (IGK-Partner)", "Sprecherin", "Sprecherin (IGK-Partner)", "Sprecherinnen", "Sprecherinnen (IGK-Partner) / Sprecher (IGK-Partner)", "Sprecherinnen / Sprecher", "Teilprojekt zu", "Teilprojektleiter", "Teilprojektleiterin", "Teilprojektleiterinnen", "Teilprojektleiterinnen / Teilprojektleiter", "Unternehmen", "Webseite", "ausländ", "ausländische Mitantragsteller", "ausländischer Mitantragsteller", "beteiligte Wissenschaftler", "beteiligte Wissenschaftlerin", "beteiligte Wissenschaftlerinnen", "beteiligte Wissenschaftlerinnen / beteiligte Wissenschaftler", "beteiligter Wissenschaftler", "description", "funding_end", "funding_start", "id", "link", "path", "person_creater_address", "person_creater_name", "stellvertr", "title"] + """ + antragstellende_institution: StrictStr | None = Field(default=None, alias="Antragstellende Institution") + antragsteller: StrictStr | None = Field(default=None, alias="Antragsteller") + antragstellerin: StrictStr | None = Field(default=None, alias="Antragstellerin") + antragstellerinnen: StrictStr | None = Field(default=None, alias="Antragstellerinnen") + antragstellerinnen___antragsteller: StrictStr | None = Field(default=None, alias="Antragstellerinnen / Antragsteller") + anwendungspartner: StrictStr | None = Field(default=None, alias="Anwendungspartner") + beteiligte_einrichtung: StrictStr | None = Field(default=None, alias="Beteiligte Einrichtung") + beteiligte_hochschule: StrictStr | None = Field(default=None, alias="Beteiligte Hochschule") + beteiligte_institution: StrictStr | None = Field(default=None, alias="Beteiligte Institution") + beteiligte_person: StrictStr | None = Field(default=None, alias="Beteiligte Person") + beteiligte_personen: StrictStr | None = Field(default=None, alias="Beteiligte Personen") + co_sprecher: StrictStr | None = Field(default=None, alias="Co-Sprecher") + co_sprecherinnen___co_sprecher: StrictStr | None = Field(default=None, alias="Co-Sprecherinnen / Co-Sprecher") + dfg_verfahren: StrictStr | None = Field(default=None, alias="DFG-Verfahren") + ehemalige_antragsteller: StrictStr | None = Field(default=None, alias="Ehemalige Antragsteller") + ehemalige_antragstellerin: StrictStr | None = Field(default=None, alias="Ehemalige Antragstellerin") + ehemalige_antragstellerinnen: StrictStr | None = Field(default=None, alias="Ehemalige Antragstellerinnen") + ehemalige_antragstellerinnen___ehemalige_antragsteller: StrictStr | None = Field(default=None, alias="Ehemalige Antragstellerinnen / Ehemalige Antragsteller") + ehemaliger_antragsteller: StrictStr | None = Field(default=None, alias="Ehemaliger Antragsteller") + fachliche_zuordnung: StrictStr | None = Field(default=None, alias="Fachliche Zuordnung") + frderung: StrictStr | None = Field(default=None, alias="Förderung") + gastgeber: StrictStr | None = Field(default=None, alias="Gastgeber") + gastgeberin: StrictStr | None = Field(default=None, alias="Gastgeberin") + gastgeberinnen: StrictStr | None = Field(default=None, alias="Gastgeberinnen") + gastgeberinnen___gastgeber: StrictStr | None = Field(default=None, alias="Gastgeberinnen / Gastgeber") + gertegruppe: StrictStr | None = Field(default=None, alias="Gerätegruppe") + grogerte: StrictStr | None = Field(default=None, alias="Großgeräte") + igk_partnerinstitution: StrictStr | None = Field(default=None, alias="IGK-Partnerinstitution") + internationaler_bezug: StrictStr | None = Field(default=None, alias="Internationaler Bezug") + kooperationspartner: StrictStr | None = Field(default=None, alias="Kooperationspartner") + kooperationspartnerin: StrictStr | None = Field(default=None, alias="Kooperationspartnerin") + kooperationspartnerinnen: StrictStr | None = Field(default=None, alias="Kooperationspartnerinnen") + kooperationspartnerinnen___kooperationspartner: StrictStr | None = Field(default=None, alias="Kooperationspartnerinnen / Kooperationspartner") + leiter: StrictStr | None = Field(default=None, alias="Leiter") + leiterin: StrictStr | None = Field(default=None, alias="Leiterin") + leiterinnen: StrictStr | None = Field(default=None, alias="Leiterinnen") + leiterinnen___leiter: StrictStr | None = Field(default=None, alias="Leiterinnen / Leiter") + mitantragstellende_institution: StrictStr | None = Field(default=None, alias="Mitantragstellende Institution") + mitantragsteller: StrictStr | None = Field(default=None, alias="Mitantragsteller") + mitantragstellerin: StrictStr | None = Field(default=None, alias="Mitantragstellerin") + mitantragstellerinnen: StrictStr | None = Field(default=None, alias="Mitantragstellerinnen") + mitantragstellerinnen___mitantragsteller: StrictStr | None = Field(default=None, alias="Mitantragstellerinnen / Mitantragsteller") + mitverantwortlich: StrictStr | None = Field(default=None, alias="Mitverantwortlich") + mitverantwortlich_e: StrictStr | None = Field(default=None, alias="Mitverantwortlich(e)") + mitverantwortliche: StrictStr | None = Field(default=None, alias="Mitverantwortliche") + partnerorganisation: StrictStr | None = Field(default=None, alias="Partnerorganisation") + projektkennung: StrictStr | None = Field(default=None, alias="Projektkennung") + sprecher: StrictStr | None = Field(default=None, alias="Sprecher") + sprecher__igk_partner: StrictStr | None = Field(default=None, alias="Sprecher (IGK-Partner)") + sprecherin: StrictStr | None = Field(default=None, alias="Sprecherin") + sprecherin__igk_partner: StrictStr | None = Field(default=None, alias="Sprecherin (IGK-Partner)") + sprecherinnen: StrictStr | None = Field(default=None, alias="Sprecherinnen") + sprecherinnen__igk_partner___sprecher__igk_partner: StrictStr | None = Field(default=None, alias="Sprecherinnen (IGK-Partner) / Sprecher (IGK-Partner)") + sprecherinnen___sprecher: StrictStr | None = Field(default=None, alias="Sprecherinnen / Sprecher") + teilprojekt_zu: StrictStr | None = Field(default=None, alias="Teilprojekt zu") + teilprojektleiter: StrictStr | None = Field(default=None, alias="Teilprojektleiter") + teilprojektleiterin: StrictStr | None = Field(default=None, alias="Teilprojektleiterin") + teilprojektleiterinnen: StrictStr | None = Field(default=None, alias="Teilprojektleiterinnen") + teilprojektleiterinnen___teilprojektleiter: StrictStr | None = Field(default=None, alias="Teilprojektleiterinnen / Teilprojektleiter") + unternehmen: StrictStr | None = Field(default=None, alias="Unternehmen") + webseite: StrictStr | None = Field(default=None, alias="Webseite") + auslnd: Auslaend | None = Field(default=None, alias="ausländ") + auslndische_mitantragsteller: StrictStr | None = Field(default=None, alias="ausländische Mitantragsteller") + auslndischer_mitantragsteller: StrictStr | None = Field(default=None, alias="ausländischer Mitantragsteller") + beteiligte_wissenschaftler: StrictStr | None = Field(default=None, alias="beteiligte Wissenschaftler") + beteiligte_wissenschaftlerin: StrictStr | None = Field(default=None, alias="beteiligte Wissenschaftlerin") + beteiligte_wissenschaftlerinnen: StrictStr | None = Field(default=None, alias="beteiligte Wissenschaftlerinnen") + beteiligte_wissenschaftlerinnen___beteiligte_wissenschaftler: StrictStr | None = Field(default=None, alias="beteiligte Wissenschaftlerinnen / beteiligte Wissenschaftler") + beteiligter_wissenschaftler: StrictStr | None = Field(default=None, alias="beteiligter Wissenschaftler") + description: StrictStr | None = None + funding_end: StrictStr | None = None + funding_start: StrictStr | None = None + id: StrictStr | None = None + link: StrictStr | None = None + path: StrictStr | None = None + person_creater_address: StrictStr | None = None + person_creater_name: StrictStr | None = None + stellvertr: Stellvertr | None = None + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["Antragstellende Institution", "Antragsteller", "Antragstellerin", "Antragstellerinnen", "Antragstellerinnen / Antragsteller", "Anwendungspartner", "Beteiligte Einrichtung", "Beteiligte Hochschule", "Beteiligte Institution", "Beteiligte Person", "Beteiligte Personen", "Co-Sprecher", "Co-Sprecherinnen / Co-Sprecher", "DFG-Verfahren", "Ehemalige Antragsteller", "Ehemalige Antragstellerin", "Ehemalige Antragstellerinnen", "Ehemalige Antragstellerinnen / Ehemalige Antragsteller", "Ehemaliger Antragsteller", "Fachliche Zuordnung", "Förderung", "Gastgeber", "Gastgeberin", "Gastgeberinnen", "Gastgeberinnen / Gastgeber", "Gerätegruppe", "Großgeräte", "IGK-Partnerinstitution", "Internationaler Bezug", "Kooperationspartner", "Kooperationspartnerin", "Kooperationspartnerinnen", "Kooperationspartnerinnen / Kooperationspartner", "Leiter", "Leiterin", "Leiterinnen", "Leiterinnen / Leiter", "Mitantragstellende Institution", "Mitantragsteller", "Mitantragstellerin", "Mitantragstellerinnen", "Mitantragstellerinnen / Mitantragsteller", "Mitverantwortlich", "Mitverantwortlich(e)", "Mitverantwortliche", "Partnerorganisation", "Projektkennung", "Sprecher", "Sprecher (IGK-Partner)", "Sprecherin", "Sprecherin (IGK-Partner)", "Sprecherinnen", "Sprecherinnen (IGK-Partner) / Sprecher (IGK-Partner)", "Sprecherinnen / Sprecher", "Teilprojekt zu", "Teilprojektleiter", "Teilprojektleiterin", "Teilprojektleiterinnen", "Teilprojektleiterinnen / Teilprojektleiter", "Unternehmen", "Webseite", "ausländ", "ausländische Mitantragsteller", "ausländischer Mitantragsteller", "beteiligte Wissenschaftler", "beteiligte Wissenschaftlerin", "beteiligte Wissenschaftlerinnen", "beteiligte Wissenschaftlerinnen / beteiligte Wissenschaftler", "beteiligter Wissenschaftler", "description", "funding_end", "funding_start", "id", "link", "path", "person_creater_address", "person_creater_name", "stellvertr", "title"] model_config = ConfigDict( validate_by_name=True, @@ -127,11 +126,11 @@ class ProjectDfg(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ProjectDfg from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -141,7 +140,7 @@ class ProjectDfg(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -158,7 +157,7 @@ class ProjectDfg(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ProjectDfg from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg/stellvertr.py b/service/src/main/inse/models/projects_dfg/stellvertr.py index 641d6c33..5d83728a 100644 --- a/service/src/main/inse/models/projects_dfg/stellvertr.py +++ b/service/src/main/inse/models/projects_dfg/stellvertr.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects DFG All Index Backend Models @@ -9,29 +8,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.projects_dfg.stellvertr_sprecherinnen import StellvertrSprecherinnen -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, Field, StrictStr from pydantic_core import to_jsonable_python + class Stellvertr(BaseModel): """ Nested object for deputy speakers. - """ # noqa: E501 - sprecher: Optional[StrictStr] = Field(default=None, alias=" Sprecher") - sprecherin: Optional[StrictStr] = Field(default=None, alias=" Sprecherin") - sprecherinnen___stellvertr: Optional[StellvertrSprecherinnen] = Field(default=None, alias=" Sprecherinnen / stellvertr") - __properties: ClassVar[List[str]] = [" Sprecher", " Sprecherin", " Sprecherinnen / stellvertr"] + """ + sprecher: StrictStr | None = Field(default=None, alias=" Sprecher") + sprecherin: StrictStr | None = Field(default=None, alias=" Sprecherin") + sprecherinnen___stellvertr: StellvertrSprecherinnen | None = Field(default=None, alias=" Sprecherinnen / stellvertr") + __properties: ClassVar[list[str]] = [" Sprecher", " Sprecherin", " Sprecherinnen / stellvertr"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class Stellvertr(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Stellvertr from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class Stellvertr(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +77,7 @@ class Stellvertr(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Stellvertr from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg/stellvertr_sprecherinnen.py b/service/src/main/inse/models/projects_dfg/stellvertr_sprecherinnen.py index 6e072ff9..b7d054f3 100644 --- a/service/src/main/inse/models/projects_dfg/stellvertr_sprecherinnen.py +++ b/service/src/main/inse/models/projects_dfg/stellvertr_sprecherinnen.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects DFG All Index Backend Models @@ -9,26 +8,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class StellvertrSprecherinnen(BaseModel): """ Deeply nested object within stellvertr. - """ # noqa: E501 - sprecher: Optional[StrictStr] = Field(default=None, alias=" Sprecher") - __properties: ClassVar[List[str]] = [" Sprecher"] + """ + sprecher: StrictStr | None = Field(default=None, alias=" Sprecher") + __properties: ClassVar[list[str]] = [" Sprecher"] model_config = ConfigDict( validate_by_name=True, @@ -47,11 +46,11 @@ class StellvertrSprecherinnen(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of StellvertrSprecherinnen from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,7 +60,7 @@ class StellvertrSprecherinnen(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -72,7 +71,7 @@ class StellvertrSprecherinnen(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of StellvertrSprecherinnen from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute.py b/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute.py index 49e663a3..eed33c2c 100644 --- a/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute.py +++ b/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Institutes API @@ -9,57 +8,61 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + +from inse.models.projects_dfg_v2.institute.dfg_institute_institute import ( + DFGInstituteInstitute, +) +from inse.models.projects_dfg_v2.institute.dfg_institute_projects_inner import ( + DFGInstituteProjectsInner, +) from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.projects_dfg_v2.institute.dfg_institute_institute import DFGInstituteInstitute -from inse.models.projects_dfg_v2.institute.dfg_institute_projects_inner import DFGInstituteProjectsInner -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGInstitute(BaseModel): """ DFGInstitute - """ # noqa: E501 - address_city: Optional[StrictStr] = None - address_country_de: Optional[StrictStr] = None - address_country_en: Optional[StrictStr] = None - address_hidden: Optional[StrictBool] = None - address_postal_code_city: Optional[StrictStr] = None - address_street: Optional[StrictStr] = None - aku_id: Optional[StrictInt] = None - fetched_at: Optional[datetime] = None - id: Optional[StrictInt] = None - institute: Optional[DFGInstituteInstitute] = None - institute_category_key: Optional[StrictStr] = None - institute_category_label_de: Optional[StrictStr] = None - institute_category_label_en: Optional[StrictStr] = None - institute_id: Optional[StrictInt] = None - institute_name_de: Optional[StrictStr] = None - institute_name_en: Optional[StrictStr] = None - institute_postal_address: Optional[StrictStr] = None - institute_type_key: Optional[StrictStr] = None - institute_type_label_de: Optional[StrictStr] = None - institute_type_label_en: Optional[StrictStr] = None - is_dissolved: Optional[StrictBool] = None - is_research_device: Optional[StrictBool] = None - link: Optional[StrictStr] = None - page_url: Optional[StrictStr] = None - project_types_order: Optional[StrictStr] = None - projects: Optional[List[DFGInstituteProjectsInner]] = None - root_id: Optional[StrictInt] = None - root_name_de: Optional[StrictStr] = None - root_name_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["address_city", "address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "fetched_at", "id", "institute", "institute_category_key", "institute_category_label_de", "institute_category_label_en", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "institute_type_key", "institute_type_label_de", "institute_type_label_en", "is_dissolved", "is_research_device", "link", "page_url", "project_types_order", "projects", "root_id", "root_name_de", "root_name_en"] + """ + address_city: StrictStr | None = None + address_country_de: StrictStr | None = None + address_country_en: StrictStr | None = None + address_hidden: StrictBool | None = None + address_postal_code_city: StrictStr | None = None + address_street: StrictStr | None = None + aku_id: StrictInt | None = None + fetched_at: datetime | None = None + id: StrictInt | None = None + institute: DFGInstituteInstitute | None = None + institute_category_key: StrictStr | None = None + institute_category_label_de: StrictStr | None = None + institute_category_label_en: StrictStr | None = None + institute_id: StrictInt | None = None + institute_name_de: StrictStr | None = None + institute_name_en: StrictStr | None = None + institute_postal_address: StrictStr | None = None + institute_type_key: StrictStr | None = None + institute_type_label_de: StrictStr | None = None + institute_type_label_en: StrictStr | None = None + is_dissolved: StrictBool | None = None + is_research_device: StrictBool | None = None + link: StrictStr | None = None + page_url: StrictStr | None = None + project_types_order: StrictStr | None = None + projects: list[DFGInstituteProjectsInner] | None = None + root_id: StrictInt | None = None + root_name_de: StrictStr | None = None + root_name_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["address_city", "address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "fetched_at", "id", "institute", "institute_category_key", "institute_category_label_de", "institute_category_label_en", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "institute_type_key", "institute_type_label_de", "institute_type_label_en", "is_dissolved", "is_research_device", "link", "page_url", "project_types_order", "projects", "root_id", "root_name_de", "root_name_en"] model_config = ConfigDict( validate_by_name=True, @@ -78,11 +81,11 @@ class DFGInstitute(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGInstitute from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -92,7 +95,7 @@ class DFGInstitute(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -113,7 +116,7 @@ class DFGInstitute(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGInstitute from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_institute.py b/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_institute.py index a3bd17ef..1047b878 100644 --- a/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_institute.py +++ b/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_institute.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Institutes API @@ -9,47 +8,47 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGInstituteInstitute(BaseModel): """ DFGInstituteInstitute - """ # noqa: E501 - address_city: Optional[StrictStr] = None - address_country_de: Optional[StrictStr] = None - address_country_en: Optional[StrictStr] = None - address_hidden: Optional[StrictBool] = None - address_postal_code_city: Optional[StrictStr] = None - address_street: Optional[StrictStr] = None - aku_id: Optional[StrictInt] = None - institute_category_key: Optional[StrictStr] = None - institute_category_label_de: Optional[StrictStr] = None - institute_category_label_en: Optional[StrictStr] = None - institute_id: Optional[StrictInt] = None - institute_name_de: Optional[StrictStr] = None - institute_name_en: Optional[StrictStr] = None - institute_postal_address: Optional[StrictStr] = None - institute_type_key: Optional[StrictStr] = None - institute_type_label_de: Optional[StrictStr] = None - institute_type_label_en: Optional[StrictStr] = None - is_dissolved: Optional[StrictBool] = None - is_research_device: Optional[StrictBool] = None - root_id: Optional[StrictInt] = None - root_name_de: Optional[StrictStr] = None - root_name_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["address_city", "address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "institute_category_key", "institute_category_label_de", "institute_category_label_en", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "institute_type_key", "institute_type_label_de", "institute_type_label_en", "is_dissolved", "is_research_device", "root_id", "root_name_de", "root_name_en"] + """ + address_city: StrictStr | None = None + address_country_de: StrictStr | None = None + address_country_en: StrictStr | None = None + address_hidden: StrictBool | None = None + address_postal_code_city: StrictStr | None = None + address_street: StrictStr | None = None + aku_id: StrictInt | None = None + institute_category_key: StrictStr | None = None + institute_category_label_de: StrictStr | None = None + institute_category_label_en: StrictStr | None = None + institute_id: StrictInt | None = None + institute_name_de: StrictStr | None = None + institute_name_en: StrictStr | None = None + institute_postal_address: StrictStr | None = None + institute_type_key: StrictStr | None = None + institute_type_label_de: StrictStr | None = None + institute_type_label_en: StrictStr | None = None + is_dissolved: StrictBool | None = None + is_research_device: StrictBool | None = None + root_id: StrictInt | None = None + root_name_de: StrictStr | None = None + root_name_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["address_city", "address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "institute_category_key", "institute_category_label_de", "institute_category_label_en", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "institute_type_key", "institute_type_label_de", "institute_type_label_en", "is_dissolved", "is_research_device", "root_id", "root_name_de", "root_name_en"] model_config = ConfigDict( validate_by_name=True, @@ -68,11 +67,11 @@ class DFGInstituteInstitute(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGInstituteInstitute from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -82,7 +81,7 @@ class DFGInstituteInstitute(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -93,7 +92,7 @@ class DFGInstituteInstitute(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGInstituteInstitute from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_projects_inner.py b/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_projects_inner.py index 5dd635dd..72cb1032 100644 --- a/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_projects_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/institute/dfg_institute_projects_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Institutes API @@ -9,42 +8,42 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGInstituteProjectsInner(BaseModel): """ DFGInstituteProjectsInner - """ # noqa: E501 - funding_end: Optional[StrictInt] = None - funding_period_de: Optional[StrictStr] = None - funding_period_en: Optional[StrictStr] = None - funding_start: Optional[StrictInt] = None - funding_type_de: Optional[StrictStr] = None - funding_type_en: Optional[StrictStr] = None - funding_type_key: Optional[StrictStr] = None - funding_type_sort: Optional[StrictStr] = None - institute_ref_id: Optional[StrictInt] = None - is_transfer_project: Optional[StrictBool] = None - project_id: Optional[StrictInt] = None - sort_criteria: Optional[StrictStr] = None - sort_year: Optional[StrictStr] = None - status_de: Optional[StrictStr] = None - status_en: Optional[StrictStr] = None - title_de: Optional[StrictStr] = None - title_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "institute_ref_id", "is_transfer_project", "project_id", "sort_criteria", "sort_year", "status_de", "status_en", "title_de", "title_en"] + """ + funding_end: StrictInt | None = None + funding_period_de: StrictStr | None = None + funding_period_en: StrictStr | None = None + funding_start: StrictInt | None = None + funding_type_de: StrictStr | None = None + funding_type_en: StrictStr | None = None + funding_type_key: StrictStr | None = None + funding_type_sort: StrictStr | None = None + institute_ref_id: StrictInt | None = None + is_transfer_project: StrictBool | None = None + project_id: StrictInt | None = None + sort_criteria: StrictStr | None = None + sort_year: StrictStr | None = None + status_de: StrictStr | None = None + status_en: StrictStr | None = None + title_de: StrictStr | None = None + title_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "institute_ref_id", "is_transfer_project", "project_id", "sort_criteria", "sort_year", "status_de", "status_en", "title_de", "title_en"] model_config = ConfigDict( validate_by_name=True, @@ -63,11 +62,11 @@ class DFGInstituteProjectsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGInstituteProjectsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -77,7 +76,7 @@ class DFGInstituteProjectsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -88,7 +87,7 @@ class DFGInstituteProjectsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGInstituteProjectsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person.py b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person.py index 4cab237e..81711cdf 100644 --- a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person.py +++ b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Persons API @@ -9,55 +8,59 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.projects_dfg_v2.person.dfg_person_awards_inner import DFGPersonAwardsInner +from typing import Any, ClassVar, Self + +from inse.models.projects_dfg_v2.person.dfg_person_awards_inner import ( + DFGPersonAwardsInner, +) from inse.models.projects_dfg_v2.person.dfg_person_person import DFGPersonPerson -from inse.models.projects_dfg_v2.person.dfg_person_projects_inner import DFGPersonProjectsInner -from typing import Optional, Set -from typing_extensions import Self +from inse.models.projects_dfg_v2.person.dfg_person_projects_inner import ( + DFGPersonProjectsInner, +) +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr from pydantic_core import to_jsonable_python + class DFGPerson(BaseModel): """ DFGPerson - """ # noqa: E501 - address_country_de: Optional[StrictStr] = None - address_country_en: Optional[StrictStr] = None - address_hidden: Optional[StrictBool] = None - address_postal_code_city: Optional[StrictStr] = None - address_street: Optional[StrictStr] = None - aku_id: Optional[StrictInt] = None - award_types_order: Optional[StrictStr] = None - awards: Optional[List[DFGPersonAwardsInner]] = None - fetched_at: Optional[datetime] = None - full_name: Optional[StrictStr] = None - id: Optional[StrictInt] = None - institute_id: Optional[StrictInt] = None - institute_name_de: Optional[StrictStr] = None - institute_name_en: Optional[StrictStr] = None - institute_postal_address: Optional[StrictStr] = None - is_deceased: Optional[StrictBool] = None - link: Optional[StrictStr] = None - orcid_id: Optional[StrictStr] = None - page_url: Optional[StrictStr] = None - person: Optional[DFGPersonPerson] = None - person_id: Optional[StrictInt] = None - project_types_order: Optional[StrictStr] = None - projects: Optional[List[DFGPersonProjectsInner]] = None - root_id: Optional[StrictInt] = None - root_name_de: Optional[StrictStr] = None - root_name_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "award_types_order", "awards", "fetched_at", "full_name", "id", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "is_deceased", "link", "orcid_id", "page_url", "person", "person_id", "project_types_order", "projects", "root_id", "root_name_de", "root_name_en"] + """ + address_country_de: StrictStr | None = None + address_country_en: StrictStr | None = None + address_hidden: StrictBool | None = None + address_postal_code_city: StrictStr | None = None + address_street: StrictStr | None = None + aku_id: StrictInt | None = None + award_types_order: StrictStr | None = None + awards: list[DFGPersonAwardsInner] | None = None + fetched_at: datetime | None = None + full_name: StrictStr | None = None + id: StrictInt | None = None + institute_id: StrictInt | None = None + institute_name_de: StrictStr | None = None + institute_name_en: StrictStr | None = None + institute_postal_address: StrictStr | None = None + is_deceased: StrictBool | None = None + link: StrictStr | None = None + orcid_id: StrictStr | None = None + page_url: StrictStr | None = None + person: DFGPersonPerson | None = None + person_id: StrictInt | None = None + project_types_order: StrictStr | None = None + projects: list[DFGPersonProjectsInner] | None = None + root_id: StrictInt | None = None + root_name_de: StrictStr | None = None + root_name_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "award_types_order", "awards", "fetched_at", "full_name", "id", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "is_deceased", "link", "orcid_id", "page_url", "person", "person_id", "project_types_order", "projects", "root_id", "root_name_de", "root_name_en"] model_config = ConfigDict( validate_by_name=True, @@ -76,11 +79,11 @@ class DFGPerson(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGPerson from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -90,7 +93,7 @@ class DFGPerson(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -118,7 +121,7 @@ class DFGPerson(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGPerson from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_awards_inner.py b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_awards_inner.py index 6d64c699..a3c7c140 100644 --- a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_awards_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_awards_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Persons API @@ -9,40 +8,40 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGPersonAwardsInner(BaseModel): """ DFGPersonAwardsInner - """ # noqa: E501 - award_group_key: Optional[StrictStr] = None - award_id: Optional[StrictInt] = None - award_key: Optional[StrictStr] = None - award_label_de: Optional[StrictStr] = None - award_label_en: Optional[StrictStr] = None - person_ref_id: Optional[StrictInt] = None - pseudo_project_id: Optional[StrictInt] = None - sort_criteria: Optional[StrictStr] = None - text_de: Optional[StrictStr] = None - text_en: Optional[StrictStr] = None - title_de: Optional[StrictStr] = None - title_en: Optional[StrictStr] = None - url_de: Optional[StrictStr] = None - url_en: Optional[StrictStr] = None - year: Optional[StrictInt] = None - __properties: ClassVar[List[str]] = ["award_group_key", "award_id", "award_key", "award_label_de", "award_label_en", "person_ref_id", "pseudo_project_id", "sort_criteria", "text_de", "text_en", "title_de", "title_en", "url_de", "url_en", "year"] + """ + award_group_key: StrictStr | None = None + award_id: StrictInt | None = None + award_key: StrictStr | None = None + award_label_de: StrictStr | None = None + award_label_en: StrictStr | None = None + person_ref_id: StrictInt | None = None + pseudo_project_id: StrictInt | None = None + sort_criteria: StrictStr | None = None + text_de: StrictStr | None = None + text_en: StrictStr | None = None + title_de: StrictStr | None = None + title_en: StrictStr | None = None + url_de: StrictStr | None = None + url_en: StrictStr | None = None + year: StrictInt | None = None + __properties: ClassVar[list[str]] = ["award_group_key", "award_id", "award_key", "award_label_de", "award_label_en", "person_ref_id", "pseudo_project_id", "sort_criteria", "text_de", "text_en", "title_de", "title_en", "url_de", "url_en", "year"] model_config = ConfigDict( validate_by_name=True, @@ -61,11 +60,11 @@ class DFGPersonAwardsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGPersonAwardsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -75,7 +74,7 @@ class DFGPersonAwardsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -86,7 +85,7 @@ class DFGPersonAwardsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGPersonAwardsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_person.py b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_person.py index e9517466..09752404 100644 --- a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_person.py +++ b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_person.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Persons API @@ -9,42 +8,42 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGPersonPerson(BaseModel): """ DFGPersonPerson - """ # noqa: E501 - address_country_de: Optional[StrictStr] = None - address_country_en: Optional[StrictStr] = None - address_hidden: Optional[StrictBool] = None - address_postal_code_city: Optional[StrictStr] = None - address_street: Optional[StrictStr] = None - aku_id: Optional[StrictInt] = None - full_name: Optional[StrictStr] = None - institute_id: Optional[StrictInt] = None - institute_name_de: Optional[StrictStr] = None - institute_name_en: Optional[StrictStr] = None - institute_postal_address: Optional[StrictStr] = None - is_deceased: Optional[StrictBool] = None - orcid_id: Optional[StrictStr] = None - person_id: Optional[StrictInt] = None - root_id: Optional[StrictInt] = None - root_name_de: Optional[StrictStr] = None - root_name_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "full_name", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "is_deceased", "orcid_id", "person_id", "root_id", "root_name_de", "root_name_en"] + """ + address_country_de: StrictStr | None = None + address_country_en: StrictStr | None = None + address_hidden: StrictBool | None = None + address_postal_code_city: StrictStr | None = None + address_street: StrictStr | None = None + aku_id: StrictInt | None = None + full_name: StrictStr | None = None + institute_id: StrictInt | None = None + institute_name_de: StrictStr | None = None + institute_name_en: StrictStr | None = None + institute_postal_address: StrictStr | None = None + is_deceased: StrictBool | None = None + orcid_id: StrictStr | None = None + person_id: StrictInt | None = None + root_id: StrictInt | None = None + root_name_de: StrictStr | None = None + root_name_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["address_country_de", "address_country_en", "address_hidden", "address_postal_code_city", "address_street", "aku_id", "full_name", "institute_id", "institute_name_de", "institute_name_en", "institute_postal_address", "is_deceased", "orcid_id", "person_id", "root_id", "root_name_de", "root_name_en"] model_config = ConfigDict( validate_by_name=True, @@ -63,11 +62,11 @@ class DFGPersonPerson(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGPersonPerson from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -77,7 +76,7 @@ class DFGPersonPerson(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -88,7 +87,7 @@ class DFGPersonPerson(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGPersonPerson from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_projects_inner.py b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_projects_inner.py index 6c5349af..0307ffc0 100644 --- a/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_projects_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/person/dfg_person_projects_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Persons API @@ -9,46 +8,46 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGPersonProjectsInner(BaseModel): """ DFGPersonProjectsInner - """ # noqa: E501 - funding_end: Optional[StrictInt] = None - funding_period_de: Optional[StrictStr] = None - funding_period_en: Optional[StrictStr] = None - funding_start: Optional[StrictInt] = None - funding_type_de: Optional[StrictStr] = None - funding_type_en: Optional[StrictStr] = None - funding_type_key: Optional[StrictStr] = None - participants_de: Optional[StrictStr] = None - participants_en: Optional[StrictStr] = None - person_ref_id: Optional[StrictInt] = None - project_id: Optional[StrictInt] = None - role_key: Optional[StrictStr] = None - role_label_de: Optional[StrictStr] = None - role_label_en: Optional[StrictStr] = None - role_sort: Optional[StrictStr] = None - sort_criteria: Optional[StrictStr] = None - sort_year: Optional[StrictStr] = None - status_de: Optional[StrictStr] = None - status_en: Optional[StrictStr] = None - title_de: Optional[StrictStr] = None - title_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "participants_de", "participants_en", "person_ref_id", "project_id", "role_key", "role_label_de", "role_label_en", "role_sort", "sort_criteria", "sort_year", "status_de", "status_en", "title_de", "title_en"] + """ + funding_end: StrictInt | None = None + funding_period_de: StrictStr | None = None + funding_period_en: StrictStr | None = None + funding_start: StrictInt | None = None + funding_type_de: StrictStr | None = None + funding_type_en: StrictStr | None = None + funding_type_key: StrictStr | None = None + participants_de: StrictStr | None = None + participants_en: StrictStr | None = None + person_ref_id: StrictInt | None = None + project_id: StrictInt | None = None + role_key: StrictStr | None = None + role_label_de: StrictStr | None = None + role_label_en: StrictStr | None = None + role_sort: StrictStr | None = None + sort_criteria: StrictStr | None = None + sort_year: StrictStr | None = None + status_de: StrictStr | None = None + status_en: StrictStr | None = None + title_de: StrictStr | None = None + title_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "participants_de", "participants_en", "person_ref_id", "project_id", "role_key", "role_label_de", "role_label_en", "role_sort", "sort_criteria", "sort_year", "status_de", "status_en", "title_de", "title_en"] model_config = ConfigDict( validate_by_name=True, @@ -67,11 +66,11 @@ class DFGPersonProjectsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGPersonProjectsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -81,7 +80,7 @@ class DFGPersonProjectsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -92,7 +91,7 @@ class DFGPersonProjectsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGPersonProjectsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py index f2bc28d7..8ae70f97 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Projects API @@ -9,79 +8,89 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import DFGProjectFachgebieteInner -from inse.models.projects_dfg_v2.project.dfg_project_institutions_inner import DFGProjectInstitutionsInner -from inse.models.projects_dfg_v2.project.dfg_project_persons_inner import DFGProjectPersonsInner -from inse.models.projects_dfg_v2.project.dfg_project_project import DFGProjectProject -from inse.models.projects_dfg_v2.project.dfg_project_publications_inner import DFGProjectPublicationsInner -from inse.models.projects_dfg_v2.project.dfg_project_subprojects_inner import DFGProjectSubprojectsInner -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from typing import Any, ClassVar, Self + from inse.models.openalex.topic import Topic, TopicDomain, TopicField, TopicSubfield +from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import ( + DFGProjectFachgebieteInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_institutions_inner import ( + DFGProjectInstitutionsInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_persons_inner import ( + DFGProjectPersonsInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_project import DFGProjectProject +from inse.models.projects_dfg_v2.project.dfg_project_publications_inner import ( + DFGProjectPublicationsInner, +) +from inse.models.projects_dfg_v2.project.dfg_project_subprojects_inner import ( + DFGProjectSubprojectsInner, +) +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from pydantic_core import to_jsonable_python + class DFGProject(BaseModel): """ DFGProject - """ # noqa: E501 - abstract_de: Optional[StrictStr] = None - abstract_en: Optional[StrictStr] = None - equipment_group: Optional[StrictStr] = None - equipment_name: Optional[StrictStr] = None - external_link: Optional[StrictStr] = None - fachgebiete: Optional[List[DFGProjectFachgebieteInner]] = None - fetched_at: Optional[datetime] = None - final_report_abstract_de: Optional[StrictStr] = None - final_report_abstract_en: Optional[StrictStr] = None - funding_end: Optional[StrictInt] = None - funding_period_de: Optional[StrictStr] = None - funding_period_en: Optional[StrictStr] = None - funding_start: Optional[StrictInt] = None - funding_type_de: Optional[StrictStr] = None - funding_type_en: Optional[StrictStr] = None - funding_type_key: Optional[StrictStr] = None - funding_type_sort: Optional[StrictStr] = None - id: Optional[StrictInt] = None - institution_roles_order: Optional[list[StrictStr]] = None - institutions: Optional[List[DFGProjectInstitutionsInner]] = None - international_relation_de: Optional[StrictStr] = None - international_relation_en: Optional[StrictStr] = None - is_transfer_project: Optional[StrictBool] = None - link: Optional[StrictStr] = None - page_url: Optional[StrictStr] = None - parent_project_id: Optional[StrictInt] = None - parent_title_de: Optional[StrictStr] = None - parent_title_en: Optional[StrictStr] = None - person_roles_order: Optional[list[StrictStr]] = None - persons: Optional[List[DFGProjectPersonsInner]] = None - project: Optional[DFGProjectProject] = None - project_id: Optional[StrictInt] = None - project_identifier_de: Optional[StrictStr] = None - project_identifier_en: Optional[StrictStr] = None - publications: Optional[List[DFGProjectPublicationsInner]] = None - subject_area_de: Optional[StrictStr] = None - subject_area_en: Optional[StrictStr] = None - subject_classifications: Optional[DFGProjectFachgebieteInner] = None - subproject_order: Optional[list[StrictStr]] = None - subprojects: Optional[List[DFGProjectSubprojectsInner]] = None - template_type: Optional[StrictStr] = None - title_de: Optional[StrictStr] = None - title_en: Optional[StrictStr] = None - website_html_de: Optional[StrictStr] = None - website_html_en: Optional[StrictStr] = None - topics: Optional[List[Topic]] = None - __properties: ClassVar[List[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link", "fachgebiete", "fetched_at", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "id", "institution_roles_order", "institutions", "international_relation_de", "international_relation_en", "is_transfer_project", "link", "page_url", "parent_project_id", "parent_title_de", "parent_title_en", "person_roles_order", "persons", "project", "project_id", "project_identifier_de", "project_identifier_en", "publications", "subject_area_de", "subject_area_en", "subject_classifications", "subproject_order", "subprojects", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"] + """ + abstract_de: StrictStr | None = None + abstract_en: StrictStr | None = None + equipment_group: StrictStr | None = None + equipment_name: StrictStr | None = None + external_link: StrictStr | None = None + fachgebiete: list[DFGProjectFachgebieteInner] | None = None + fetched_at: datetime | None = None + final_report_abstract_de: StrictStr | None = None + final_report_abstract_en: StrictStr | None = None + funding_end: StrictInt | None = None + funding_period_de: StrictStr | None = None + funding_period_en: StrictStr | None = None + funding_start: StrictInt | None = None + funding_type_de: StrictStr | None = None + funding_type_en: StrictStr | None = None + funding_type_key: StrictStr | None = None + funding_type_sort: StrictStr | None = None + id: StrictInt | None = None + institution_roles_order: list[StrictStr] | None = None + institutions: list[DFGProjectInstitutionsInner] | None = None + international_relation_de: StrictStr | None = None + international_relation_en: StrictStr | None = None + is_transfer_project: StrictBool | None = None + link: StrictStr | None = None + page_url: StrictStr | None = None + parent_project_id: StrictInt | None = None + parent_title_de: StrictStr | None = None + parent_title_en: StrictStr | None = None + person_roles_order: list[StrictStr] | None = None + persons: list[DFGProjectPersonsInner] | None = None + project: DFGProjectProject | None = None + project_id: StrictInt | None = None + project_identifier_de: StrictStr | None = None + project_identifier_en: StrictStr | None = None + publications: list[DFGProjectPublicationsInner] | None = None + subject_area_de: StrictStr | None = None + subject_area_en: StrictStr | None = None + subject_classifications: DFGProjectFachgebieteInner | None = None + subproject_order: list[StrictStr] | None = None + subprojects: list[DFGProjectSubprojectsInner] | None = None + template_type: StrictStr | None = None + title_de: StrictStr | None = None + title_en: StrictStr | None = None + website_html_de: StrictStr | None = None + website_html_en: StrictStr | None = None + topics: list[Topic] | None = None + __properties: ClassVar[list[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link", "fachgebiete", "fetched_at", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "id", "institution_roles_order", "institutions", "international_relation_de", "international_relation_en", "is_transfer_project", "link", "page_url", "parent_project_id", "parent_title_de", "parent_title_en", "person_roles_order", "persons", "project", "project_id", "project_identifier_de", "project_identifier_en", "publications", "subject_area_de", "subject_area_en", "subject_classifications", "subproject_order", "subprojects", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"] model_config = ConfigDict( validate_by_name=True, @@ -100,11 +109,11 @@ class DFGProject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGProject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -114,7 +123,7 @@ class DFGProject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -166,7 +175,7 @@ class DFGProject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGProject from a dict""" if obj is None: return None @@ -234,7 +243,7 @@ class DFGProject(BaseModel): return _obj @staticmethod - def _topic_from_match(match: Dict[str, Any]) -> Topic: + def _topic_from_match(match: dict[str, Any]) -> Topic: """Builds a Topic model from a flattened topic_match dict. """ domain_name = match.get("domain") diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_fachgebiete_inner.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_fachgebiete_inner.py index 1ca663c5..4a57aa59 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_fachgebiete_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_fachgebiete_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Projects API @@ -9,33 +8,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGProjectFachgebieteInner(BaseModel): """ DFGProjectFachgebieteInner - """ # noqa: E501 - fach: Optional[StrictStr] = None - fach_code: Optional[StrictStr] = None - fachgebiet: Optional[StrictStr] = None - fachgebiet_code: Optional[StrictStr] = None - fachkollegium: Optional[StrictStr] = None - fachkollegium_code: Optional[StrictStr] = None - wissenschaftsbereich: Optional[StrictStr] = None - wissenschaftsbereich_code: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["fach", "fach_code", "fachgebiet", "fachgebiet_code", "fachkollegium", "fachkollegium_code", "wissenschaftsbereich", "wissenschaftsbereich_code"] + """ + fach: StrictStr | None = None + fach_code: StrictStr | None = None + fachgebiet: StrictStr | None = None + fachgebiet_code: StrictStr | None = None + fachkollegium: StrictStr | None = None + fachkollegium_code: StrictStr | None = None + wissenschaftsbereich: StrictStr | None = None + wissenschaftsbereich_code: StrictStr | None = None + __properties: ClassVar[list[str]] = ["fach", "fach_code", "fachgebiet", "fachgebiet_code", "fachkollegium", "fachkollegium_code", "wissenschaftsbereich", "wissenschaftsbereich_code"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class DFGProjectFachgebieteInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGProjectFachgebieteInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class DFGProjectFachgebieteInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class DFGProjectFachgebieteInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGProjectFachgebieteInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_institutions_inner.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_institutions_inner.py index d9f4dd02..fb20679a 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_institutions_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_institutions_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Projects API @@ -9,41 +8,41 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGProjectInstitutionsInner(BaseModel): """ DFGProjectInstitutionsInner - """ # noqa: E501 - dissolution_date: Optional[datetime] = None - has_detail_page: Optional[StrictBool] = None - institute_id: Optional[StrictInt] = None - institute_name_de: Optional[StrictStr] = None - institute_name_en: Optional[StrictStr] = None - is_dissolved: Optional[StrictBool] = None - is_head_display: Optional[StrictBool] = None - project_ref_id: Optional[StrictInt] = None - role_group_label_de: Optional[StrictStr] = None - role_key: Optional[StrictStr] = None - role_label_de: Optional[StrictStr] = None - role_label_en: Optional[StrictStr] = None - role_sort: Optional[StrictStr] = None - sort_criteria: Optional[StrictStr] = None - sort_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["dissolution_date", "has_detail_page", "institute_id", "institute_name_de", "institute_name_en", "is_dissolved", "is_head_display", "project_ref_id", "role_group_label_de", "role_key", "role_label_de", "role_label_en", "role_sort", "sort_criteria", "sort_name"] + """ + dissolution_date: datetime | None = None + has_detail_page: StrictBool | None = None + institute_id: StrictInt | None = None + institute_name_de: StrictStr | None = None + institute_name_en: StrictStr | None = None + is_dissolved: StrictBool | None = None + is_head_display: StrictBool | None = None + project_ref_id: StrictInt | None = None + role_group_label_de: StrictStr | None = None + role_key: StrictStr | None = None + role_label_de: StrictStr | None = None + role_label_en: StrictStr | None = None + role_sort: StrictStr | None = None + sort_criteria: StrictStr | None = None + sort_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["dissolution_date", "has_detail_page", "institute_id", "institute_name_de", "institute_name_en", "is_dissolved", "is_head_display", "project_ref_id", "role_group_label_de", "role_key", "role_label_de", "role_label_en", "role_sort", "sort_criteria", "sort_name"] model_config = ConfigDict( validate_by_name=True, @@ -62,11 +61,11 @@ class DFGProjectInstitutionsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGProjectInstitutionsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -76,7 +75,7 @@ class DFGProjectInstitutionsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -87,7 +86,7 @@ class DFGProjectInstitutionsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGProjectInstitutionsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_persons_inner.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_persons_inner.py index fe4596e5..e427f903 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_persons_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_persons_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Projects API @@ -9,41 +8,41 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGProjectPersonsInner(BaseModel): """ DFGProjectPersonsInner - """ # noqa: E501 - affiliation_de: Optional[StrictStr] = None - affiliation_en: Optional[StrictStr] = None - award_text_de: Optional[StrictStr] = None - award_text_en: Optional[StrictStr] = None - full_name: Optional[StrictStr] = None - is_deceased: Optional[StrictBool] = None - is_head_display: Optional[StrictBool] = None - person_id: Optional[StrictInt] = None - project_ref_id: Optional[StrictInt] = None - role_group_label_de: Optional[StrictStr] = None - role_key: Optional[StrictStr] = None - role_label_de: Optional[StrictStr] = None - role_label_en: Optional[StrictStr] = None - role_sort: Optional[StrictStr] = None - sort_criteria: Optional[StrictStr] = None - sort_name: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["affiliation_de", "affiliation_en", "award_text_de", "award_text_en", "full_name", "is_deceased", "is_head_display", "person_id", "project_ref_id", "role_group_label_de", "role_key", "role_label_de", "role_label_en", "role_sort", "sort_criteria", "sort_name"] + """ + affiliation_de: StrictStr | None = None + affiliation_en: StrictStr | None = None + award_text_de: StrictStr | None = None + award_text_en: StrictStr | None = None + full_name: StrictStr | None = None + is_deceased: StrictBool | None = None + is_head_display: StrictBool | None = None + person_id: StrictInt | None = None + project_ref_id: StrictInt | None = None + role_group_label_de: StrictStr | None = None + role_key: StrictStr | None = None + role_label_de: StrictStr | None = None + role_label_en: StrictStr | None = None + role_sort: StrictStr | None = None + sort_criteria: StrictStr | None = None + sort_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["affiliation_de", "affiliation_en", "award_text_de", "award_text_en", "full_name", "is_deceased", "is_head_display", "person_id", "project_ref_id", "role_group_label_de", "role_key", "role_label_de", "role_label_en", "role_sort", "sort_criteria", "sort_name"] model_config = ConfigDict( validate_by_name=True, @@ -62,11 +61,11 @@ class DFGProjectPersonsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGProjectPersonsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -76,7 +75,7 @@ class DFGProjectPersonsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -87,7 +86,7 @@ class DFGProjectPersonsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGProjectPersonsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_project.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_project.py index 9a1b954f..38a2cb1d 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_project.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_project.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Projects API @@ -9,56 +8,56 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGProjectProject(BaseModel): """ DFGProjectProject - """ # noqa: E501 - abstract_de: Optional[StrictStr] = None - abstract_en: Optional[StrictStr] = None - equipment_group: Optional[StrictStr] = None - equipment_name: Optional[StrictStr] = None - external_link: Optional[StrictStr] = None - final_report_abstract_de: Optional[StrictStr] = None - final_report_abstract_en: Optional[StrictStr] = None - funding_end: Optional[StrictInt] = None - funding_period_de: Optional[StrictStr] = None - funding_period_en: Optional[StrictStr] = None - funding_start: Optional[StrictInt] = None - funding_type_de: Optional[StrictStr] = None - funding_type_en: Optional[StrictStr] = None - funding_type_key: Optional[StrictStr] = None - funding_type_sort: Optional[StrictStr] = None - international_relation_de: Optional[StrictStr] = None - international_relation_en: Optional[StrictStr] = None - is_transfer_project: Optional[StrictBool] = None - parent_project_id: Optional[StrictInt] = None - parent_title_de: Optional[StrictStr] = None - parent_title_en: Optional[StrictStr] = None - project_id: Optional[StrictInt] = None - project_identifier_de: Optional[StrictStr] = None - project_identifier_en: Optional[StrictStr] = None - subject_area_de: Optional[StrictStr] = None - subject_area_en: Optional[StrictStr] = None - template_type: Optional[StrictStr] = None - title_de: Optional[StrictStr] = None - title_en: Optional[StrictStr] = None - website_html_de: Optional[StrictStr] = None - website_html_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "international_relation_de", "international_relation_en", "is_transfer_project", "parent_project_id", "parent_title_de", "parent_title_en", "project_id", "project_identifier_de", "project_identifier_en", "subject_area_de", "subject_area_en", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"] + """ + abstract_de: StrictStr | None = None + abstract_en: StrictStr | None = None + equipment_group: StrictStr | None = None + equipment_name: StrictStr | None = None + external_link: StrictStr | None = None + final_report_abstract_de: StrictStr | None = None + final_report_abstract_en: StrictStr | None = None + funding_end: StrictInt | None = None + funding_period_de: StrictStr | None = None + funding_period_en: StrictStr | None = None + funding_start: StrictInt | None = None + funding_type_de: StrictStr | None = None + funding_type_en: StrictStr | None = None + funding_type_key: StrictStr | None = None + funding_type_sort: StrictStr | None = None + international_relation_de: StrictStr | None = None + international_relation_en: StrictStr | None = None + is_transfer_project: StrictBool | None = None + parent_project_id: StrictInt | None = None + parent_title_de: StrictStr | None = None + parent_title_en: StrictStr | None = None + project_id: StrictInt | None = None + project_identifier_de: StrictStr | None = None + project_identifier_en: StrictStr | None = None + subject_area_de: StrictStr | None = None + subject_area_en: StrictStr | None = None + template_type: StrictStr | None = None + title_de: StrictStr | None = None + title_en: StrictStr | None = None + website_html_de: StrictStr | None = None + website_html_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "international_relation_de", "international_relation_en", "is_transfer_project", "parent_project_id", "parent_title_de", "parent_title_en", "project_id", "project_identifier_de", "project_identifier_en", "subject_area_de", "subject_area_en", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"] model_config = ConfigDict( validate_by_name=True, @@ -77,11 +76,11 @@ class DFGProjectProject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGProjectProject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -91,7 +90,7 @@ class DFGProjectProject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -102,7 +101,7 @@ class DFGProjectProject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGProjectProject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_publications_inner.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_publications_inner.py index 3f4cf32c..f1f525b0 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_publications_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_publications_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Projects API @@ -9,32 +8,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGProjectPublicationsInner(BaseModel): """ DFGProjectPublicationsInner - """ # noqa: E501 - authors_editors: Optional[StrictStr] = None - doi: Optional[StrictStr] = None - project_ref_id: Optional[StrictInt] = None - publication_id: Optional[StrictInt] = None - publication_year: Optional[StrictInt] = None - sort_key: Optional[StrictInt] = None - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["authors_editors", "doi", "project_ref_id", "publication_id", "publication_year", "sort_key", "title"] + """ + authors_editors: StrictStr | None = None + doi: StrictStr | None = None + project_ref_id: StrictInt | None = None + publication_id: StrictInt | None = None + publication_year: StrictInt | None = None + sort_key: StrictInt | None = None + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["authors_editors", "doi", "project_ref_id", "publication_id", "publication_year", "sort_key", "title"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +52,11 @@ class DFGProjectPublicationsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGProjectPublicationsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +66,7 @@ class DFGProjectPublicationsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +77,7 @@ class DFGProjectPublicationsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGProjectPublicationsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_subprojects_inner.py b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_subprojects_inner.py index d7bf0801..8bb00c1f 100644 --- a/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_subprojects_inner.py +++ b/service/src/main/inse/models/projects_dfg_v2/project/dfg_project_subprojects_inner.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ DFG Projects API @@ -9,47 +8,47 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DFGProjectSubprojectsInner(BaseModel): """ DFGProjectSubprojectsInner - """ # noqa: E501 - funding_end: Optional[StrictInt] = None - funding_period_de: Optional[StrictStr] = None - funding_period_en: Optional[StrictStr] = None - funding_start: Optional[StrictInt] = None - group_label_de: Optional[StrictStr] = None - group_label_en: Optional[StrictStr] = None - is_head_display: Optional[StrictBool] = None - parent_project_id: Optional[StrictInt] = None - person_first_names: Optional[StrictStr] = None - person_id: Optional[StrictInt] = None - person_last_name: Optional[StrictStr] = None - role_group_label_de: Optional[StrictStr] = None - role_key: Optional[StrictStr] = None - role_label_de: Optional[StrictStr] = None - short_title: Optional[StrictStr] = None - sort_criteria: Optional[StrictStr] = None - sort_key: Optional[StrictStr] = None - status_de: Optional[StrictStr] = None - status_en: Optional[StrictStr] = None - subproject_id: Optional[StrictInt] = None - title_de: Optional[StrictStr] = None - title_en: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["funding_end", "funding_period_de", "funding_period_en", "funding_start", "group_label_de", "group_label_en", "is_head_display", "parent_project_id", "person_first_names", "person_id", "person_last_name", "role_group_label_de", "role_key", "role_label_de", "short_title", "sort_criteria", "sort_key", "status_de", "status_en", "subproject_id", "title_de", "title_en"] + """ + funding_end: StrictInt | None = None + funding_period_de: StrictStr | None = None + funding_period_en: StrictStr | None = None + funding_start: StrictInt | None = None + group_label_de: StrictStr | None = None + group_label_en: StrictStr | None = None + is_head_display: StrictBool | None = None + parent_project_id: StrictInt | None = None + person_first_names: StrictStr | None = None + person_id: StrictInt | None = None + person_last_name: StrictStr | None = None + role_group_label_de: StrictStr | None = None + role_key: StrictStr | None = None + role_label_de: StrictStr | None = None + short_title: StrictStr | None = None + sort_criteria: StrictStr | None = None + sort_key: StrictStr | None = None + status_de: StrictStr | None = None + status_en: StrictStr | None = None + subproject_id: StrictInt | None = None + title_de: StrictStr | None = None + title_en: StrictStr | None = None + __properties: ClassVar[list[str]] = ["funding_end", "funding_period_de", "funding_period_en", "funding_start", "group_label_de", "group_label_en", "is_head_display", "parent_project_id", "person_first_names", "person_id", "person_last_name", "role_group_label_de", "role_key", "role_label_de", "short_title", "sort_criteria", "sort_key", "status_de", "status_en", "subproject_id", "title_de", "title_en"] model_config = ConfigDict( validate_by_name=True, @@ -68,11 +67,11 @@ class DFGProjectSubprojectsInner(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DFGProjectSubprojectsInner from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -82,7 +81,7 @@ class DFGProjectSubprojectsInner(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -93,7 +92,7 @@ class DFGProjectSubprojectsInner(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DFGProjectSubprojectsInner from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu/category_nested.py b/service/src/main/inse/models/projects_eu/category_nested.py index 3bf4c794..33f3ad18 100644 --- a/service/src/main/inse/models/projects_eu/category_nested.py +++ b/service/src/main/inse/models/projects_eu/category_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects EU All Index Backend Models @@ -9,31 +8,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self +from inse.models.projects_eu.display_code_splitted_nested import ( + DisplayCodeSplittedNested, +) from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from inse.models.projects_eu.display_code_splitted_nested import DisplayCodeSplittedNested -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class CategoryNested(BaseModel): """ First-level nested object for categories. - """ # noqa: E501 - category: Optional[StrictStr] = None - code: Optional[StrictStr] = None - display_code: Optional[StrictStr] = Field(default=None, alias="displayCode") - display_code_splitted: Optional[StrictStr] = Field(default=None, alias="displayCode_splitted") - display_code_splitted_nested: Optional[List[DisplayCodeSplittedNested]] = Field(default=None, alias="displayCode_splitted_nested") - __properties: ClassVar[List[str]] = ["category", "code", "displayCode", "displayCode_splitted", "displayCode_splitted_nested"] + """ + category: StrictStr | None = None + code: StrictStr | None = None + display_code: StrictStr | None = Field(default=None, alias="displayCode") + display_code_splitted: StrictStr | None = Field(default=None, alias="displayCode_splitted") + display_code_splitted_nested: list[DisplayCodeSplittedNested] | None = Field(default=None, alias="displayCode_splitted_nested") + __properties: ClassVar[list[str]] = ["category", "code", "displayCode", "displayCode_splitted", "displayCode_splitted_nested"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +53,11 @@ class CategoryNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of CategoryNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +67,7 @@ class CategoryNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -84,7 +85,7 @@ class CategoryNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of CategoryNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu/display_code_splitted_nested.py b/service/src/main/inse/models/projects_eu/display_code_splitted_nested.py index d5b2c829..5eb5f50b 100644 --- a/service/src/main/inse/models/projects_eu/display_code_splitted_nested.py +++ b/service/src/main/inse/models/projects_eu/display_code_splitted_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects EU All Index Backend Models @@ -9,26 +8,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class DisplayCodeSplittedNested(BaseModel): """ Second-level nested object inside categories. - """ # noqa: E501 - single_display_code: Optional[StrictStr] = Field(default=None, alias="singleDisplayCode") - __properties: ClassVar[List[str]] = ["singleDisplayCode"] + """ + single_display_code: StrictStr | None = Field(default=None, alias="singleDisplayCode") + __properties: ClassVar[list[str]] = ["singleDisplayCode"] model_config = ConfigDict( validate_by_name=True, @@ -47,11 +46,11 @@ class DisplayCodeSplittedNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of DisplayCodeSplittedNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,7 +60,7 @@ class DisplayCodeSplittedNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -72,7 +71,7 @@ class DisplayCodeSplittedNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of DisplayCodeSplittedNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu/keyword_nested.py b/service/src/main/inse/models/projects_eu/keyword_nested.py index 9b83f2f6..6c97b983 100644 --- a/service/src/main/inse/models/projects_eu/keyword_nested.py +++ b/service/src/main/inse/models/projects_eu/keyword_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects EU All Index Backend Models @@ -9,26 +8,26 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class KeywordNested(BaseModel): """ Nested object for individual keywords. - """ # noqa: E501 - keyword: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["keyword"] + """ + keyword: StrictStr | None = None + __properties: ClassVar[list[str]] = ["keyword"] model_config = ConfigDict( validate_by_name=True, @@ -47,11 +46,11 @@ class KeywordNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of KeywordNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -61,7 +60,7 @@ class KeywordNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -72,7 +71,7 @@ class KeywordNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of KeywordNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu/organization_nested.py b/service/src/main/inse/models/projects_eu/organization_nested.py index 3c87569b..54890b5a 100644 --- a/service/src/main/inse/models/projects_eu/organization_nested.py +++ b/service/src/main/inse/models/projects_eu/organization_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects EU All Index Backend Models @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class OrganizationNested(BaseModel): """ Nested object for project organizations. - """ # noqa: E501 - ec_contribution: Optional[StrictStr] = Field(default=None, alias="ecContribution") - id: Optional[StrictStr] = None - name: Optional[StrictStr] = None - net_ec_contribution: Optional[StrictStr] = Field(default=None, alias="netEcContribution") - total_cost: Optional[StrictStr] = Field(default=None, alias="totalCost") - type: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["ecContribution", "id", "name", "netEcContribution", "totalCost", "type"] + """ + ec_contribution: StrictStr | None = Field(default=None, alias="ecContribution") + id: StrictStr | None = None + name: StrictStr | None = None + net_ec_contribution: StrictStr | None = Field(default=None, alias="netEcContribution") + total_cost: StrictStr | None = Field(default=None, alias="totalCost") + type: StrictStr | None = None + __properties: ClassVar[list[str]] = ["ecContribution", "id", "name", "netEcContribution", "totalCost", "type"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class OrganizationNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of OrganizationNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class OrganizationNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class OrganizationNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of OrganizationNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu/programme_nested.py b/service/src/main/inse/models/projects_eu/programme_nested.py index 07cdd49f..771ddfea 100644 --- a/service/src/main/inse/models/projects_eu/programme_nested.py +++ b/service/src/main/inse/models/projects_eu/programme_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects EU All Index Backend Models @@ -9,28 +8,28 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class ProgrammeNested(BaseModel): """ Nested object for related programmes. - """ # noqa: E501 - code: Optional[StrictStr] = None - id: Optional[StrictStr] = None - programme: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["code", "id", "programme"] + """ + code: StrictStr | None = None + id: StrictStr | None = None + programme: StrictStr | None = None + __properties: ClassVar[list[str]] = ["code", "id", "programme"] model_config = ConfigDict( validate_by_name=True, @@ -49,11 +48,11 @@ class ProgrammeNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ProgrammeNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -63,7 +62,7 @@ class ProgrammeNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -74,7 +73,7 @@ class ProgrammeNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ProgrammeNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu/project_eu.py b/service/src/main/inse/models/projects_eu/project_eu.py index c332409d..42608e4e 100644 --- a/service/src/main/inse/models/projects_eu/project_eu.py +++ b/service/src/main/inse/models/projects_eu/project_eu.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ Projects EU All Index Backend Models @@ -9,50 +8,50 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.projects_eu.category_nested import CategoryNested from inse.models.projects_eu.keyword_nested import KeywordNested from inse.models.projects_eu.organization_nested import OrganizationNested from inse.models.projects_eu.programme_nested import ProgrammeNested -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, Field, StrictStr from pydantic_core import to_jsonable_python + class ProjectEu(BaseModel): """ Main document model for the projects_eu_all index. - """ # noqa: E501 - acronym: Optional[StrictStr] = None - categories_nested: Optional[List[CategoryNested]] = None - doc_number: Optional[StrictStr] = None - doi: Optional[StrictStr] = None - ec_max_contribution: Optional[StrictStr] = Field(default=None, alias="ecMaxContribution") - end_date: Optional[StrictStr] = Field(default=None, alias="endDate") - funding_end: Optional[StrictStr] = None - funding_start: Optional[StrictStr] = None - id: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - keywords_nested: Optional[List[KeywordNested]] = None - link: Optional[StrictStr] = None - objective: Optional[StrictStr] = None - organization_nested: Optional[List[OrganizationNested]] = None - programme_nested: Optional[List[ProgrammeNested]] = None - source: Optional[StrictStr] = None - start_date: Optional[StrictStr] = Field(default=None, alias="startDate") - status: Optional[StrictStr] = None - teaser: Optional[StrictStr] = None - title: Optional[StrictStr] = None - total_cost: Optional[StrictStr] = Field(default=None, alias="totalCost") - __properties: ClassVar[List[str]] = ["acronym", "categories_nested", "doc_number", "doi", "ecMaxContribution", "endDate", "funding_end", "funding_start", "id", "keywords", "keywords_nested", "link", "objective", "organization_nested", "programme_nested", "source", "startDate", "status", "teaser", "title", "totalCost"] + """ + acronym: StrictStr | None = None + categories_nested: list[CategoryNested] | None = None + doc_number: StrictStr | None = None + doi: StrictStr | None = None + ec_max_contribution: StrictStr | None = Field(default=None, alias="ecMaxContribution") + end_date: StrictStr | None = Field(default=None, alias="endDate") + funding_end: StrictStr | None = None + funding_start: StrictStr | None = None + id: StrictStr | None = None + keywords: StrictStr | None = None + keywords_nested: list[KeywordNested] | None = None + link: StrictStr | None = None + objective: StrictStr | None = None + organization_nested: list[OrganizationNested] | None = None + programme_nested: list[ProgrammeNested] | None = None + source: StrictStr | None = None + start_date: StrictStr | None = Field(default=None, alias="startDate") + status: StrictStr | None = None + teaser: StrictStr | None = None + title: StrictStr | None = None + total_cost: StrictStr | None = Field(default=None, alias="totalCost") + __properties: ClassVar[list[str]] = ["acronym", "categories_nested", "doc_number", "doi", "ecMaxContribution", "endDate", "funding_end", "funding_start", "id", "keywords", "keywords_nested", "link", "objective", "organization_nested", "programme_nested", "source", "startDate", "status", "teaser", "title", "totalCost"] model_config = ConfigDict( validate_by_name=True, @@ -71,11 +70,11 @@ class ProjectEu(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ProjectEu from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -85,7 +84,7 @@ class ProjectEu(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -124,7 +123,7 @@ class ProjectEu(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ProjectEu from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_eurosci_voc.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_eurosci_voc.py index 27e2cec2..27f9aad7 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_eurosci_voc.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_eurosci_voc.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Fp7EurosciVoc(BaseModel): """ Fp7EurosciVoc - """ # noqa: E501 - code: Optional[StrictStr] = None - description: Optional[StrictStr] = None - id: Optional[StrictStr] = None - path: Optional[StrictStr] = None - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["code", "description", "id", "path", "projectID", "title"] + """ + code: StrictStr | None = None + description: StrictStr | None = None + id: StrictStr | None = None + path: StrictStr | None = None + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["code", "description", "id", "path", "projectID", "title"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class Fp7EurosciVoc(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7EurosciVoc from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class Fp7EurosciVoc(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class Fp7EurosciVoc(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7EurosciVoc from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_legal_basis.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_legal_basis.py index b4868f44..f98621d2 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_legal_basis.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_legal_basis.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,30 +8,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Fp7LegalBasis(BaseModel): """ Fp7LegalBasis - """ # noqa: E501 - id: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - unique_programme_part: Optional[StrictStr] = Field(default=None, alias="uniqueProgrammePart") - __properties: ClassVar[List[str]] = ["id", "legalBasis", "projectID", "title", "uniqueProgrammePart"] + """ + id: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + unique_programme_part: StrictStr | None = Field(default=None, alias="uniqueProgrammePart") + __properties: ClassVar[list[str]] = ["id", "legalBasis", "projectID", "title", "uniqueProgrammePart"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +50,11 @@ class Fp7LegalBasis(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7LegalBasis from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +64,7 @@ class Fp7LegalBasis(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -76,7 +75,7 @@ class Fp7LegalBasis(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7LegalBasis from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_organization.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_organization.py index 07814631..cebe393b 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_organization.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_organization.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,52 +8,60 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictInt, + StrictStr, +) from pydantic_core import to_jsonable_python + class Fp7Organization(BaseModel): """ Fp7Organization - """ # noqa: E501 - sme: Optional[StrictBool] = Field(default=None, alias="SME") - active: Optional[StrictBool] = None - activity_type: Optional[StrictStr] = Field(default=None, alias="activityType") - city: Optional[StrictStr] = None - contact_form: Optional[StrictStr] = Field(default=None, alias="contactForm") - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - country: Optional[StrictStr] = None - ec_contribution: Optional[StrictFloat] = Field(default=None, alias="ecContribution") - end_of_participation: Optional[StrictBool] = Field(default=None, alias="endOfParticipation") - geolocation: Optional[StrictStr] = None - id: Optional[StrictStr] = None - name: Optional[StrictStr] = None - net_ec_contribution: Optional[StrictFloat] = Field(default=None, alias="netEcContribution") - nuts_code: Optional[StrictStr] = Field(default=None, alias="nutsCode") - order: Optional[StrictInt] = None - organisation_id: Optional[StrictStr] = Field(default=None, alias="organisationID") - organization_url: Optional[StrictStr] = Field(default=None, alias="organizationURL") - post_code: Optional[StrictStr] = Field(default=None, alias="postCode") - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - role: Optional[StrictStr] = None - short_name: Optional[StrictStr] = Field(default=None, alias="shortName") - street: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") - vat_number: Optional[StrictStr] = Field(default=None, alias="vatNumber") - __properties: ClassVar[List[str]] = ["SME", "active", "activityType", "city", "contactForm", "contentUpdateDate", "country", "ecContribution", "endOfParticipation", "geolocation", "id", "name", "netEcContribution", "nutsCode", "order", "organisationID", "organizationURL", "postCode", "projectAcronym", "projectID", "rcn", "role", "shortName", "street", "totalCost", "vatNumber"] + """ + sme: StrictBool | None = Field(default=None, alias="SME") + active: StrictBool | None = None + activity_type: StrictStr | None = Field(default=None, alias="activityType") + city: StrictStr | None = None + contact_form: StrictStr | None = Field(default=None, alias="contactForm") + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + country: StrictStr | None = None + ec_contribution: StrictFloat | None = Field(default=None, alias="ecContribution") + end_of_participation: StrictBool | None = Field(default=None, alias="endOfParticipation") + geolocation: StrictStr | None = None + id: StrictStr | None = None + name: StrictStr | None = None + net_ec_contribution: StrictFloat | None = Field(default=None, alias="netEcContribution") + nuts_code: StrictStr | None = Field(default=None, alias="nutsCode") + order: StrictInt | None = None + organisation_id: StrictStr | None = Field(default=None, alias="organisationID") + organization_url: StrictStr | None = Field(default=None, alias="organizationURL") + post_code: StrictStr | None = Field(default=None, alias="postCode") + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + role: StrictStr | None = None + short_name: StrictStr | None = Field(default=None, alias="shortName") + street: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") + vat_number: StrictStr | None = Field(default=None, alias="vatNumber") + __properties: ClassVar[list[str]] = ["SME", "active", "activityType", "city", "contactForm", "contentUpdateDate", "country", "ecContribution", "endOfParticipation", "geolocation", "id", "name", "netEcContribution", "nutsCode", "order", "organisationID", "organizationURL", "postCode", "projectAcronym", "projectID", "rcn", "role", "shortName", "street", "totalCost", "vatNumber"] model_config = ConfigDict( validate_by_name=True, @@ -73,11 +80,11 @@ class Fp7Organization(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7Organization from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -87,7 +94,7 @@ class Fp7Organization(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -98,7 +105,7 @@ class Fp7Organization(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7Organization from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project.py index ca53bf13..6d468ce8 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,48 +8,55 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictStr, +) from pydantic_core import to_jsonable_python + class Fp7Project(BaseModel): """ Fp7Project - """ # noqa: E501 - acronym: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - ec_max_contribution: Optional[StrictFloat] = Field(default=None, alias="ecMaxContribution") - ec_signature_date: Optional[date] = Field(default=None, alias="ecSignatureDate") - end_date: Optional[date] = Field(default=None, alias="endDate") - framework_programme: Optional[StrictStr] = Field(default=None, alias="frameworkProgramme") - funding_scheme: Optional[StrictStr] = Field(default=None, alias="fundingScheme") - grant_doi: Optional[StrictStr] = Field(default=None, alias="grantDoi") - human_validated: Optional[StrictBool] = Field(default=None, alias="humanValidated") - id: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - master_call: Optional[StrictStr] = Field(default=None, alias="masterCall") - nature: Optional[StrictStr] = None - objective: Optional[StrictStr] = None - rcn: Optional[StrictStr] = None - start_date: Optional[date] = Field(default=None, alias="startDate") - status: Optional[StrictStr] = None - sub_call: Optional[StrictStr] = Field(default=None, alias="subCall") - title: Optional[StrictStr] = None - topics: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") - __properties: ClassVar[List[str]] = ["acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", "nature", "objective", "rcn", "startDate", "status", "subCall", "title", "topics", "totalCost"] + """ + acronym: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + ec_max_contribution: StrictFloat | None = Field(default=None, alias="ecMaxContribution") + ec_signature_date: date | None = Field(default=None, alias="ecSignatureDate") + end_date: date | None = Field(default=None, alias="endDate") + framework_programme: StrictStr | None = Field(default=None, alias="frameworkProgramme") + funding_scheme: StrictStr | None = Field(default=None, alias="fundingScheme") + grant_doi: StrictStr | None = Field(default=None, alias="grantDoi") + human_validated: StrictBool | None = Field(default=None, alias="humanValidated") + id: StrictStr | None = None + keywords: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + master_call: StrictStr | None = Field(default=None, alias="masterCall") + nature: StrictStr | None = None + objective: StrictStr | None = None + rcn: StrictStr | None = None + start_date: date | None = Field(default=None, alias="startDate") + status: StrictStr | None = None + sub_call: StrictStr | None = Field(default=None, alias="subCall") + title: StrictStr | None = None + topics: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") + __properties: ClassVar[list[str]] = ["acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", "nature", "objective", "rcn", "startDate", "status", "subCall", "title", "topics", "totalCost"] model_config = ConfigDict( validate_by_name=True, @@ -69,11 +75,11 @@ class Fp7Project(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7Project from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -83,7 +89,7 @@ class Fp7Project(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -94,7 +100,7 @@ class Fp7Project(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7Project from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_details.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_details.py index fd6ba6d0..82d4a060 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_details.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_details.py @@ -1,32 +1,39 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API - Extended Models -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from typing import Any, ClassVar, Self + +from inse.authors.v2.model import AuthorPage +from inse.models.openalex.topic import Topic +from inse.models.projects_eu_cordis.fp7.fp7_eurosci_voc import Fp7EurosciVoc +from inse.models.projects_eu_cordis.fp7.fp7_legal_basis import Fp7LegalBasis +from inse.models.projects_eu_cordis.fp7.fp7_organization import Fp7Organization # Import all the base models from inse.models.projects_eu_cordis.fp7.fp7_project import Fp7Project -from inse.models.projects_eu_cordis.fp7.fp7_organization import Fp7Organization -from inse.models.projects_eu_cordis.fp7.fp7_publication import Fp7Publication from inse.models.projects_eu_cordis.fp7.fp7_project_ipr import Fp7ProjectIPR +from inse.models.projects_eu_cordis.fp7.fp7_publication import Fp7Publication from inse.models.projects_eu_cordis.fp7.fp7_report_summary import Fp7ReportSummary from inse.models.projects_eu_cordis.fp7.fp7_topic import Fp7Topic from inse.models.projects_eu_cordis.fp7.fp7_web_link import Fp7WebLink -from inse.models.projects_eu_cordis.fp7.fp7_eurosci_voc import Fp7EurosciVoc -from inse.models.projects_eu_cordis.fp7.fp7_legal_basis import Fp7LegalBasis -from inse.authors.v2.model import AuthorPage -from inse.models.openalex.topic import Topic +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictStr, +) +from pydantic_core import to_jsonable_python + class Fp7ProjectDetails(BaseModel): """ @@ -34,48 +41,48 @@ class Fp7ProjectDetails(BaseModel): This model extends the base Fp7Project with all associated data. """ # Project core information (flattened from Fp7Project) - acronym: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - ec_max_contribution: Optional[StrictFloat] = Field(default=None, alias="ecMaxContribution") - ec_signature_date: Optional[date] = Field(default=None, alias="ecSignatureDate") - end_date: Optional[date] = Field(default=None, alias="endDate") - framework_programme: Optional[StrictStr] = Field(default=None, alias="frameworkProgramme") - funding_scheme: Optional[StrictStr] = Field(default=None, alias="fundingScheme") - grant_doi: Optional[StrictStr] = Field(default=None, alias="grantDoi") - human_validated: Optional[StrictBool] = Field(default=None, alias="humanValidated") - id: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - master_call: Optional[StrictStr] = Field(default=None, alias="masterCall") - nature: Optional[StrictStr] = None - objective: Optional[StrictStr] = None - rcn: Optional[StrictStr] = None - start_date: Optional[date] = Field(default=None, alias="startDate") - status: Optional[StrictStr] = None - sub_call: Optional[StrictStr] = Field(default=None, alias="subCall") - title: Optional[StrictStr] = None - topics: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") + acronym: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + ec_max_contribution: StrictFloat | None = Field(default=None, alias="ecMaxContribution") + ec_signature_date: date | None = Field(default=None, alias="ecSignatureDate") + end_date: date | None = Field(default=None, alias="endDate") + framework_programme: StrictStr | None = Field(default=None, alias="frameworkProgramme") + funding_scheme: StrictStr | None = Field(default=None, alias="fundingScheme") + grant_doi: StrictStr | None = Field(default=None, alias="grantDoi") + human_validated: StrictBool | None = Field(default=None, alias="humanValidated") + id: StrictStr | None = None + keywords: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + master_call: StrictStr | None = Field(default=None, alias="masterCall") + nature: StrictStr | None = None + objective: StrictStr | None = None + rcn: StrictStr | None = None + start_date: date | None = Field(default=None, alias="startDate") + status: StrictStr | None = None + sub_call: StrictStr | None = Field(default=None, alias="subCall") + title: StrictStr | None = None + topics: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") # Related entities (collections) - organizations: Optional[List[Fp7Organization]] = Field(default=None, description="Organizations participating in the project") - publications: Optional[List[Fp7Publication]] = Field(default=None, description="Publications related to the project") - iprs: Optional[List[Fp7ProjectIPR]] = Field(default=None, description="Intellectual Property Rights related to the project") - report_summaries: Optional[List[Fp7ReportSummary]] = Field(default=None, description="Report summaries for the project") - topics_list: Optional[List[Fp7Topic]] = Field(default=None, alias="topicsList", description="Topics associated with the project") - web_links: Optional[List[Fp7WebLink]] = Field(default=None, description="Web links related to the project") - eurosci_voc: Optional[List[Fp7EurosciVoc]] = Field(default=None, alias="eurosciVoc", description="EuroSciVoc classifications") - legal_basis_list: Optional[List[Fp7LegalBasis]] = Field(default=None, alias="legalBasisList", description="Legal basis information") + organizations: list[Fp7Organization] | None = Field(default=None, description="Organizations participating in the project") + publications: list[Fp7Publication] | None = Field(default=None, description="Publications related to the project") + iprs: list[Fp7ProjectIPR] | None = Field(default=None, description="Intellectual Property Rights related to the project") + report_summaries: list[Fp7ReportSummary] | None = Field(default=None, description="Report summaries for the project") + topics_list: list[Fp7Topic] | None = Field(default=None, alias="topicsList", description="Topics associated with the project") + web_links: list[Fp7WebLink] | None = Field(default=None, description="Web links related to the project") + eurosci_voc: list[Fp7EurosciVoc] | None = Field(default=None, alias="eurosciVoc", description="EuroSciVoc classifications") + legal_basis_list: list[Fp7LegalBasis] | None = Field(default=None, alias="legalBasisList", description="Legal basis information") # Project statistics (aggregated) - organization_count: Optional[int] = Field(default=None, alias="organizationCount") - publication_count: Optional[int] = Field(default=None, alias="publicationCount") - ipr_count: Optional[int] = Field(default=None, alias="iprCount") + organization_count: int | None = Field(default=None, alias="organizationCount") + publication_count: int | None = Field(default=None, alias="publicationCount") + ipr_count: int | None = Field(default=None, alias="iprCount") # OpenAlex related fields - oa_topics: Optional[List[Topic]] = Field(default=None, alias="oaTopics", description="OpenAlex topics associated with the project") - oa_authors: Optional[AuthorPage] = Field(default=None, alias="oaAuthors", description="OpenAlex authors associated with the project") + oa_topics: list[Topic] | None = Field(default=None, alias="oaTopics", description="OpenAlex topics associated with the project") + oa_authors: AuthorPage | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors associated with the project") - __properties: ClassVar[List[str]] = [ + __properties: ClassVar[list[str]] = [ "acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", @@ -103,13 +110,13 @@ class Fp7ProjectDetails(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7ProjectDetailed from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias.""" - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -120,7 +127,7 @@ class Fp7ProjectDetails(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7ProjectDetailed from a dict""" if obj is None: return None @@ -178,16 +185,16 @@ class Fp7ProjectDetails(BaseModel): def from_project_with_relations( cls, project: Fp7Project, - organizations: Optional[List[Fp7Organization]] = None, - publications: Optional[List[Fp7Publication]] = None, - iprs: Optional[List[Fp7ProjectIPR]] = None, - report_summaries: Optional[List[Fp7ReportSummary]] = None, - topics_list: Optional[List[Fp7Topic]] = None, - web_links: Optional[List[Fp7WebLink]] = None, - eurosci_voc: Optional[List[Fp7EurosciVoc]] = None, - legal_basis_list: Optional[List[Fp7LegalBasis]] = None, - oa_topics: Optional[List[Topic]] = None, - oa_authors: Optional[AuthorPage] = None, + organizations: list[Fp7Organization] | None = None, + publications: list[Fp7Publication] | None = None, + iprs: list[Fp7ProjectIPR] | None = None, + report_summaries: list[Fp7ReportSummary] | None = None, + topics_list: list[Fp7Topic] | None = None, + web_links: list[Fp7WebLink] | None = None, + eurosci_voc: list[Fp7EurosciVoc] | None = None, + legal_basis_list: list[Fp7LegalBasis] | None = None, + oa_topics: list[Topic] | None = None, + oa_authors: AuthorPage | None = None, ) -> Self: """ Factory method to create a detailed project from a base project and its relations. diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_ipr.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_ipr.py index cfbdd89b..df4378e7 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_ipr.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_project_ipr.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,45 +8,45 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Fp7ProjectIPR(BaseModel): """ Fp7ProjectIPR - """ # noqa: E501 - applicant_name: Optional[StrictStr] = Field(default=None, alias="applicantName") - application_date: Optional[date] = Field(default=None, alias="applicationDate") - application_identifier: Optional[StrictStr] = Field(default=None, alias="applicationIdentifier") - application_kind: Optional[StrictStr] = Field(default=None, alias="applicationKind") - application_prefix: Optional[StrictStr] = Field(default=None, alias="applicationPrefix") - award_date: Optional[date] = Field(default=None, alias="awardDate") - award_identifier: Optional[StrictStr] = Field(default=None, alias="awardIdentifier") - award_kind: Optional[StrictStr] = Field(default=None, alias="awardKind") - award_prefix: Optional[StrictStr] = Field(default=None, alias="awardPrefix") - epo_app_url: Optional[StrictStr] = Field(default=None, alias="epoAppUrl") - epo_pub_url: Optional[StrictStr] = Field(default=None, alias="epoPubUrl") - id: Optional[StrictStr] = None - organisation_id: Optional[StrictStr] = Field(default=None, alias="organisationID") - patent_family_identifier: Optional[StrictStr] = Field(default=None, alias="patentFamilyIdentifier") - patent_type: Optional[StrictStr] = Field(default=None, alias="patentType") - priority_date: Optional[date] = Field(default=None, alias="priorityDate") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - type: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["applicantName", "applicationDate", "applicationIdentifier", "applicationKind", "applicationPrefix", "awardDate", "awardIdentifier", "awardKind", "awardPrefix", "epoAppUrl", "epoPubUrl", "id", "organisationID", "patentFamilyIdentifier", "patentType", "priorityDate", "projectID", "title", "type"] + """ + applicant_name: StrictStr | None = Field(default=None, alias="applicantName") + application_date: date | None = Field(default=None, alias="applicationDate") + application_identifier: StrictStr | None = Field(default=None, alias="applicationIdentifier") + application_kind: StrictStr | None = Field(default=None, alias="applicationKind") + application_prefix: StrictStr | None = Field(default=None, alias="applicationPrefix") + award_date: date | None = Field(default=None, alias="awardDate") + award_identifier: StrictStr | None = Field(default=None, alias="awardIdentifier") + award_kind: StrictStr | None = Field(default=None, alias="awardKind") + award_prefix: StrictStr | None = Field(default=None, alias="awardPrefix") + epo_app_url: StrictStr | None = Field(default=None, alias="epoAppUrl") + epo_pub_url: StrictStr | None = Field(default=None, alias="epoPubUrl") + id: StrictStr | None = None + organisation_id: StrictStr | None = Field(default=None, alias="organisationID") + patent_family_identifier: StrictStr | None = Field(default=None, alias="patentFamilyIdentifier") + patent_type: StrictStr | None = Field(default=None, alias="patentType") + priority_date: date | None = Field(default=None, alias="priorityDate") + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + type: StrictStr | None = None + __properties: ClassVar[list[str]] = ["applicantName", "applicationDate", "applicationIdentifier", "applicationKind", "applicationPrefix", "awardDate", "awardIdentifier", "awardKind", "awardPrefix", "epoAppUrl", "epoPubUrl", "id", "organisationID", "patentFamilyIdentifier", "patentType", "priorityDate", "projectID", "title", "type"] model_config = ConfigDict( validate_by_name=True, @@ -66,11 +65,11 @@ class Fp7ProjectIPR(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7ProjectIPR from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -80,7 +79,7 @@ class Fp7ProjectIPR(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -91,7 +90,7 @@ class Fp7ProjectIPR(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7ProjectIPR from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_publication.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_publication.py index b92f9084..f03765e0 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_publication.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_publication.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,46 +8,47 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from typing import Any, ClassVar, Self + from inse.authors.v2.model import Author +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python + + class Fp7Publication(BaseModel): """ Fp7Publication - """ # noqa: E501 - authors: Optional[StrictStr] = None - oa_authors: Optional[List[Author]] = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") + """ + authors: StrictStr | None = None + oa_authors: list[Author] | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") - collection: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - doi: Optional[StrictStr] = None - id: Optional[StrictStr] = None - is_published_as: Optional[StrictStr] = Field(default=None, alias="isPublishedAs") - journal_number: Optional[StrictStr] = Field(default=None, alias="journalNumber") - journal_title: Optional[StrictStr] = Field(default=None, alias="journalTitle") - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - published_pages: Optional[StrictStr] = Field(default=None, alias="publishedPages") - published_year: Optional[StrictInt] = Field(default=None, alias="publishedYear") - publisher: Optional[StrictStr] = None - qa_processed_doi: Optional[StrictStr] = Field(default=None, alias="qaProcessedDoi") - rcn: Optional[StrictStr] = None - repository_url: Optional[StrictStr] = Field(default=None, alias="repositoryUrl") - title: Optional[StrictStr] = None - volume: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["authors", "collection", "contentUpdateDate", "doi", "id", "isPublishedAs", "journalNumber", "journalTitle", "projectAcronym", "projectID", "publishedPages", "publishedYear", "publisher", "qaProcessedDoi", "rcn", "repositoryUrl", "title", "volume", "oaAuthors"] + collection: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + doi: StrictStr | None = None + id: StrictStr | None = None + is_published_as: StrictStr | None = Field(default=None, alias="isPublishedAs") + journal_number: StrictStr | None = Field(default=None, alias="journalNumber") + journal_title: StrictStr | None = Field(default=None, alias="journalTitle") + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + published_pages: StrictStr | None = Field(default=None, alias="publishedPages") + published_year: StrictInt | None = Field(default=None, alias="publishedYear") + publisher: StrictStr | None = None + qa_processed_doi: StrictStr | None = Field(default=None, alias="qaProcessedDoi") + rcn: StrictStr | None = None + repository_url: StrictStr | None = Field(default=None, alias="repositoryUrl") + title: StrictStr | None = None + volume: StrictStr | None = None + __properties: ClassVar[list[str]] = ["authors", "collection", "contentUpdateDate", "doi", "id", "isPublishedAs", "journalNumber", "journalTitle", "projectAcronym", "projectID", "publishedPages", "publishedYear", "publisher", "qaProcessedDoi", "rcn", "repositoryUrl", "title", "volume", "oaAuthors"] model_config = ConfigDict( validate_by_name=True, @@ -67,11 +67,11 @@ class Fp7Publication(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7Publication from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -81,7 +81,7 @@ class Fp7Publication(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -92,7 +92,7 @@ class Fp7Publication(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7Publication from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_report_summary.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_report_summary.py index 43ce8910..cbe1ac59 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_report_summary.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_report_summary.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,33 +8,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Fp7ReportSummary(BaseModel): """ Fp7ReportSummary - """ # noqa: E501 - attachments: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - id: Optional[StrictStr] = None - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["attachments", "contentUpdateDate", "id", "projectAcronym", "projectID", "rcn", "title"] + """ + attachments: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + id: StrictStr | None = None + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["attachments", "contentUpdateDate", "id", "projectAcronym", "projectID", "rcn", "title"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class Fp7ReportSummary(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7ReportSummary from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class Fp7ReportSummary(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class Fp7ReportSummary(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7ReportSummary from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_topic.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_topic.py index 27a59a47..7a404f24 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_topic.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_topic.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,29 +8,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Fp7Topic(BaseModel): """ Fp7Topic - """ # noqa: E501 - id: Optional[StrictStr] = None - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - topic: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "projectID", "title", "topic"] + """ + id: StrictStr | None = None + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + topic: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "projectID", "title", "topic"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class Fp7Topic(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7Topic from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class Fp7Topic(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class Fp7Topic(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7Topic from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_web_link.py b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_web_link.py index 6898b07f..429feb39 100644 --- a/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_web_link.py +++ b/service/src/main/inse/models/projects_eu_cordis/fp7/fp7_web_link.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS FP7 Multi-Index API @@ -9,36 +8,36 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class Fp7WebLink(BaseModel): """ Fp7WebLink - """ # noqa: E501 - archived_date: Optional[datetime] = Field(default=None, alias="archivedDate") - available_languages: Optional[StrictStr] = Field(default=None, alias="availableLanguages") - id: Optional[StrictStr] = None - link_id: Optional[StrictStr] = Field(default=None, alias="linkId") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - represents: Optional[StrictStr] = None - source: Optional[StrictStr] = None - status: Optional[StrictStr] = None - type: Optional[StrictStr] = None - url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["archivedDate", "availableLanguages", "id", "linkId", "projectID", "represents", "source", "status", "type", "url"] + """ + archived_date: datetime | None = Field(default=None, alias="archivedDate") + available_languages: StrictStr | None = Field(default=None, alias="availableLanguages") + id: StrictStr | None = None + link_id: StrictStr | None = Field(default=None, alias="linkId") + project_id: StrictStr | None = Field(default=None, alias="projectID") + represents: StrictStr | None = None + source: StrictStr | None = None + status: StrictStr | None = None + type: StrictStr | None = None + url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["archivedDate", "availableLanguages", "id", "linkId", "projectID", "represents", "source", "status", "type", "url"] model_config = ConfigDict( validate_by_name=True, @@ -57,11 +56,11 @@ class Fp7WebLink(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of Fp7WebLink from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -71,7 +70,7 @@ class Fp7WebLink(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -82,7 +81,7 @@ class Fp7WebLink(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of Fp7WebLink from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_deliverable.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_deliverable.py index 29166ca3..678d4fba 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_deliverable.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_deliverable.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,34 +8,34 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class H2020Deliverable(BaseModel): """ H2020Deliverable - """ # noqa: E501 - collection: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - deliverable_type: Optional[StrictStr] = Field(default=None, alias="deliverableType") - description: Optional[StrictStr] = None - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["collection", "contentUpdateDate", "deliverableType", "description", "projectAcronym", "projectID", "rcn", "url"] + """ + collection: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + deliverable_type: StrictStr | None = Field(default=None, alias="deliverableType") + description: StrictStr | None = None + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["collection", "contentUpdateDate", "deliverableType", "description", "projectAcronym", "projectID", "rcn", "url"] model_config = ConfigDict( validate_by_name=True, @@ -55,11 +54,11 @@ class H2020Deliverable(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020Deliverable from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -69,7 +68,7 @@ class H2020Deliverable(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -80,7 +79,7 @@ class H2020Deliverable(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020Deliverable from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_erc_pi.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_erc_pi.py index b16ed4d0..23324516 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_erc_pi.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_erc_pi.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,33 +8,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class H2020ErcPI(BaseModel): """ H2020ErcPI - """ # noqa: E501 - first_name: Optional[StrictStr] = Field(default=None, alias="firstName") - funding_scheme: Optional[StrictStr] = Field(default=None, alias="fundingScheme") - id: Optional[StrictStr] = None - last_name: Optional[StrictStr] = Field(default=None, alias="lastName") - organisation_id: Optional[StrictStr] = Field(default=None, alias="organisationID") - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["firstName", "fundingScheme", "id", "lastName", "organisationID", "projectAcronym", "projectID", "title"] + """ + first_name: StrictStr | None = Field(default=None, alias="firstName") + funding_scheme: StrictStr | None = Field(default=None, alias="fundingScheme") + id: StrictStr | None = None + last_name: StrictStr | None = Field(default=None, alias="lastName") + organisation_id: StrictStr | None = Field(default=None, alias="organisationID") + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["firstName", "fundingScheme", "id", "lastName", "organisationID", "projectAcronym", "projectID", "title"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class H2020ErcPI(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020ErcPI from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class H2020ErcPI(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class H2020ErcPI(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020ErcPI from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_eurosci_voc.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_eurosci_voc.py index f6227b6c..26009d82 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_eurosci_voc.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_eurosci_voc.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class H2020EurosciVoc(BaseModel): """ H2020EurosciVoc - """ # noqa: E501 - code: Optional[StrictStr] = None - description: Optional[StrictStr] = None - id: Optional[StrictStr] = None - path: Optional[StrictStr] = None - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["code", "description", "id", "path", "projectID", "title"] + """ + code: StrictStr | None = None + description: StrictStr | None = None + id: StrictStr | None = None + path: StrictStr | None = None + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["code", "description", "id", "path", "projectID", "title"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class H2020EurosciVoc(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020EurosciVoc from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class H2020EurosciVoc(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class H2020EurosciVoc(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020EurosciVoc from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_legal_basis.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_legal_basis.py index 43327f68..51f9c3a9 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_legal_basis.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_legal_basis.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,30 +8,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class H2020LegalBasis(BaseModel): """ H2020LegalBasis - """ # noqa: E501 - id: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - unique_programme_part: Optional[StrictStr] = Field(default=None, alias="uniqueProgrammePart") - __properties: ClassVar[List[str]] = ["id", "legalBasis", "projectID", "title", "uniqueProgrammePart"] + """ + id: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + unique_programme_part: StrictStr | None = Field(default=None, alias="uniqueProgrammePart") + __properties: ClassVar[list[str]] = ["id", "legalBasis", "projectID", "title", "uniqueProgrammePart"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +50,11 @@ class H2020LegalBasis(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020LegalBasis from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +64,7 @@ class H2020LegalBasis(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -76,7 +75,7 @@ class H2020LegalBasis(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020LegalBasis from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_organization.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_organization.py index ed63c1a0..3f111097 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_organization.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_organization.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,52 +8,60 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictInt, + StrictStr, +) from pydantic_core import to_jsonable_python + class H2020Organization(BaseModel): """ H2020Organization - """ # noqa: E501 - sme: Optional[StrictBool] = Field(default=None, alias="SME") - active: Optional[StrictBool] = None - activity_type: Optional[StrictStr] = Field(default=None, alias="activityType") - city: Optional[StrictStr] = None - contact_form: Optional[StrictStr] = Field(default=None, alias="contactForm") - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - country: Optional[StrictStr] = None - ec_contribution: Optional[StrictFloat] = Field(default=None, alias="ecContribution") - end_of_participation: Optional[StrictBool] = Field(default=None, alias="endOfParticipation") - geolocation: Optional[StrictStr] = None - id: Optional[StrictStr] = None - name: Optional[StrictStr] = None - net_ec_contribution: Optional[StrictFloat] = Field(default=None, alias="netEcContribution") - nuts_code: Optional[StrictStr] = Field(default=None, alias="nutsCode") - order: Optional[StrictInt] = None - organisation_id: Optional[StrictStr] = Field(default=None, alias="organisationID") - organization_url: Optional[StrictStr] = Field(default=None, alias="organizationURL") - post_code: Optional[StrictStr] = Field(default=None, alias="postCode") - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - role: Optional[StrictStr] = None - short_name: Optional[StrictStr] = Field(default=None, alias="shortName") - street: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") - vat_number: Optional[StrictStr] = Field(default=None, alias="vatNumber") - __properties: ClassVar[List[str]] = ["SME", "active", "activityType", "city", "contactForm", "contentUpdateDate", "country", "ecContribution", "endOfParticipation", "geolocation", "id", "name", "netEcContribution", "nutsCode", "order", "organisationID", "organizationURL", "postCode", "projectAcronym", "projectID", "rcn", "role", "shortName", "street", "totalCost", "vatNumber"] + """ + sme: StrictBool | None = Field(default=None, alias="SME") + active: StrictBool | None = None + activity_type: StrictStr | None = Field(default=None, alias="activityType") + city: StrictStr | None = None + contact_form: StrictStr | None = Field(default=None, alias="contactForm") + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + country: StrictStr | None = None + ec_contribution: StrictFloat | None = Field(default=None, alias="ecContribution") + end_of_participation: StrictBool | None = Field(default=None, alias="endOfParticipation") + geolocation: StrictStr | None = None + id: StrictStr | None = None + name: StrictStr | None = None + net_ec_contribution: StrictFloat | None = Field(default=None, alias="netEcContribution") + nuts_code: StrictStr | None = Field(default=None, alias="nutsCode") + order: StrictInt | None = None + organisation_id: StrictStr | None = Field(default=None, alias="organisationID") + organization_url: StrictStr | None = Field(default=None, alias="organizationURL") + post_code: StrictStr | None = Field(default=None, alias="postCode") + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + role: StrictStr | None = None + short_name: StrictStr | None = Field(default=None, alias="shortName") + street: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") + vat_number: StrictStr | None = Field(default=None, alias="vatNumber") + __properties: ClassVar[list[str]] = ["SME", "active", "activityType", "city", "contactForm", "contentUpdateDate", "country", "ecContribution", "endOfParticipation", "geolocation", "id", "name", "netEcContribution", "nutsCode", "order", "organisationID", "organizationURL", "postCode", "projectAcronym", "projectID", "rcn", "role", "shortName", "street", "totalCost", "vatNumber"] model_config = ConfigDict( validate_by_name=True, @@ -73,11 +80,11 @@ class H2020Organization(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020Organization from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -87,7 +94,7 @@ class H2020Organization(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -98,7 +105,7 @@ class H2020Organization(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020Organization from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project.py index c12b16ec..824d2e42 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,48 +8,55 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictStr, +) from pydantic_core import to_jsonable_python + class H2020Project(BaseModel): """ H2020Project - """ # noqa: E501 - acronym: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - ec_max_contribution: Optional[StrictFloat] = Field(default=None, alias="ecMaxContribution") - ec_signature_date: Optional[date] = Field(default=None, alias="ecSignatureDate") - end_date: Optional[date] = Field(default=None, alias="endDate") - framework_programme: Optional[StrictStr] = Field(default=None, alias="frameworkProgramme") - funding_scheme: Optional[StrictStr] = Field(default=None, alias="fundingScheme") - grant_doi: Optional[StrictStr] = Field(default=None, alias="grantDoi") - human_validated: Optional[StrictBool] = Field(default=None, alias="humanValidated") - id: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - master_call: Optional[StrictStr] = Field(default=None, alias="masterCall") - nature: Optional[StrictStr] = None - objective: Optional[StrictStr] = None - rcn: Optional[StrictStr] = None - start_date: Optional[date] = Field(default=None, alias="startDate") - status: Optional[StrictStr] = None - sub_call: Optional[StrictStr] = Field(default=None, alias="subCall") - title: Optional[StrictStr] = None - topics: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") - __properties: ClassVar[List[str]] = ["acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", "nature", "objective", "rcn", "startDate", "status", "subCall", "title", "topics", "totalCost"] + """ + acronym: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + ec_max_contribution: StrictFloat | None = Field(default=None, alias="ecMaxContribution") + ec_signature_date: date | None = Field(default=None, alias="ecSignatureDate") + end_date: date | None = Field(default=None, alias="endDate") + framework_programme: StrictStr | None = Field(default=None, alias="frameworkProgramme") + funding_scheme: StrictStr | None = Field(default=None, alias="fundingScheme") + grant_doi: StrictStr | None = Field(default=None, alias="grantDoi") + human_validated: StrictBool | None = Field(default=None, alias="humanValidated") + id: StrictStr | None = None + keywords: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + master_call: StrictStr | None = Field(default=None, alias="masterCall") + nature: StrictStr | None = None + objective: StrictStr | None = None + rcn: StrictStr | None = None + start_date: date | None = Field(default=None, alias="startDate") + status: StrictStr | None = None + sub_call: StrictStr | None = Field(default=None, alias="subCall") + title: StrictStr | None = None + topics: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") + __properties: ClassVar[list[str]] = ["acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", "nature", "objective", "rcn", "startDate", "status", "subCall", "title", "topics", "totalCost"] model_config = ConfigDict( validate_by_name=True, @@ -69,11 +75,11 @@ class H2020Project(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020Project from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -83,7 +89,7 @@ class H2020Project(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -94,7 +100,7 @@ class H2020Project(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020Project from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project_details.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project_details.py index 4cd7e3c4..9c41747d 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project_details.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_project_details.py @@ -1,33 +1,48 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API - Extended Models -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from typing import Any, ClassVar, Self + +from inse.authors.v2.model import AuthorPage +from inse.models.openalex.topic import Topic +from inse.models.projects_eu_cordis.horizon2020.h2020_deliverable import ( + H2020Deliverable, +) +from inse.models.projects_eu_cordis.horizon2020.h2020_erc_pi import H2020ErcPI +from inse.models.projects_eu_cordis.horizon2020.h2020_eurosci_voc import H2020EurosciVoc +from inse.models.projects_eu_cordis.horizon2020.h2020_legal_basis import H2020LegalBasis +from inse.models.projects_eu_cordis.horizon2020.h2020_organization import ( + H2020Organization, +) # Import all the base models from inse.models.projects_eu_cordis.horizon2020.h2020_project import H2020Project -from inse.models.projects_eu_cordis.horizon2020.h2020_organization import H2020Organization -from inse.models.projects_eu_cordis.horizon2020.h2020_publication import H2020Publication -from inse.models.projects_eu_cordis.horizon2020.h2020_deliverable import H2020Deliverable -from inse.models.projects_eu_cordis.horizon2020.h2020_report_summary import H2020ReportSummary +from inse.models.projects_eu_cordis.horizon2020.h2020_publication import ( + H2020Publication, +) +from inse.models.projects_eu_cordis.horizon2020.h2020_report_summary import ( + H2020ReportSummary, +) from inse.models.projects_eu_cordis.horizon2020.h2020_topic import H2020Topic from inse.models.projects_eu_cordis.horizon2020.h2020_web_link import H2020WebLink -from inse.models.projects_eu_cordis.horizon2020.h2020_eurosci_voc import H2020EurosciVoc -from inse.models.projects_eu_cordis.horizon2020.h2020_legal_basis import H2020LegalBasis -from inse.models.projects_eu_cordis.horizon2020.h2020_erc_pi import H2020ErcPI -from inse.authors.v2.model import AuthorPage -from inse.models.openalex.topic import Topic +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictStr, +) +from pydantic_core import to_jsonable_python + class H2020ProjectDetails(BaseModel): """ @@ -35,50 +50,50 @@ class H2020ProjectDetails(BaseModel): This model extends the base H2020Project with all associated data. """ # Project core information (flattened from H2020Project) - acronym: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - ec_max_contribution: Optional[StrictFloat] = Field(default=None, alias="ecMaxContribution") - ec_signature_date: Optional[date] = Field(default=None, alias="ecSignatureDate") - end_date: Optional[date] = Field(default=None, alias="endDate") - framework_programme: Optional[StrictStr] = Field(default=None, alias="frameworkProgramme") - funding_scheme: Optional[StrictStr] = Field(default=None, alias="fundingScheme") - grant_doi: Optional[StrictStr] = Field(default=None, alias="grantDoi") - human_validated: Optional[StrictBool] = Field(default=None, alias="humanValidated") - id: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - master_call: Optional[StrictStr] = Field(default=None, alias="masterCall") - nature: Optional[StrictStr] = None - objective: Optional[StrictStr] = None - rcn: Optional[StrictStr] = None - start_date: Optional[date] = Field(default=None, alias="startDate") - status: Optional[StrictStr] = None - sub_call: Optional[StrictStr] = Field(default=None, alias="subCall") - title: Optional[StrictStr] = None - topics: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") + acronym: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + ec_max_contribution: StrictFloat | None = Field(default=None, alias="ecMaxContribution") + ec_signature_date: date | None = Field(default=None, alias="ecSignatureDate") + end_date: date | None = Field(default=None, alias="endDate") + framework_programme: StrictStr | None = Field(default=None, alias="frameworkProgramme") + funding_scheme: StrictStr | None = Field(default=None, alias="fundingScheme") + grant_doi: StrictStr | None = Field(default=None, alias="grantDoi") + human_validated: StrictBool | None = Field(default=None, alias="humanValidated") + id: StrictStr | None = None + keywords: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + master_call: StrictStr | None = Field(default=None, alias="masterCall") + nature: StrictStr | None = None + objective: StrictStr | None = None + rcn: StrictStr | None = None + start_date: date | None = Field(default=None, alias="startDate") + status: StrictStr | None = None + sub_call: StrictStr | None = Field(default=None, alias="subCall") + title: StrictStr | None = None + topics: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") # Related entities (collections) - organizations: Optional[List[H2020Organization]] = Field(default=None, description="Organizations participating in the project") - publications: Optional[List[H2020Publication]] = Field(default=None, description="Publications related to the project") - deliverables: Optional[List[H2020Deliverable]] = Field(default=None, description="Deliverables of the project") - report_summaries: Optional[List[H2020ReportSummary]] = Field(default=None, alias="reportSummaries", description="Report summaries for the project") - topics_list: Optional[List[H2020Topic]] = Field(default=None, alias="topicsList", description="Topics associated with the project") - web_links: Optional[List[H2020WebLink]] = Field(default=None, alias="webLinks", description="Web links related to the project") - eurosci_voc: Optional[List[H2020EurosciVoc]] = Field(default=None, alias="eurosciVoc", description="EuroSciVoc classifications") - legal_basis_list: Optional[List[H2020LegalBasis]] = Field(default=None, alias="legalBasisList", description="Legal basis information") - erc_principal_investigators: Optional[List[H2020ErcPI]] = Field(default=None, alias="ercPrincipalInvestigators", description="ERC Principal Investigators (specific to H2020)") + organizations: list[H2020Organization] | None = Field(default=None, description="Organizations participating in the project") + publications: list[H2020Publication] | None = Field(default=None, description="Publications related to the project") + deliverables: list[H2020Deliverable] | None = Field(default=None, description="Deliverables of the project") + report_summaries: list[H2020ReportSummary] | None = Field(default=None, alias="reportSummaries", description="Report summaries for the project") + topics_list: list[H2020Topic] | None = Field(default=None, alias="topicsList", description="Topics associated with the project") + web_links: list[H2020WebLink] | None = Field(default=None, alias="webLinks", description="Web links related to the project") + eurosci_voc: list[H2020EurosciVoc] | None = Field(default=None, alias="eurosciVoc", description="EuroSciVoc classifications") + legal_basis_list: list[H2020LegalBasis] | None = Field(default=None, alias="legalBasisList", description="Legal basis information") + erc_principal_investigators: list[H2020ErcPI] | None = Field(default=None, alias="ercPrincipalInvestigators", description="ERC Principal Investigators (specific to H2020)") # Project statistics (aggregated) - organization_count: Optional[int] = Field(default=None, alias="organizationCount") - publication_count: Optional[int] = Field(default=None, alias="publicationCount") - deliverable_count: Optional[int] = Field(default=None, alias="deliverableCount") - erc_pi_count: Optional[int] = Field(default=None, alias="ercPiCount") + organization_count: int | None = Field(default=None, alias="organizationCount") + publication_count: int | None = Field(default=None, alias="publicationCount") + deliverable_count: int | None = Field(default=None, alias="deliverableCount") + erc_pi_count: int | None = Field(default=None, alias="ercPiCount") # OpenAlex related fields - oa_topics: Optional[List[Topic]] = Field(default=None, alias="oaTopics", description="OpenAlex topics associated with the project") - oa_authors: Optional[AuthorPage] = Field(default=None, alias="oaAuthors", description="OpenAlex authors associated with the project") + oa_topics: list[Topic] | None = Field(default=None, alias="oaTopics", description="OpenAlex topics associated with the project") + oa_authors: AuthorPage | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors associated with the project") - __properties: ClassVar[List[str]] = [ + __properties: ClassVar[list[str]] = [ "acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", @@ -108,13 +123,13 @@ class H2020ProjectDetails(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020ProjectDetailed from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias.""" - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -125,7 +140,7 @@ class H2020ProjectDetails(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020ProjectDetailed from a dict""" if obj is None: return None @@ -181,17 +196,17 @@ class H2020ProjectDetails(BaseModel): def from_project_with_relations( cls, project: H2020Project, - organizations: Optional[List[H2020Organization]] = None, - publications: Optional[List[H2020Publication]] = None, - deliverables: Optional[List[H2020Deliverable]] = None, - report_summaries: Optional[List[H2020ReportSummary]] = None, - topics_list: Optional[List[H2020Topic]] = None, - web_links: Optional[List[H2020WebLink]] = None, - eurosci_voc: Optional[List[H2020EurosciVoc]] = None, - legal_basis_list: Optional[List[H2020LegalBasis]] = None, - erc_principal_investigators: Optional[List[H2020ErcPI]] = None, - oa_topics: Optional[List[Topic]] = None, - oa_authors: Optional[AuthorPage] = None, + organizations: list[H2020Organization] | None = None, + publications: list[H2020Publication] | None = None, + deliverables: list[H2020Deliverable] | None = None, + report_summaries: list[H2020ReportSummary] | None = None, + topics_list: list[H2020Topic] | None = None, + web_links: list[H2020WebLink] | None = None, + eurosci_voc: list[H2020EurosciVoc] | None = None, + legal_basis_list: list[H2020LegalBasis] | None = None, + erc_principal_investigators: list[H2020ErcPI] | None = None, + oa_topics: list[Topic] | None = None, + oa_authors: AuthorPage | None = None, ) -> Self: """ Factory method to create a detailed project from a base project and its relations. diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_publication.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_publication.py index a9443e4c..cd4d5389 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_publication.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_publication.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,46 +8,47 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from typing import Any, ClassVar, Self + from inse.authors.v2.model import Author +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python + + class H2020Publication(BaseModel): """ H2020Publication - """ # noqa: E501 - authors: Optional[StrictStr] = None - oa_authors: Optional[List[Author]] = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") - collection: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - doi: Optional[StrictStr] = None - id: Optional[StrictStr] = None - is_published_as: Optional[StrictStr] = Field(default=None, alias="isPublishedAs") - journal_number: Optional[StrictStr] = Field(default=None, alias="journalNumber") - journal_title: Optional[StrictStr] = Field(default=None, alias="journalTitle") - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - published_pages: Optional[StrictStr] = Field(default=None, alias="publishedPages") - published_year: Optional[StrictInt] = Field(default=None, alias="publishedYear") - publisher: Optional[StrictStr] = None - qa_processed_doi: Optional[StrictStr] = Field(default=None, alias="qaProcessedDoi") - rcn: Optional[StrictStr] = None - repository_url: Optional[StrictStr] = Field(default=None, alias="repositoryUrl") - title: Optional[StrictStr] = None - volume: Optional[StrictStr] = None - oa_authors: Optional[List[Author]] = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") - __properties: ClassVar[List[str]] = ["authors", "collection", "contentUpdateDate", "doi", "id", "isPublishedAs", "journalNumber", "journalTitle", "projectAcronym", "projectID", "publishedPages", "publishedYear", "publisher", "qaProcessedDoi", "rcn", "repositoryUrl", "title", "volume", "oaAuthors"] + """ + authors: StrictStr | None = None + oa_authors: list[Author] | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") + collection: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + doi: StrictStr | None = None + id: StrictStr | None = None + is_published_as: StrictStr | None = Field(default=None, alias="isPublishedAs") + journal_number: StrictStr | None = Field(default=None, alias="journalNumber") + journal_title: StrictStr | None = Field(default=None, alias="journalTitle") + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + published_pages: StrictStr | None = Field(default=None, alias="publishedPages") + published_year: StrictInt | None = Field(default=None, alias="publishedYear") + publisher: StrictStr | None = None + qa_processed_doi: StrictStr | None = Field(default=None, alias="qaProcessedDoi") + rcn: StrictStr | None = None + repository_url: StrictStr | None = Field(default=None, alias="repositoryUrl") + title: StrictStr | None = None + volume: StrictStr | None = None + oa_authors: list[Author] | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") + __properties: ClassVar[list[str]] = ["authors", "collection", "contentUpdateDate", "doi", "id", "isPublishedAs", "journalNumber", "journalTitle", "projectAcronym", "projectID", "publishedPages", "publishedYear", "publisher", "qaProcessedDoi", "rcn", "repositoryUrl", "title", "volume", "oaAuthors"] model_config = ConfigDict( validate_by_name=True, @@ -67,11 +67,11 @@ class H2020Publication(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020Publication from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -81,7 +81,7 @@ class H2020Publication(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -92,7 +92,7 @@ class H2020Publication(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020Publication from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_report_summary.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_report_summary.py index e1f7e49f..c33dbb38 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_report_summary.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_report_summary.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,33 +8,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class H2020ReportSummary(BaseModel): """ H2020ReportSummary - """ # noqa: E501 - attachments: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - id: Optional[StrictStr] = None - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["attachments", "contentUpdateDate", "id", "projectAcronym", "projectID", "rcn", "title"] + """ + attachments: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + id: StrictStr | None = None + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["attachments", "contentUpdateDate", "id", "projectAcronym", "projectID", "rcn", "title"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class H2020ReportSummary(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020ReportSummary from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class H2020ReportSummary(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class H2020ReportSummary(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020ReportSummary from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_topic.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_topic.py index 0c6bedbb..a4df2dcf 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_topic.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_topic.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,29 +8,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class H2020Topic(BaseModel): """ H2020Topic - """ # noqa: E501 - id: Optional[StrictStr] = None - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - topic: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "projectID", "title", "topic"] + """ + id: StrictStr | None = None + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + topic: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "projectID", "title", "topic"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class H2020Topic(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020Topic from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class H2020Topic(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class H2020Topic(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020Topic from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_web_link.py b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_web_link.py index a8e45638..0ff51ed7 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_web_link.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon2020/h2020_web_link.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon 2020 Multi-Index API @@ -9,36 +8,36 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class H2020WebLink(BaseModel): """ H2020WebLink - """ # noqa: E501 - archived_date: Optional[datetime] = Field(default=None, alias="archivedDate") - available_languages: Optional[StrictStr] = Field(default=None, alias="availableLanguages") - id: Optional[StrictStr] = None - link_id: Optional[StrictStr] = Field(default=None, alias="linkId") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - represents: Optional[StrictStr] = None - source: Optional[StrictStr] = None - status: Optional[StrictStr] = None - type: Optional[StrictStr] = None - url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["archivedDate", "availableLanguages", "id", "linkId", "projectID", "represents", "source", "status", "type", "url"] + """ + archived_date: datetime | None = Field(default=None, alias="archivedDate") + available_languages: StrictStr | None = Field(default=None, alias="availableLanguages") + id: StrictStr | None = None + link_id: StrictStr | None = Field(default=None, alias="linkId") + project_id: StrictStr | None = Field(default=None, alias="projectID") + represents: StrictStr | None = None + source: StrictStr | None = None + status: StrictStr | None = None + type: StrictStr | None = None + url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["archivedDate", "availableLanguages", "id", "linkId", "projectID", "represents", "source", "status", "type", "url"] model_config = ConfigDict( validate_by_name=True, @@ -57,11 +56,11 @@ class H2020WebLink(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of H2020WebLink from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -71,7 +70,7 @@ class H2020WebLink(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -82,7 +81,7 @@ class H2020WebLink(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of H2020WebLink from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_deliverable.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_deliverable.py index ba858158..7ff50b04 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_deliverable.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_deliverable.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,34 +8,34 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class HEUDeliverable(BaseModel): """ HEUDeliverable - """ # noqa: E501 - collection: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - deliverable_type: Optional[StrictStr] = Field(default=None, alias="deliverableType") - description: Optional[StrictStr] = None - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["collection", "contentUpdateDate", "deliverableType", "description", "projectAcronym", "projectID", "rcn", "url"] + """ + collection: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + deliverable_type: StrictStr | None = Field(default=None, alias="deliverableType") + description: StrictStr | None = None + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["collection", "contentUpdateDate", "deliverableType", "description", "projectAcronym", "projectID", "rcn", "url"] model_config = ConfigDict( validate_by_name=True, @@ -55,11 +54,11 @@ class HEUDeliverable(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUDeliverable from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -69,7 +68,7 @@ class HEUDeliverable(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -80,7 +79,7 @@ class HEUDeliverable(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUDeliverable from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_eurosci_voc.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_eurosci_voc.py index 586f3777..49ea168c 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_eurosci_voc.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_eurosci_voc.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class HEUEurosciVoc(BaseModel): """ HEUEurosciVoc - """ # noqa: E501 - code: Optional[StrictStr] = None - description: Optional[StrictStr] = None - id: Optional[StrictStr] = None - path: Optional[StrictStr] = None - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["code", "description", "id", "path", "projectID", "title"] + """ + code: StrictStr | None = None + description: StrictStr | None = None + id: StrictStr | None = None + path: StrictStr | None = None + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["code", "description", "id", "path", "projectID", "title"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class HEUEurosciVoc(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUEurosciVoc from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class HEUEurosciVoc(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class HEUEurosciVoc(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUEurosciVoc from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_legal_basis.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_legal_basis.py index 0c4e288e..a2b9fdd7 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_legal_basis.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_legal_basis.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,30 +8,30 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class HEULegalBasis(BaseModel): """ HEULegalBasis - """ # noqa: E501 - id: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - unique_programme_part: Optional[StrictStr] = Field(default=None, alias="uniqueProgrammePart") - __properties: ClassVar[List[str]] = ["id", "legalBasis", "projectID", "title", "uniqueProgrammePart"] + """ + id: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + unique_programme_part: StrictStr | None = Field(default=None, alias="uniqueProgrammePart") + __properties: ClassVar[list[str]] = ["id", "legalBasis", "projectID", "title", "uniqueProgrammePart"] model_config = ConfigDict( validate_by_name=True, @@ -51,11 +50,11 @@ class HEULegalBasis(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEULegalBasis from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -65,7 +64,7 @@ class HEULegalBasis(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -76,7 +75,7 @@ class HEULegalBasis(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEULegalBasis from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_organization.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_organization.py index 069ee71a..0cd27867 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_organization.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_organization.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,52 +8,60 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictInt, + StrictStr, +) from pydantic_core import to_jsonable_python + class HEUOrganization(BaseModel): """ HEUOrganization - """ # noqa: E501 - sme: Optional[StrictBool] = Field(default=None, alias="SME") - active: Optional[StrictBool] = None - activity_type: Optional[StrictStr] = Field(default=None, alias="activityType") - city: Optional[StrictStr] = None - contact_form: Optional[StrictStr] = Field(default=None, alias="contactForm") - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - country: Optional[StrictStr] = None - ec_contribution: Optional[StrictFloat] = Field(default=None, alias="ecContribution") - end_of_participation: Optional[StrictBool] = Field(default=None, alias="endOfParticipation") - geolocation: Optional[StrictStr] = None - id: Optional[StrictStr] = None - name: Optional[StrictStr] = None - net_ec_contribution: Optional[StrictFloat] = Field(default=None, alias="netEcContribution") - nuts_code: Optional[StrictStr] = Field(default=None, alias="nutsCode") - order: Optional[StrictInt] = None - organisation_id: Optional[StrictStr] = Field(default=None, alias="organisationID") - organization_url: Optional[StrictStr] = Field(default=None, alias="organizationURL") - post_code: Optional[StrictStr] = Field(default=None, alias="postCode") - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - role: Optional[StrictStr] = None - short_name: Optional[StrictStr] = Field(default=None, alias="shortName") - street: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") - vat_number: Optional[StrictStr] = Field(default=None, alias="vatNumber") - __properties: ClassVar[List[str]] = ["SME", "active", "activityType", "city", "contactForm", "contentUpdateDate", "country", "ecContribution", "endOfParticipation", "geolocation", "id", "name", "netEcContribution", "nutsCode", "order", "organisationID", "organizationURL", "postCode", "projectAcronym", "projectID", "rcn", "role", "shortName", "street", "totalCost", "vatNumber"] + """ + sme: StrictBool | None = Field(default=None, alias="SME") + active: StrictBool | None = None + activity_type: StrictStr | None = Field(default=None, alias="activityType") + city: StrictStr | None = None + contact_form: StrictStr | None = Field(default=None, alias="contactForm") + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + country: StrictStr | None = None + ec_contribution: StrictFloat | None = Field(default=None, alias="ecContribution") + end_of_participation: StrictBool | None = Field(default=None, alias="endOfParticipation") + geolocation: StrictStr | None = None + id: StrictStr | None = None + name: StrictStr | None = None + net_ec_contribution: StrictFloat | None = Field(default=None, alias="netEcContribution") + nuts_code: StrictStr | None = Field(default=None, alias="nutsCode") + order: StrictInt | None = None + organisation_id: StrictStr | None = Field(default=None, alias="organisationID") + organization_url: StrictStr | None = Field(default=None, alias="organizationURL") + post_code: StrictStr | None = Field(default=None, alias="postCode") + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + role: StrictStr | None = None + short_name: StrictStr | None = Field(default=None, alias="shortName") + street: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") + vat_number: StrictStr | None = Field(default=None, alias="vatNumber") + __properties: ClassVar[list[str]] = ["SME", "active", "activityType", "city", "contactForm", "contentUpdateDate", "country", "ecContribution", "endOfParticipation", "geolocation", "id", "name", "netEcContribution", "nutsCode", "order", "organisationID", "organizationURL", "postCode", "projectAcronym", "projectID", "rcn", "role", "shortName", "street", "totalCost", "vatNumber"] model_config = ConfigDict( validate_by_name=True, @@ -73,11 +80,11 @@ class HEUOrganization(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUOrganization from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -87,7 +94,7 @@ class HEUOrganization(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -98,7 +105,7 @@ class HEUOrganization(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUOrganization from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project.py index 77607832..bd7da3f5 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,48 +8,55 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +from typing import Any, ClassVar, Self + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictStr, +) from pydantic_core import to_jsonable_python + class HEUProject(BaseModel): """ HEUProject - """ # noqa: E501 - acronym: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - ec_max_contribution: Optional[StrictFloat] = Field(default=None, alias="ecMaxContribution") - ec_signature_date: Optional[date] = Field(default=None, alias="ecSignatureDate") - end_date: Optional[date] = Field(default=None, alias="endDate") - framework_programme: Optional[StrictStr] = Field(default=None, alias="frameworkProgramme") - funding_scheme: Optional[StrictStr] = Field(default=None, alias="fundingScheme") - grant_doi: Optional[StrictStr] = Field(default=None, alias="grantDoi") - human_validated: Optional[StrictBool] = Field(default=None, alias="humanValidated") - id: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - master_call: Optional[StrictStr] = Field(default=None, alias="masterCall") - nature: Optional[StrictStr] = None - objective: Optional[StrictStr] = None - rcn: Optional[StrictStr] = None - start_date: Optional[date] = Field(default=None, alias="startDate") - status: Optional[StrictStr] = None - sub_call: Optional[StrictStr] = Field(default=None, alias="subCall") - title: Optional[StrictStr] = None - topics: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") - __properties: ClassVar[List[str]] = ["acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", "nature", "objective", "rcn", "startDate", "status", "subCall", "title", "topics", "totalCost"] + """ + acronym: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + ec_max_contribution: StrictFloat | None = Field(default=None, alias="ecMaxContribution") + ec_signature_date: date | None = Field(default=None, alias="ecSignatureDate") + end_date: date | None = Field(default=None, alias="endDate") + framework_programme: StrictStr | None = Field(default=None, alias="frameworkProgramme") + funding_scheme: StrictStr | None = Field(default=None, alias="fundingScheme") + grant_doi: StrictStr | None = Field(default=None, alias="grantDoi") + human_validated: StrictBool | None = Field(default=None, alias="humanValidated") + id: StrictStr | None = None + keywords: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + master_call: StrictStr | None = Field(default=None, alias="masterCall") + nature: StrictStr | None = None + objective: StrictStr | None = None + rcn: StrictStr | None = None + start_date: date | None = Field(default=None, alias="startDate") + status: StrictStr | None = None + sub_call: StrictStr | None = Field(default=None, alias="subCall") + title: StrictStr | None = None + topics: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") + __properties: ClassVar[list[str]] = ["acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", "nature", "objective", "rcn", "startDate", "status", "subCall", "title", "topics", "totalCost"] model_config = ConfigDict( validate_by_name=True, @@ -69,11 +75,11 @@ class HEUProject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUProject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -83,7 +89,7 @@ class HEUProject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -94,7 +100,7 @@ class HEUProject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUProject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project_details.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project_details.py index 26227002..a694f160 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project_details.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_project_details.py @@ -1,32 +1,43 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API - Extended Models -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json from datetime import date, datetime -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from typing import Any, ClassVar, Self + +from inse.authors.v2.model import AuthorPage +from inse.models.openalex.topic import Topic +from inse.models.projects_eu_cordis.horizon_europe.heu_deliverable import HEUDeliverable +from inse.models.projects_eu_cordis.horizon_europe.heu_eurosci_voc import HEUEurosciVoc +from inse.models.projects_eu_cordis.horizon_europe.heu_legal_basis import HEULegalBasis +from inse.models.projects_eu_cordis.horizon_europe.heu_organization import ( + HEUOrganization, +) # Import all the base models from inse.models.projects_eu_cordis.horizon_europe.heu_project import HEUProject -from inse.models.projects_eu_cordis.horizon_europe.heu_organization import HEUOrganization from inse.models.projects_eu_cordis.horizon_europe.heu_publication import HEUPublication -from inse.models.projects_eu_cordis.horizon_europe.heu_deliverable import HEUDeliverable -from inse.models.projects_eu_cordis.horizon_europe.heu_report_summary import HEUReportSummary +from inse.models.projects_eu_cordis.horizon_europe.heu_report_summary import ( + HEUReportSummary, +) from inse.models.projects_eu_cordis.horizon_europe.heu_topic import HEUTopic from inse.models.projects_eu_cordis.horizon_europe.heu_web_link import HEUWebLink -from inse.models.projects_eu_cordis.horizon_europe.heu_eurosci_voc import HEUEurosciVoc -from inse.models.projects_eu_cordis.horizon_europe.heu_legal_basis import HEULegalBasis -from inse.authors.v2.model import AuthorPage -from inse.models.openalex.topic import Topic +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictStr, +) +from pydantic_core import to_jsonable_python + class HEUProjectDetails(BaseModel): """ @@ -34,47 +45,47 @@ class HEUProjectDetails(BaseModel): This model extends the base HEUProject with all associated data. """ # Project core information (flattened from HEUProject) - acronym: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - ec_max_contribution: Optional[StrictFloat] = Field(default=None, alias="ecMaxContribution") - ec_signature_date: Optional[date] = Field(default=None, alias="ecSignatureDate") - end_date: Optional[date] = Field(default=None, alias="endDate") - framework_programme: Optional[StrictStr] = Field(default=None, alias="frameworkProgramme") - funding_scheme: Optional[StrictStr] = Field(default=None, alias="fundingScheme") - grant_doi: Optional[StrictStr] = Field(default=None, alias="grantDoi") - human_validated: Optional[StrictBool] = Field(default=None, alias="humanValidated") - id: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - legal_basis: Optional[StrictStr] = Field(default=None, alias="legalBasis") - master_call: Optional[StrictStr] = Field(default=None, alias="masterCall") - nature: Optional[StrictStr] = None - objective: Optional[StrictStr] = None - rcn: Optional[StrictStr] = None - start_date: Optional[date] = Field(default=None, alias="startDate") - status: Optional[StrictStr] = None - sub_call: Optional[StrictStr] = Field(default=None, alias="subCall") - title: Optional[StrictStr] = None - topics: Optional[StrictStr] = None - total_cost: Optional[StrictFloat] = Field(default=None, alias="totalCost") + acronym: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + ec_max_contribution: StrictFloat | None = Field(default=None, alias="ecMaxContribution") + ec_signature_date: date | None = Field(default=None, alias="ecSignatureDate") + end_date: date | None = Field(default=None, alias="endDate") + framework_programme: StrictStr | None = Field(default=None, alias="frameworkProgramme") + funding_scheme: StrictStr | None = Field(default=None, alias="fundingScheme") + grant_doi: StrictStr | None = Field(default=None, alias="grantDoi") + human_validated: StrictBool | None = Field(default=None, alias="humanValidated") + id: StrictStr | None = None + keywords: StrictStr | None = None + legal_basis: StrictStr | None = Field(default=None, alias="legalBasis") + master_call: StrictStr | None = Field(default=None, alias="masterCall") + nature: StrictStr | None = None + objective: StrictStr | None = None + rcn: StrictStr | None = None + start_date: date | None = Field(default=None, alias="startDate") + status: StrictStr | None = None + sub_call: StrictStr | None = Field(default=None, alias="subCall") + title: StrictStr | None = None + topics: StrictStr | None = None + total_cost: StrictFloat | None = Field(default=None, alias="totalCost") # Related entities (collections) - organizations: Optional[List[HEUOrganization]] = Field(default=None, description="Organizations participating in the project") - publications: Optional[List[HEUPublication]] = Field(default=None, description="Publications related to the project") - deliverables: Optional[List[HEUDeliverable]] = Field(default=None, description="Deliverables of the project") - report_summaries: Optional[List[HEUReportSummary]] = Field(default=None, alias="reportSummaries", description="Report summaries for the project") - topics_list: Optional[List[HEUTopic]] = Field(default=None, alias="topicsList", description="Topics associated with the project") - web_links: Optional[List[HEUWebLink]] = Field(default=None, alias="webLinks", description="Web links related to the project") - eurosci_voc: Optional[List[HEUEurosciVoc]] = Field(default=None, alias="eurosciVoc", description="EuroSciVoc classifications") - legal_basis_list: Optional[List[HEULegalBasis]] = Field(default=None, alias="legalBasisList", description="Legal basis information") + organizations: list[HEUOrganization] | None = Field(default=None, description="Organizations participating in the project") + publications: list[HEUPublication] | None = Field(default=None, description="Publications related to the project") + deliverables: list[HEUDeliverable] | None = Field(default=None, description="Deliverables of the project") + report_summaries: list[HEUReportSummary] | None = Field(default=None, alias="reportSummaries", description="Report summaries for the project") + topics_list: list[HEUTopic] | None = Field(default=None, alias="topicsList", description="Topics associated with the project") + web_links: list[HEUWebLink] | None = Field(default=None, alias="webLinks", description="Web links related to the project") + eurosci_voc: list[HEUEurosciVoc] | None = Field(default=None, alias="eurosciVoc", description="EuroSciVoc classifications") + legal_basis_list: list[HEULegalBasis] | None = Field(default=None, alias="legalBasisList", description="Legal basis information") # Project statistics (aggregated) - organization_count: Optional[int] = Field(default=None, alias="organizationCount") - publication_count: Optional[int] = Field(default=None, alias="publicationCount") - deliverable_count: Optional[int] = Field(default=None, alias="deliverableCount") + organization_count: int | None = Field(default=None, alias="organizationCount") + publication_count: int | None = Field(default=None, alias="publicationCount") + deliverable_count: int | None = Field(default=None, alias="deliverableCount") # OpenAlex related fields - oa_topics: Optional[List[Topic]] = Field(default=None, alias="oaTopics", description="OpenAlex topics associated with the project") - oa_authors: Optional[AuthorPage] = Field(default=None, alias="oaAuthors", description="OpenAlex authors associated with the project") - __properties: ClassVar[List[str]] = [ + oa_topics: list[Topic] | None = Field(default=None, alias="oaTopics", description="OpenAlex topics associated with the project") + oa_authors: AuthorPage | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors associated with the project") + __properties: ClassVar[list[str]] = [ "acronym", "contentUpdateDate", "ecMaxContribution", "ecSignatureDate", "endDate", "frameworkProgramme", "fundingScheme", "grantDoi", "humanValidated", "id", "keywords", "legalBasis", "masterCall", @@ -102,13 +113,13 @@ class HEUProjectDetails(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUProjectDetailed from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias.""" - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -119,7 +130,7 @@ class HEUProjectDetails(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUProjectDetailed from a dict""" if obj is None: return None @@ -173,16 +184,16 @@ class HEUProjectDetails(BaseModel): def from_project_with_relations( cls, project: HEUProject, - organizations: Optional[List[HEUOrganization]] = None, - publications: Optional[List[HEUPublication]] = None, - deliverables: Optional[List[HEUDeliverable]] = None, - report_summaries: Optional[List[HEUReportSummary]] = None, - topics_list: Optional[List[HEUTopic]] = None, - web_links: Optional[List[HEUWebLink]] = None, - eurosci_voc: Optional[List[HEUEurosciVoc]] = None, - legal_basis_list: Optional[List[HEULegalBasis]] = None, - oa_topics: Optional[List[Topic]] = None, - oa_authors: Optional[AuthorPage] = None, + organizations: list[HEUOrganization] | None = None, + publications: list[HEUPublication] | None = None, + deliverables: list[HEUDeliverable] | None = None, + report_summaries: list[HEUReportSummary] | None = None, + topics_list: list[HEUTopic] | None = None, + web_links: list[HEUWebLink] | None = None, + eurosci_voc: list[HEUEurosciVoc] | None = None, + legal_basis_list: list[HEULegalBasis] | None = None, + oa_topics: list[Topic] | None = None, + oa_authors: AuthorPage | None = None, ) -> Self: """ Factory method to create a detailed project from a base project and its relations. diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_publication.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_publication.py index 291542a6..97d678f4 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_publication.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_publication.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,47 +8,47 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self -from pydantic_core import to_jsonable_python +from typing import Any, ClassVar, Self + from inse.authors.v2.model import Author +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from pydantic_core import to_jsonable_python + class HEUPublication(BaseModel): """ HEUPublication - """ # noqa: E501 - authors: Optional[StrictStr] = None - oa_authors: Optional[List[Author]] = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") - collection: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - doi: Optional[StrictStr] = None - id: Optional[StrictStr] = None - is_published_as: Optional[StrictStr] = Field(default=None, alias="isPublishedAs") - journal_number: Optional[StrictStr] = Field(default=None, alias="journalNumber") - journal_title: Optional[StrictStr] = Field(default=None, alias="journalTitle") - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - published_pages: Optional[StrictStr] = Field(default=None, alias="publishedPages") - published_year: Optional[StrictInt] = Field(default=None, alias="publishedYear") - publisher: Optional[StrictStr] = None - qa_processed_doi: Optional[StrictStr] = Field(default=None, alias="qaProcessedDoi") - rcn: Optional[StrictStr] = None - repository_url: Optional[StrictStr] = Field(default=None, alias="repositoryUrl") - title: Optional[StrictStr] = None - volume: Optional[StrictStr] = None - oa_authors: Optional[List[Author]] = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") - __properties: ClassVar[List[str]] = ["authors", "collection", "contentUpdateDate", "doi", "id", "isPublishedAs", "journalNumber", "journalTitle", "projectAcronym", "projectID", "publishedPages", "publishedYear", "publisher", "qaProcessedDoi", "rcn", "repositoryUrl", "title", "volume", "oaAuthors"] + """ + authors: StrictStr | None = None + oa_authors: list[Author] | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") + collection: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + doi: StrictStr | None = None + id: StrictStr | None = None + is_published_as: StrictStr | None = Field(default=None, alias="isPublishedAs") + journal_number: StrictStr | None = Field(default=None, alias="journalNumber") + journal_title: StrictStr | None = Field(default=None, alias="journalTitle") + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + published_pages: StrictStr | None = Field(default=None, alias="publishedPages") + published_year: StrictInt | None = Field(default=None, alias="publishedYear") + publisher: StrictStr | None = None + qa_processed_doi: StrictStr | None = Field(default=None, alias="qaProcessedDoi") + rcn: StrictStr | None = None + repository_url: StrictStr | None = Field(default=None, alias="repositoryUrl") + title: StrictStr | None = None + volume: StrictStr | None = None + oa_authors: list[Author] | None = Field(default=None, alias="oaAuthors", description="OpenAlex authors matched to this publication's DOI") + __properties: ClassVar[list[str]] = ["authors", "collection", "contentUpdateDate", "doi", "id", "isPublishedAs", "journalNumber", "journalTitle", "projectAcronym", "projectID", "publishedPages", "publishedYear", "publisher", "qaProcessedDoi", "rcn", "repositoryUrl", "title", "volume", "oaAuthors"] model_config = ConfigDict( validate_by_name=True, @@ -68,11 +67,11 @@ class HEUPublication(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUPublication from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -82,7 +81,7 @@ class HEUPublication(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -93,7 +92,7 @@ class HEUPublication(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUPublication from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_report_summary.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_report_summary.py index bf5850fc..a4692e5c 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_report_summary.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_report_summary.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,33 +8,33 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class HEUReportSummary(BaseModel): """ HEUReportSummary - """ # noqa: E501 - attachments: Optional[StrictStr] = None - content_update_date: Optional[datetime] = Field(default=None, alias="contentUpdateDate") - id: Optional[StrictStr] = None - project_acronym: Optional[StrictStr] = Field(default=None, alias="projectAcronym") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - rcn: Optional[StrictStr] = None - title: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["attachments", "contentUpdateDate", "id", "projectAcronym", "projectID", "rcn", "title"] + """ + attachments: StrictStr | None = None + content_update_date: datetime | None = Field(default=None, alias="contentUpdateDate") + id: StrictStr | None = None + project_acronym: StrictStr | None = Field(default=None, alias="projectAcronym") + project_id: StrictStr | None = Field(default=None, alias="projectID") + rcn: StrictStr | None = None + title: StrictStr | None = None + __properties: ClassVar[list[str]] = ["attachments", "contentUpdateDate", "id", "projectAcronym", "projectID", "rcn", "title"] model_config = ConfigDict( validate_by_name=True, @@ -54,11 +53,11 @@ class HEUReportSummary(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUReportSummary from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -68,7 +67,7 @@ class HEUReportSummary(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -79,7 +78,7 @@ class HEUReportSummary(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUReportSummary from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_topic.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_topic.py index 4aa58787..1830c3d3 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_topic.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_topic.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,29 +8,29 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class HEUTopic(BaseModel): """ HEUTopic - """ # noqa: E501 - id: Optional[StrictStr] = None - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - title: Optional[StrictStr] = None - topic: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["id", "projectID", "title", "topic"] + """ + id: StrictStr | None = None + project_id: StrictStr | None = Field(default=None, alias="projectID") + title: StrictStr | None = None + topic: StrictStr | None = None + __properties: ClassVar[list[str]] = ["id", "projectID", "title", "topic"] model_config = ConfigDict( validate_by_name=True, @@ -50,11 +49,11 @@ class HEUTopic(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUTopic from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +63,7 @@ class HEUTopic(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -75,7 +74,7 @@ class HEUTopic(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUTopic from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_web_link.py b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_web_link.py index 50797815..937cd295 100644 --- a/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_web_link.py +++ b/service/src/main/inse/models/projects_eu_cordis/horizon_europe/heu_web_link.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ CORDIS Horizon Europe Multi-Index API @@ -9,36 +8,36 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json - from datetime import datetime +from typing import Any, ClassVar, Self + from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class HEUWebLink(BaseModel): """ HEUWebLink - """ # noqa: E501 - archived_date: Optional[datetime] = Field(default=None, alias="archivedDate") - available_languages: Optional[StrictStr] = Field(default=None, alias="availableLanguages") - id: Optional[StrictStr] = None - link_id: Optional[StrictStr] = Field(default=None, alias="linkId") - project_id: Optional[StrictStr] = Field(default=None, alias="projectID") - represents: Optional[StrictStr] = None - source: Optional[StrictStr] = None - status: Optional[StrictStr] = None - type: Optional[StrictStr] = None - url: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["archivedDate", "availableLanguages", "id", "linkId", "projectID", "represents", "source", "status", "type", "url"] + """ + archived_date: datetime | None = Field(default=None, alias="archivedDate") + available_languages: StrictStr | None = Field(default=None, alias="availableLanguages") + id: StrictStr | None = None + link_id: StrictStr | None = Field(default=None, alias="linkId") + project_id: StrictStr | None = Field(default=None, alias="projectID") + represents: StrictStr | None = None + source: StrictStr | None = None + status: StrictStr | None = None + type: StrictStr | None = None + url: StrictStr | None = None + __properties: ClassVar[list[str]] = ["archivedDate", "availableLanguages", "id", "linkId", "projectID", "represents", "source", "status", "type", "url"] model_config = ConfigDict( validate_by_name=True, @@ -57,11 +56,11 @@ class HEUWebLink(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HEUWebLink from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -71,7 +70,7 @@ class HEUWebLink(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -82,7 +81,7 @@ class HEUWebLink(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HEUWebLink from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/ude_organizations/keyword_object.py b/service/src/main/inse/models/ude_organizations/keyword_object.py index f5584e02..551e76d5 100644 --- a/service/src/main/inse/models/ude_organizations/keyword_object.py +++ b/service/src/main/inse/models/ude_organizations/keyword_object.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ UDE Organization Content Index Backend Models @@ -9,27 +8,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class KeywordObject(BaseModel): """ Object structure for keywords and their assigned scores. - """ # noqa: E501 - score: Optional[Union[StrictFloat, StrictInt]] = None - value: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["score", "value"] + """ + score: StrictFloat | StrictInt | None = None + value: StrictStr | None = None + __properties: ClassVar[list[str]] = ["score", "value"] model_config = ConfigDict( validate_by_name=True, @@ -48,11 +47,11 @@ class KeywordObject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of KeywordObject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -62,7 +61,7 @@ class KeywordObject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -73,7 +72,7 @@ class KeywordObject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of KeywordObject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/ude_organizations/news_object.py b/service/src/main/inse/models/ude_organizations/news_object.py index 4348bf4b..39399107 100644 --- a/service/src/main/inse/models/ude_organizations/news_object.py +++ b/service/src/main/inse/models/ude_organizations/news_object.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ UDE Organization Content Index Backend Models @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class NewsObject(BaseModel): """ Object structure for related news content. - """ # noqa: E501 - var_date: Optional[StrictStr] = Field(default=None, alias="date") - keywords: Optional[StrictStr] = None - links: Optional[StrictStr] = None - source: Optional[StrictStr] = None - title: Optional[StrictStr] = None - topic: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["date", "keywords", "links", "source", "title", "topic"] + """ + var_date: StrictStr | None = Field(default=None, alias="date") + keywords: StrictStr | None = None + links: StrictStr | None = None + source: StrictStr | None = None + title: StrictStr | None = None + topic: StrictStr | None = None + __properties: ClassVar[list[str]] = ["date", "keywords", "links", "source", "title", "topic"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class NewsObject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of NewsObject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class NewsObject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class NewsObject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of NewsObject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/ude_organizations/project_object.py b/service/src/main/inse/models/ude_organizations/project_object.py index dc0e9514..0243af6c 100644 --- a/service/src/main/inse/models/ude_organizations/project_object.py +++ b/service/src/main/inse/models/ude_organizations/project_object.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ UDE Organization Content Index Backend Models @@ -9,31 +8,31 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class ProjectObject(BaseModel): """ Object structure for related projects. - """ # noqa: E501 - keywords: Optional[StrictStr] = None - links: Optional[StrictStr] = None - names: Optional[StrictStr] = None - project_type: Optional[StrictStr] = None - title: Optional[StrictStr] = None - topic: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["keywords", "links", "names", "project_type", "title", "topic"] + """ + keywords: StrictStr | None = None + links: StrictStr | None = None + names: StrictStr | None = None + project_type: StrictStr | None = None + title: StrictStr | None = None + topic: StrictStr | None = None + __properties: ClassVar[list[str]] = ["keywords", "links", "names", "project_type", "title", "topic"] model_config = ConfigDict( validate_by_name=True, @@ -52,11 +51,11 @@ class ProjectObject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ProjectObject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -66,7 +65,7 @@ class ProjectObject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -77,7 +76,7 @@ class ProjectObject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ProjectObject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/ude_organizations/staff_object.py b/service/src/main/inse/models/ude_organizations/staff_object.py index b6629a2e..1564b0e4 100644 --- a/service/src/main/inse/models/ude_organizations/staff_object.py +++ b/service/src/main/inse/models/ude_organizations/staff_object.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ UDE Organization Content Index Backend Models @@ -9,32 +8,32 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class StaffObject(BaseModel): """ Object structure for related staff members. - """ # noqa: E501 - email: Optional[StrictStr] = None - keywords: Optional[StrictStr] = None - links: Optional[StrictStr] = None - name: Optional[StrictStr] = None - research_interests: Optional[StrictStr] = None - source: Optional[StrictStr] = None - telefon: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["email", "keywords", "links", "name", "research_interests", "source", "telefon"] + """ + email: StrictStr | None = None + keywords: StrictStr | None = None + links: StrictStr | None = None + name: StrictStr | None = None + research_interests: StrictStr | None = None + source: StrictStr | None = None + telefon: StrictStr | None = None + __properties: ClassVar[list[str]] = ["email", "keywords", "links", "name", "research_interests", "source", "telefon"] model_config = ConfigDict( validate_by_name=True, @@ -53,11 +52,11 @@ class StaffObject(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of StaffObject from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -67,7 +66,7 @@ class StaffObject(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -78,7 +77,7 @@ class StaffObject(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of StaffObject from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/ude_organizations/ude_organization_content.py b/service/src/main/inse/models/ude_organizations/ude_organization_content.py index 879ec30f..b4bf5c1d 100644 --- a/service/src/main/inse/models/ude_organizations/ude_organization_content.py +++ b/service/src/main/inse/models/ude_organizations/ude_organization_content.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ UDE Organization Content Index Backend Models @@ -9,34 +8,34 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.ude_organizations.keyword_object import KeywordObject from inse.models.ude_organizations.news_object import NewsObject from inse.models.ude_organizations.project_object import ProjectObject from inse.models.ude_organizations.staff_object import StaffObject -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, StrictStr from pydantic_core import to_jsonable_python + class UdeOrganizationContent(BaseModel): """ Main document model for the ude_organization_content_august_2025 index. - """ # noqa: E501 - keywords: Optional[KeywordObject] = None - news: Optional[NewsObject] = None - projects: Optional[ProjectObject] = None - staff: Optional[StaffObject] = None - uri: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["keywords", "news", "projects", "staff", "uri"] + """ + keywords: KeywordObject | None = None + news: NewsObject | None = None + projects: ProjectObject | None = None + staff: StaffObject | None = None + uri: StrictStr | None = None + __properties: ClassVar[list[str]] = ["keywords", "news", "projects", "staff", "uri"] model_config = ConfigDict( validate_by_name=True, @@ -55,11 +54,11 @@ class UdeOrganizationContent(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of UdeOrganizationContent from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -69,7 +68,7 @@ class UdeOrganizationContent(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -92,7 +91,7 @@ class UdeOrganizationContent(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of UdeOrganizationContent from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/ude_persons/function_nested.py b/service/src/main/inse/models/ude_persons/function_nested.py index 97e618be..a21f6da6 100644 --- a/service/src/main/inse/models/ude_persons/function_nested.py +++ b/service/src/main/inse/models/ude_persons/function_nested.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ UDE Persons Index Backend Models @@ -9,27 +8,27 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self from pydantic_core import to_jsonable_python + class FunctionNested(BaseModel): """ Nested object for a person's functions and facilities. - """ # noqa: E501 - facility: Optional[StrictStr] = None - function: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["facility", "function"] + """ + facility: StrictStr | None = None + function: StrictStr | None = None + __properties: ClassVar[list[str]] = ["facility", "function"] model_config = ConfigDict( validate_by_name=True, @@ -48,11 +47,11 @@ class FunctionNested(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of FunctionNested from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -62,7 +61,7 @@ class FunctionNested(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -73,7 +72,7 @@ class FunctionNested(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of FunctionNested from a dict""" if obj is None: return None diff --git a/service/src/main/inse/models/ude_persons/ude_person.py b/service/src/main/inse/models/ude_persons/ude_person.py index 80c08da0..9c4c084b 100644 --- a/service/src/main/inse/models/ude_persons/ude_person.py +++ b/service/src/main/inse/models/ude_persons/ude_person.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ UDE Persons Index Backend Models @@ -9,42 +8,42 @@ Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. -""" # noqa: E501 +""" from __future__ import annotations + +import json import pprint import re # noqa: F401 -import json +from typing import Any, ClassVar, Self -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional from inse.models.ude_persons.function_nested import FunctionNested -from typing import Optional, Set -from typing_extensions import Self +from pydantic import BaseModel, ConfigDict, StrictStr from pydantic_core import to_jsonable_python + class UdePerson(BaseModel): """ Main document model for the ude_persons_1.0 index. - """ # noqa: E501 - affiliation_chair: Optional[StrictStr] = None - affiliation_faculty: Optional[StrictStr] = None - affiliation_institute: Optional[StrictStr] = None - affiliation_university: Optional[StrictStr] = None - firstname: Optional[StrictStr] = None - functions: Optional[List[FunctionNested]] = None - location: Optional[StrictStr] = None - lsf_id: Optional[StrictStr] = None - mail: Optional[StrictStr] = None - name: Optional[StrictStr] = None - room: Optional[StrictStr] = None - surname: Optional[StrictStr] = None - telefax: Optional[StrictStr] = None - telefon: Optional[StrictStr] = None - title: Optional[StrictStr] = None - web: Optional[StrictStr] = None - __properties: ClassVar[List[str]] = ["affiliation_chair", "affiliation_faculty", "affiliation_institute", "affiliation_university", "firstname", "functions", "location", "lsf_id", "mail", "name", "room", "surname", "telefax", "telefon", "title", "web"] + """ + affiliation_chair: StrictStr | None = None + affiliation_faculty: StrictStr | None = None + affiliation_institute: StrictStr | None = None + affiliation_university: StrictStr | None = None + firstname: StrictStr | None = None + functions: list[FunctionNested] | None = None + location: StrictStr | None = None + lsf_id: StrictStr | None = None + mail: StrictStr | None = None + name: StrictStr | None = None + room: StrictStr | None = None + surname: StrictStr | None = None + telefax: StrictStr | None = None + telefon: StrictStr | None = None + title: StrictStr | None = None + web: StrictStr | None = None + __properties: ClassVar[list[str]] = ["affiliation_chair", "affiliation_faculty", "affiliation_institute", "affiliation_university", "firstname", "functions", "location", "lsf_id", "mail", "name", "room", "surname", "telefax", "telefon", "title", "web"] model_config = ConfigDict( validate_by_name=True, @@ -63,11 +62,11 @@ class UdePerson(BaseModel): return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of UdePerson from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -77,7 +76,7 @@ class UdePerson(BaseModel): were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([ + excluded_fields: set[str] = set([ ]) _dict = self.model_dump( @@ -95,7 +94,7 @@ class UdePerson(BaseModel): return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of UdePerson from a dict""" if obj is None: return None diff --git a/service/src/main/inse/news/logic.py b/service/src/main/inse/news/logic.py index 68ab493f..9e07315b 100644 --- a/service/src/main/inse/news/logic.py +++ b/service/src/main/inse/news/logic.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Business logic for the "aktuell" news index on the INSE cluster. """ @@ -13,7 +12,14 @@ from inse.exceptions import ElasticsearchException from ..integrations import elasticsearch, llm from ..persons.logic import find_ude_author_by_name, get_author_name_by_id from ..topics.logic import vector_search_topics_batch -from .model import (MatchedTopic, MentionedPerson, NewsArticle, NewsArticleDetail, NewsKeywords, NewsPage) +from .model import ( + MatchedTopic, + MentionedPerson, + NewsArticle, + NewsArticleDetail, + NewsKeywords, + NewsPage, +) logger = logging.getLogger(__name__) @@ -248,7 +254,7 @@ async def get_news_by_id(news_id: str) -> NewsArticleDetail: source=["date", "maintitle", "author", "url", "full_content"], cluster="inse", ) - except ElasticsearchException as exc: + except ElasticsearchException: logger.exception("Abruf des News-Artikels fehlgeschlagen.") raise @@ -523,7 +529,7 @@ async def _run_search(query: dict, source: list, size: int, offset: int, sort, h highlight=highlight, cluster="inse", ) - except ElasticsearchException as exc: + except ElasticsearchException: logger.exception("Elasticsearch-Anfrage an Index 'aktuell' fehlgeschlagen.") raise diff --git a/service/src/main/inse/news/model.py b/service/src/main/inse/news/model.py index fd320a90..8ce160de 100644 --- a/service/src/main/inse/news/model.py +++ b/service/src/main/inse/news/model.py @@ -1,51 +1,49 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from typing import List, Optional + from pydantic import BaseModel, Field class NewsKeywords(BaseModel): - keywords: List[str] = Field(description="The extracted keywords from the article.") + keywords: list[str] = Field(description="The extracted keywords from the article.") class NewsArticle(BaseModel): id: str - date: Optional[str] = None - maintitle: Optional[str] = None - author: Optional[str] = None - url: Optional[str] = None - relevant: Optional[bool] = None - snippet: Optional[str] = None - related: Optional[bool] = None + date: str | None = None + maintitle: str | None = None + author: str | None = None + url: str | None = None + relevant: bool | None = None + snippet: str | None = None + related: bool | None = None class MentionedPerson(BaseModel): name: str is_ude: bool = False - person_id: Optional[str] = None + person_id: str | None = None class MatchedTopic(BaseModel): - id: Optional[str] = None - display_name: Optional[str] = None - subfield_name: Optional[str] = None - field_name: Optional[str] = None - domain_name: Optional[str] = None - source_keyword: Optional[str] = None + id: str | None = None + display_name: str | None = None + subfield_name: str | None = None + field_name: str | None = None + domain_name: str | None = None + source_keyword: str | None = None class NewsArticleDetail(NewsArticle): - full_content: Optional[str] = None - relevant: Optional[bool] = None - authors: List[MentionedPerson] = [] - keywords: List[str] = [] - topics: List[MatchedTopic] = [] + full_content: str | None = None + relevant: bool | None = None + authors: list[MentionedPerson] = [] + keywords: list[str] = [] + topics: list[MatchedTopic] = [] class NewsPage(BaseModel): total: int page: int page_size: int - results: List[NewsArticle] + results: list[NewsArticle] diff --git a/service/src/main/inse/news/service.py b/service/src/main/inse/news/service.py index b183d6fa..74f300b9 100644 --- a/service/src/main/inse/news/service.py +++ b/service/src/main/inse/news/service.py @@ -1,16 +1,14 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for the "aktuell" news index. """ from typing import Annotated -from fastapi import APIRouter -from fastapi import Path -from fastapi import Query +from fastapi import APIRouter, Path, Query from inse.tags import Tags + from . import logic from .model import NewsArticleDetail, NewsPage diff --git a/service/src/main/inse/organization_management/model.py b/service/src/main/inse/organization_management/model.py index e5e0a615..8357daa9 100644 --- a/service/src/main/inse/organization_management/model.py +++ b/service/src/main/inse/organization_management/model.py @@ -1,5 +1,4 @@ import uuid -from typing import List, Optional from pydantic import BaseModel, Field @@ -7,13 +6,13 @@ from pydantic import BaseModel, Field class OrganizationProfile(BaseModel): id: uuid.UUID name: str - other_inst_id: Optional[str] = None + other_inst_id: str | None = None deleted: bool member_count: int class OrganizationPage(BaseModel): - items: List[OrganizationProfile] + items: list[OrganizationProfile] total: int page: int page_size: int @@ -21,10 +20,10 @@ class OrganizationPage(BaseModel): class CreateOrganizationRequest(BaseModel): name: str = Field(min_length=1) - other_inst_id: Optional[str] = None + other_inst_id: str | None = None class UpdateOrganizationRequest(BaseModel): - name: Optional[str] = Field(default=None, min_length=1) - other_inst_id: Optional[str] = None - deleted: Optional[bool] = None + name: str | None = Field(default=None, min_length=1) + other_inst_id: str | None = None + deleted: bool | None = None diff --git a/service/src/main/inse/organization_management/router.py b/service/src/main/inse/organization_management/router.py index 5a2db2bd..5232ca66 100644 --- a/service/src/main/inse/organization_management/router.py +++ b/service/src/main/inse/organization_management/router.py @@ -1,5 +1,4 @@ import uuid -from typing import Optional from fastapi import APIRouter, Depends, Query, Response, status from sqlmodel import Session @@ -24,7 +23,7 @@ router = APIRouter(prefix="/api/organizations", tags=[Tags.ORGANIZATION]) async def get_organizations( page: int = Query(default=0, ge=0), page_size: int = Query(default=25, ge=1, le=100), - offset: Optional[int] = Query(default=None, ge=0), + offset: int | None = Query(default=None, ge=0), session: Session = Depends(get_session), access_token: AccessTokenMetadata = auth_service.CurrentUserAccessTokenPayloadDep, ) -> OrganizationPage: diff --git a/service/src/main/inse/organization_management/service.py b/service/src/main/inse/organization_management/service.py index 528bcf35..dcb06c30 100644 --- a/service/src/main/inse/organization_management/service.py +++ b/service/src/main/inse/organization_management/service.py @@ -1,5 +1,4 @@ import uuid -from typing import Optional from fastapi import HTTPException, status from sqlmodel import Session, func, select @@ -35,7 +34,7 @@ def _normalize_name(name: str) -> str: def _ensure_name_available( session: Session, name: str, - excluded_organization_id: Optional[uuid.UUID] = None, + excluded_organization_id: uuid.UUID | None = None, ) -> None: statement = select(Organization).where( func.lower(Organization.name) == name.lower() @@ -72,8 +71,8 @@ def _member_counts( select(Account.organization_id, func.count(Account.id)) .where( Account.organization_id.in_(organization_ids), - Account.deleted == False, # noqa: E712 - Account.activated == True, # noqa: E712 + Account.deleted == False, + Account.activated == True, ) .group_by(Account.organization_id) ).all() @@ -98,7 +97,7 @@ def _deactivate_organization_accounts( accounts = session.exec( select(Account).where( Account.organization_id == organization_id, - Account.activated == True, # noqa: E712 + Account.activated == True, ) ).all() for account in accounts: @@ -112,7 +111,7 @@ def get_organizations( access_token: AccessTokenMetadata, page: int, page_size: int, - offset: Optional[int] = None, + offset: int | None = None, ) -> OrganizationPage: statement = select(Organization) count_statement = select(func.count()).select_from(Organization) diff --git a/service/src/main/inse/patents/__init__.py b/service/src/main/inse/patents/__init__.py index d10d63ca..4f4c13ee 100644 --- a/service/src/main/inse/patents/__init__.py +++ b/service/src/main/inse/patents/__init__.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Patents domain package. """ diff --git a/service/src/main/inse/patents/all/logic.py b/service/src/main/inse/patents/all/logic.py index 767546d8..0213dd0b 100644 --- a/service/src/main/inse/patents/all/logic.py +++ b/service/src/main/inse/patents/all/logic.py @@ -5,9 +5,11 @@ from datetime import datetime import httpx from fastapi import HTTPException -from starlette.status import HTTP_404_NOT_FOUND -from starlette.status import HTTP_502_BAD_GATEWAY -from starlette.status import HTTP_503_SERVICE_UNAVAILABLE +from starlette.status import ( + HTTP_404_NOT_FOUND, + HTTP_502_BAD_GATEWAY, + HTTP_503_SERVICE_UNAVAILABLE, +) from inse.patents.common import model from inse.patents.common.elastic_search_client import MissingApiKeyError diff --git a/service/src/main/inse/patents/authors/identity.py b/service/src/main/inse/patents/authors/identity.py index 79ab6115..3c71b879 100644 --- a/service/src/main/inse/patents/authors/identity.py +++ b/service/src/main/inse/patents/authors/identity.py @@ -9,15 +9,18 @@ from dataclasses import dataclass from inse.models.openalex.author import Author from inse.patents.authors.name_matching import ( + _family_name_matches, + _given_name_matches, first_name_match_kind_for_person, name_matches_person, tokens_equal, - _family_name_matches, - _given_name_matches, ) from inse.patents.authors.name_variants import parse_inventor_name, parse_person_name from inse.patents.common import model -from inse.patents.common.text_normalization import normalize_name_part, strip_person_titles +from inse.patents.common.text_normalization import ( + normalize_name_part, + strip_person_titles, +) from inse.patents.institutions.name_matching import ( assignee_matches_institution_name, is_generic_institution_name, diff --git a/service/src/main/inse/patents/authors/logic.py b/service/src/main/inse/patents/authors/logic.py index 32a6f8bc..61d89dbe 100644 --- a/service/src/main/inse/patents/authors/logic.py +++ b/service/src/main/inse/patents/authors/logic.py @@ -3,15 +3,14 @@ import logging import httpx from fastapi import HTTPException -from starlette.status import HTTP_502_BAD_GATEWAY -from starlette.status import HTTP_503_SERVICE_UNAVAILABLE +from starlette.status import HTTP_502_BAD_GATEWAY, HTTP_503_SERVICE_UNAVAILABLE +from inse.models.openalex.author import Author from inse.patents.authors.identity import is_ambiguous_name from inse.patents.authors.name_matching import filter_patents_by_author_name from inse.patents.authors.name_variants import parse_person_name from inse.patents.authors.search_pagination import search_author_patents_adaptive from inse.patents.authors.topic_filter import filter_patents_by_ipc_topic_mapping -from inse.patents.patents_openalex_keywords.resolver import PatentOpenAlexMappingResolver from inse.patents.common import model from inse.patents.common.elastic_search_client import MissingApiKeyError from inse.patents.common.parsing import ( @@ -19,9 +18,11 @@ from inse.patents.common.parsing import ( expand_matched_epo_application_families, ) from inse.patents.ipc_search_client import IpcSearchClient +from inse.patents.patents_openalex_keywords.resolver import ( + PatentOpenAlexMappingResolver, +) from inse.patents.search_client import PatentSearchClient from inse.persons import logic as person_logic -from inse.models.openalex.author import Author logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/patents/authors/name_matching.py b/service/src/main/inse/patents/authors/name_matching.py index e6132d47..79921a57 100644 --- a/service/src/main/inse/patents/authors/name_matching.py +++ b/service/src/main/inse/patents/authors/name_matching.py @@ -2,9 +2,9 @@ from inse.patents.authors.name_variants import ( ParsedPersonName, + _initials_from_tokens, parse_inventor_name, parse_person_name, - _initials_from_tokens, ) from inse.patents.common import model from inse.patents.common.text_normalization import ( diff --git a/service/src/main/inse/patents/authors/name_variants.py b/service/src/main/inse/patents/authors/name_variants.py index c1f7a5e0..50a878e9 100644 --- a/service/src/main/inse/patents/authors/name_variants.py +++ b/service/src/main/inse/patents/authors/name_variants.py @@ -1,7 +1,6 @@ """Parse person names and build search/match variants for multi-part names.""" from __future__ import annotations -import re from dataclasses import dataclass from inse.patents.common.text_normalization import normalize_name_part diff --git a/service/src/main/inse/patents/authors/search_pagination.py b/service/src/main/inse/patents/authors/search_pagination.py index b4af7bed..549fe069 100644 --- a/service/src/main/inse/patents/authors/search_pagination.py +++ b/service/src/main/inse/patents/authors/search_pagination.py @@ -10,9 +10,10 @@ from __future__ import annotations import asyncio import logging import time +from collections.abc import Awaitable, Callable from dataclasses import dataclass, field from enum import Enum -from typing import Any, Awaitable, Callable +from typing import Any from inse.patents.authors.identity import best_name_match_kind from inse.patents.authors.name_matching import filter_patents_by_author_name diff --git a/service/src/main/inse/patents/authors/test_ipc_openalex_mapping.py b/service/src/main/inse/patents/authors/test_ipc_openalex_mapping.py index 3972cb2a..112a96e9 100644 --- a/service/src/main/inse/patents/authors/test_ipc_openalex_mapping.py +++ b/service/src/main/inse/patents/authors/test_ipc_openalex_mapping.py @@ -4,17 +4,14 @@ from inse.models.openalex.work_topic_domain import WorkTopicDomain from inse.models.openalex.work_topic_field import WorkTopicField from inse.models.openalex.work_topic_subfield import WorkTopicSubfield from inse.patents.authors import ipc_openalex_mapping as mapping_module -from inse.patents.authors.ipc_openalex_mapping import ( - clear_mapping_cache, - load_ipc_openalex_mapping, - mapped_topics_match_author, - patent_topics_match_author, - resolve_mapped_topics_for_code, -) from inse.patents.authors.identity import ( patent_full_personal_identity_match, patent_personal_assignee_full_match, ) +from inse.patents.authors.ipc_openalex_mapping import ( + patent_topics_match_author, + resolve_mapped_topics_for_code, +) from inse.patents.authors.topic_filter import filter_patents_by_ipc_topic_mapping from inse.patents.common import model from inse.patents.common.parsing import patent_map_key @@ -317,7 +314,6 @@ def test_filter_rejects_initial_only_personal_assignee_without_topic_match() -> def test_filter_keeps_ambiguous_on_last_known_institution_without_topic() -> None: from inse.models.openalex.dehydrated_institution import DehydratedInstitution - from inse.models.openalex.author_affiliations_inner import AuthorAffiliationsInner author = _author_with_topic( "https://openalex.org/T10158", @@ -357,8 +353,8 @@ def test_filter_keeps_ambiguous_on_last_known_institution_without_topic() -> Non def test_filter_rejects_ambiguous_historical_institution_alone() -> None: - from inse.models.openalex.dehydrated_institution import DehydratedInstitution from inse.models.openalex.author_affiliations_inner import AuthorAffiliationsInner + from inse.models.openalex.dehydrated_institution import DehydratedInstitution author = _author_with_topic( "https://openalex.org/T11111", @@ -402,8 +398,8 @@ def test_filter_rejects_ambiguous_historical_institution_alone() -> None: def test_filter_rejects_ambiguous_generic_historical_institution() -> None: - from inse.models.openalex.dehydrated_institution import DehydratedInstitution from inse.models.openalex.author_affiliations_inner import AuthorAffiliationsInner + from inse.models.openalex.dehydrated_institution import DehydratedInstitution author = _author_with_topic( "https://openalex.org/T11111", @@ -444,8 +440,8 @@ def test_filter_rejects_ambiguous_generic_historical_institution() -> None: def test_filter_keeps_historical_with_confirmed_co_inventors() -> None: - from inse.models.openalex.dehydrated_institution import DehydratedInstitution from inse.models.openalex.author_affiliations_inner import AuthorAffiliationsInner + from inse.models.openalex.dehydrated_institution import DehydratedInstitution author = _author_with_topic( "https://openalex.org/T10158", diff --git a/service/src/main/inse/patents/elastic_search_all_patents_client.py b/service/src/main/inse/patents/elastic_search_all_patents_client.py index faf29ded..84835e7d 100644 --- a/service/src/main/inse/patents/elastic_search_all_patents_client.py +++ b/service/src/main/inse/patents/elastic_search_all_patents_client.py @@ -1,16 +1,15 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ HTTP client for fetching all patents from EPO and USPTO Elasticsearch indices. """ from typing import Any -from .. import config from inse.exceptions import MissingApiKeyError - from inse.integrations import elasticsearch from inse.model import ESCluster +from .. import config + EPO_INDEX = "epo_index_1.0" USPTO_INDEX = "uspto_patents_3.0" diff --git a/service/src/main/inse/patents/elastic_search_client.py b/service/src/main/inse/patents/elastic_search_client.py index 840ac21e..3e561ef0 100644 --- a/service/src/main/inse/patents/elastic_search_client.py +++ b/service/src/main/inse/patents/elastic_search_client.py @@ -1,2 +1,2 @@ """Backward-compatible re-exports.""" -from inse.patents.search_client import * # noqa: F403 +from inse.patents.search_client import * diff --git a/service/src/main/inse/patents/institutions/logic.py b/service/src/main/inse/patents/institutions/logic.py index 9575c38d..6caf7309 100644 --- a/service/src/main/inse/patents/institutions/logic.py +++ b/service/src/main/inse/patents/institutions/logic.py @@ -4,8 +4,7 @@ import logging import httpx from fastapi import HTTPException -from starlette.status import HTTP_502_BAD_GATEWAY -from starlette.status import HTTP_503_SERVICE_UNAVAILABLE +from starlette.status import HTTP_502_BAD_GATEWAY, HTTP_503_SERVICE_UNAVAILABLE from inse.institutions.institutions_search_client import InstitutionsSearchClient from inse.models.openalex.institution import Institution diff --git a/service/src/main/inse/patents/ipc_lookup.py b/service/src/main/inse/patents/ipc_lookup.py index 9581ffe6..39b9305c 100644 --- a/service/src/main/inse/patents/ipc_lookup.py +++ b/service/src/main/inse/patents/ipc_lookup.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Parse IPC/CPC symbols and assemble enriched classification objects. """ @@ -171,10 +170,10 @@ def _lookup_name(level_names: dict[str, str | None], *keys: str | None) -> str | for key in keys: if not key: continue - if key in level_names and level_names[key]: + if level_names.get(key): return level_names[key] normalized = normalize_ipc_symbol(key) - if normalized in level_names and level_names[normalized]: + if level_names.get(normalized): return level_names[normalized] return None diff --git a/service/src/main/inse/patents/ipc_search_client.py b/service/src/main/inse/patents/ipc_search_client.py index 4eb2ec07..7a5b6924 100644 --- a/service/src/main/inse/patents/ipc_search_client.py +++ b/service/src/main/inse/patents/ipc_search_client.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ HTTP client for IPC/CPC classification lookups in the ipc Elasticsearch index. """ @@ -7,17 +6,19 @@ from __future__ import annotations from typing import Any -from .. import config -from . import model from inse.exceptions import MissingApiKeyError -from .ipc_lookup import IpcHierarchyKeys -from .ipc_lookup import build_ipc_classification -from .ipc_lookup import normalize_ipc_symbol -from .ipc_lookup import parse_ipc_symbol - from inse.integrations import elasticsearch from inse.model import ESCluster +from .. import config +from . import model +from .ipc_lookup import ( + IpcHierarchyKeys, + build_ipc_classification, + normalize_ipc_symbol, + parse_ipc_symbol, +) + IPC_INDEX = "ipc" _LEVELS: tuple[tuple[str, str, str], ...] = ( diff --git a/service/src/main/inse/patents/keywords/logic.py b/service/src/main/inse/patents/keywords/logic.py index 1e030675..01e06de2 100644 --- a/service/src/main/inse/patents/keywords/logic.py +++ b/service/src/main/inse/patents/keywords/logic.py @@ -42,14 +42,21 @@ from inse.patents.keywords.model import ( from inse.patents.keywords.reverse_lookup import ( IpcCodeMatch, KeywordIpcReverseLookup, +) +from inse.patents.keywords.reverse_lookup import ( _topic_group_key as _match_topic_group_key, ) from inse.patents.keywords.search_queries import ( IpcPatentSearchQueries, _search_terms_for_symbol, ) -from inse.patents.patents_openalex_keywords.ipc_entries import infer_subclass, normalize_symbol -from inse.patents.patents_openalex_keywords.resolver import PatentOpenAlexMappingResolver +from inse.patents.patents_openalex_keywords.ipc_entries import ( + infer_subclass, + normalize_symbol, +) +from inse.patents.patents_openalex_keywords.resolver import ( + PatentOpenAlexMappingResolver, +) logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/patents/keywords/reverse_lookup.py b/service/src/main/inse/patents/keywords/reverse_lookup.py index 5f29b445..6e3a3825 100644 --- a/service/src/main/inse/patents/keywords/reverse_lookup.py +++ b/service/src/main/inse/patents/keywords/reverse_lookup.py @@ -16,8 +16,12 @@ from inse.patents.common.elastic_search_client import MissingApiKeyError from inse.patents.keywords.model import KeywordPatentSearchItem from inse.patents.patents_openalex_keywords.client import PatentsOpenAlexKeywordsClient from inse.patents.patents_openalex_keywords.ipc_entries import normalize_symbol -from inse.patents.patents_openalex_keywords.mapping import PATENTS_OPENALEX_KEYWORDS_INDEX -from inse.patents.patents_openalex_keywords.resolver import load_patents_openalex_keywords_json +from inse.patents.patents_openalex_keywords.mapping import ( + PATENTS_OPENALEX_KEYWORDS_INDEX, +) +from inse.patents.patents_openalex_keywords.resolver import ( + load_patents_openalex_keywords_json, +) logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/patents/keywords/search_queries.py b/service/src/main/inse/patents/keywords/search_queries.py index 02139697..c24570f6 100644 --- a/service/src/main/inse/patents/keywords/search_queries.py +++ b/service/src/main/inse/patents/keywords/search_queries.py @@ -5,7 +5,10 @@ from typing import Any from inse.patents.common.elastic_search_client import DEFAULT_SEARCH_SIZE from inse.patents.ipc_lookup import display_ipc_symbol, parse_ipc_symbol -from inse.patents.patents_openalex_keywords.ipc_entries import infer_subclass, normalize_symbol +from inse.patents.patents_openalex_keywords.ipc_entries import ( + infer_subclass, + normalize_symbol, +) _PATENT_SOURCE_FIELDS = [ "doc_number", diff --git a/service/src/main/inse/patents/keywords/service.py b/service/src/main/inse/patents/keywords/service.py index 8aac2ea4..a991771b 100644 --- a/service/src/main/inse/patents/keywords/service.py +++ b/service/src/main/inse/patents/keywords/service.py @@ -3,7 +3,10 @@ from typing import Annotated from fastapi import APIRouter, Body from inse.patents.keywords import logic -from inse.patents.keywords.model import PatentsByKeywordsRequest, PatentsByKeywordsResponse +from inse.patents.keywords.model import ( + PatentsByKeywordsRequest, + PatentsByKeywordsResponse, +) router = APIRouter(prefix="/api/inse-service/keywords", tags=["Keywords"]) diff --git a/service/src/main/inse/patents/keywords/test_logic.py b/service/src/main/inse/patents/keywords/test_logic.py index b6f14912..4b48aaa4 100644 --- a/service/src/main/inse/patents/keywords/test_logic.py +++ b/service/src/main/inse/patents/keywords/test_logic.py @@ -10,21 +10,21 @@ from inse.patents.authors.ipc_openalex_mapping import MappedOpenAlexTopic from inse.patents.common import model from inse.patents.keywords.logic import ( TopicEvidence, + _aggregate_subclass_clusters, + _collect_keyword_text_evidence, _compute_final_score, _compute_topic_evidence, - _collect_keyword_text_evidence, _exact_topic_or_subfield_match, - _keyword_text_passes_relevance_gate, - _keyword_text_score, _filter_keywords_for_patent_search, _ipc_hierarchy_quality, _keyword_is_patent_searchable, + _keyword_text_passes_relevance_gate, + _keyword_text_score, _patent_passes_relevance_gate, _patent_search_terms, _score_ipc_match, _score_patent, _select_dominant_clusters, - _aggregate_subclass_clusters, _term_from_ipc_match, _text_overlap_score, _text_search_terms, @@ -34,6 +34,10 @@ from inse.patents.keywords.logic import ( get_patents_by_keywords, select_ipc_matches_by_cluster_mass, ) +from inse.patents.keywords.model import ( + KeywordPatentSearchItem, + PatentsByKeywordsRequest, +) from inse.patents.keywords.reverse_lookup import ( IpcCodeMatch, _dedupe_ipc_matches, @@ -41,7 +45,6 @@ from inse.patents.keywords.reverse_lookup import ( _weighted_score, clear_reverse_lookup_caches, ) -from inse.patents.keywords.model import KeywordPatentSearchItem, PatentsByKeywordsRequest from inse.patents.keywords.search_queries import ( IpcPatentSearchQueries, _search_terms_for_symbol, @@ -1177,7 +1180,7 @@ def test_json_lookup_returns_empty_without_mapping(monkeypatch) -> None: clear_reverse_lookup_caches() monkeypatch.setattr( "inse.patents.keywords.reverse_lookup.load_patents_openalex_keywords_json", - lambda: {}, + dict, ) clear_reverse_lookup_caches() diff --git a/service/src/main/inse/patents/logic.py b/service/src/main/inse/patents/logic.py index 26e73984..1a6f71cb 100644 --- a/service/src/main/inse/patents/logic.py +++ b/service/src/main/inse/patents/logic.py @@ -4,6 +4,8 @@ from inse.patents.authors.logic import get_patents_by_author_id from inse.patents.common.parsing import deduplicate_patents as _deduplicate_patents from inse.patents.institutions.logic import ( filter_patents_by_institution as _filter_patents_by_institution, +) +from inse.patents.institutions.logic import ( get_patents_by_institution_id, ) diff --git a/service/src/main/inse/patents/model.py b/service/src/main/inse/patents/model.py index fe8a1047..4201a81d 100644 --- a/service/src/main/inse/patents/model.py +++ b/service/src/main/inse/patents/model.py @@ -1,2 +1,2 @@ """Backward-compatible re-exports.""" -from inse.patents.common.model import * # noqa: F403 +from inse.patents.common.model import * diff --git a/service/src/main/inse/patents/org/elastic_search_client.py b/service/src/main/inse/patents/org/elastic_search_client.py index 1dc73042..0bee7f9e 100644 --- a/service/src/main/inse/patents/org/elastic_search_client.py +++ b/service/src/main/inse/patents/org/elastic_search_client.py @@ -6,12 +6,12 @@ from typing import Any import httpx +from inse import config from inse.integrations import elasticsearch from inse.models.openalex.author import Author from inse.patents.common.elastic_search_client import MissingApiKeyError from inse.patents.org.mapping import ORG_PATENTS_INDEX, ORG_PATENTS_MAPPING from inse.patents.org.model import MatchTypeFilter, OrgPatentEntry -from inse import config logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/patents/org/logic.py b/service/src/main/inse/patents/org/logic.py index d0c93be7..5225d251 100644 --- a/service/src/main/inse/patents/org/logic.py +++ b/service/src/main/inse/patents/org/logic.py @@ -6,8 +6,7 @@ from dataclasses import dataclass, field import httpx from fastapi import HTTPException -from starlette.status import HTTP_502_BAD_GATEWAY -from starlette.status import HTTP_503_SERVICE_UNAVAILABLE +from starlette.status import HTTP_502_BAD_GATEWAY, HTTP_503_SERVICE_UNAVAILABLE from inse.institutions.institutions_search_client import InstitutionsSearchClient from inse.models.openalex.author import Author @@ -29,18 +28,18 @@ from inse.patents.common.parsing import ( ) from inse.patents.institutions.logic import get_patents_by_institution_id from inse.patents.ipc_search_client import IpcSearchClient -from inse.patents.patents_openalex_keywords.client import PatentsOpenAlexKeywordsClient from inse.patents.org.elastic_search_client import ( OrgPatentsSearchClient, fetch_authors_by_institution_name, ) from inse.patents.org.model import ( + MatchedAuthor, MatchType, MatchTypeFilter, - MatchedAuthor, OrgPatentEntry, OrgPatentsResponse, ) +from inse.patents.patents_openalex_keywords.client import PatentsOpenAlexKeywordsClient from inse.patents.search_client import PatentSearchClient logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/patents/org/test_logic.py b/service/src/main/inse/patents/org/test_logic.py index 60622812..f513da34 100644 --- a/service/src/main/inse/patents/org/test_logic.py +++ b/service/src/main/inse/patents/org/test_logic.py @@ -5,7 +5,6 @@ from inse.patents.org.logic import ( org_patent_document_id, resolve_match_type, ) -from inse.patents.org.model import MatchedAuthor def _patent( diff --git a/service/src/main/inse/patents/patents_openalex_keywords/matching.py b/service/src/main/inse/patents/patents_openalex_keywords/matching.py index 872d2837..84a62aa6 100644 --- a/service/src/main/inse/patents/patents_openalex_keywords/matching.py +++ b/service/src/main/inse/patents/patents_openalex_keywords/matching.py @@ -4,7 +4,7 @@ from __future__ import annotations import json import logging from dataclasses import dataclass -from datetime import datetime, timezone +from datetime import UTC, datetime from pathlib import Path from typing import Any @@ -225,7 +225,7 @@ def build_documents( levels: tuple[str, ...], top_k: int, ) -> list[tuple[str, dict]]: - built_at = datetime.now(timezone.utc).isoformat() + built_at = datetime.now(UTC).isoformat() documents: list[tuple[str, dict]] = [] label_cache: dict[str, tuple[list[dict], list[dict]]] = {} @@ -392,7 +392,7 @@ async def build_documents_from_topicvectors( levels: tuple[str, ...], top_k: int, ) -> list[tuple[str, dict]]: - built_at = datetime.now(timezone.utc).isoformat() + built_at = datetime.now(UTC).isoformat() documents: list[tuple[str, dict]] = [] label_cache: dict[str, tuple[list[dict], list[dict]]] = {} diff --git a/service/src/main/inse/patents/patents_openalex_keywords/resolver.py b/service/src/main/inse/patents/patents_openalex_keywords/resolver.py index 8f7bfddc..4dc53a74 100644 --- a/service/src/main/inse/patents/patents_openalex_keywords/resolver.py +++ b/service/src/main/inse/patents/patents_openalex_keywords/resolver.py @@ -19,7 +19,10 @@ from inse.patents.patents_openalex_keywords.client import ( PatentsOpenAlexKeywordsClient, candidate_doc_ids, ) -from inse.patents.patents_openalex_keywords.ipc_entries import infer_subclass, normalize_symbol +from inse.patents.patents_openalex_keywords.ipc_entries import ( + infer_subclass, + normalize_symbol, +) logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/patents/patents_openalex_keywords/test_client.py b/service/src/main/inse/patents/patents_openalex_keywords/test_client.py index bdde354d..4ad73f63 100644 --- a/service/src/main/inse/patents/patents_openalex_keywords/test_client.py +++ b/service/src/main/inse/patents/patents_openalex_keywords/test_client.py @@ -4,10 +4,11 @@ import httpx import pytest from inse.patents.patents_openalex_keywords.client import ( - _MAX_SEARCH_WINDOW, PatentsOpenAlexKeywordsClient, ) -from inse.patents.patents_openalex_keywords.mapping import PATENTS_OPENALEX_KEYWORDS_INDEX +from inse.patents.patents_openalex_keywords.mapping import ( + PATENTS_OPENALEX_KEYWORDS_INDEX, +) @pytest.fixture diff --git a/service/src/main/inse/patents/patents_openalex_keywords/test_ipc_entries.py b/service/src/main/inse/patents/patents_openalex_keywords/test_ipc_entries.py index be6e3a5a..41ba1020 100644 --- a/service/src/main/inse/patents/patents_openalex_keywords/test_ipc_entries.py +++ b/service/src/main/inse/patents/patents_openalex_keywords/test_ipc_entries.py @@ -31,7 +31,7 @@ def _bucket(symbol: str, name_field: str, name: str) -> dict: async def test_fetch_unique_ipc_entries_includes_main_groups_from_cpc_subclass(): """H01M8/00 from cpc_subclass_* is stored as group with a non-empty label.""" - async def fake_search(*, index, body, cluster): # noqa: ANN001 + async def fake_search(*, index, body, cluster): sources = body.get("aggs", {}).get("items", {}).get("composite", {}).get( "sources", [] ) @@ -115,7 +115,7 @@ async def test_fetch_unique_ipc_entries_includes_main_groups_from_cpc_subclass() async def test_fetch_unique_ipc_entries_dedupes_normalized_group_symbols(): """Spaced and unspaced main-group variants collapse to one entry.""" - async def fake_search(*, index, body, cluster): # noqa: ANN001 + async def fake_search(*, index, body, cluster): sources = body.get("aggs", {}).get("items", {}).get("composite", {}).get( "sources", [] ) @@ -151,7 +151,7 @@ async def test_fetch_unique_ipc_entries_dedupes_normalized_group_symbols(): async def test_fetch_unique_ipc_entries_prefers_existing_group_over_subclass_field(): """cpc_group_* labels are not overwritten by cpc_subclass_*.""" - async def fake_search(*, index, body, cluster): # noqa: ANN001 + async def fake_search(*, index, body, cluster): sources = body.get("aggs", {}).get("items", {}).get("composite", {}).get( "sources", [] ) diff --git a/service/src/main/inse/patents/patents_openalex_keywords/test_matching.py b/service/src/main/inse/patents/patents_openalex_keywords/test_matching.py index 4b7c5051..c3d519a3 100644 --- a/service/src/main/inse/patents/patents_openalex_keywords/test_matching.py +++ b/service/src/main/inse/patents/patents_openalex_keywords/test_matching.py @@ -2,7 +2,6 @@ from __future__ import annotations import numpy as np -import pytest from inse.patents.patents_openalex_keywords.matching import ( EmbeddingMatcher, diff --git a/service/src/main/inse/patents/search_client.py b/service/src/main/inse/patents/search_client.py index 38feee9e..9cd833e0 100644 --- a/service/src/main/inse/patents/search_client.py +++ b/service/src/main/inse/patents/search_client.py @@ -21,7 +21,7 @@ class PatentSearchClient( __all__ = [ "DEFAULT_SEARCH_SIZE", "EPO_INDEX", + "USPTO_INDEX", "MissingApiKeyError", "PatentSearchClient", - "USPTO_INDEX", ] diff --git a/service/src/main/inse/patents/service.py b/service/src/main/inse/patents/service.py index 3cd2f6d8..92f487b2 100644 --- a/service/src/main/inse/patents/service.py +++ b/service/src/main/inse/patents/service.py @@ -1,5 +1,4 @@ """Aggregates patent API routers.""" -from fastapi import APIRouter from inse.patents.all.service import router as all_patents_router from inse.patents.authors.service import router as author_patents_router diff --git a/service/src/main/inse/patents/test_elastic_search_client.py b/service/src/main/inse/patents/test_elastic_search_client.py index 6403362c..e388f1c5 100644 --- a/service/src/main/inse/patents/test_elastic_search_client.py +++ b/service/src/main/inse/patents/test_elastic_search_client.py @@ -2,6 +2,7 @@ import json import httpx import pytest + from inse.model import ESIndex from inse.patents.elastic_search_client import ( DEFAULT_SEARCH_SIZE, diff --git a/service/src/main/inse/patents/test_ipc_model.py b/service/src/main/inse/patents/test_ipc_model.py index 5b942cba..9a352a6f 100644 --- a/service/src/main/inse/patents/test_ipc_model.py +++ b/service/src/main/inse/patents/test_ipc_model.py @@ -1,4 +1,3 @@ -import pytest from inse.patents import model diff --git a/service/src/main/inse/patents/test_ipc_search_client.py b/service/src/main/inse/patents/test_ipc_search_client.py index 4abc4a67..2b6a580e 100644 --- a/service/src/main/inse/patents/test_ipc_search_client.py +++ b/service/src/main/inse/patents/test_ipc_search_client.py @@ -1,4 +1,5 @@ from unittest.mock import AsyncMock, patch + import pytest from inse.patents.ipc_lookup import parse_ipc_symbol @@ -66,7 +67,7 @@ async def test_resolve_symbols_does_not_crash_for_subclass_codes(): async def test_resolve_symbols_main_group_from_cpc_subclass_field(): """H01M8/00 description comes from cpc_subclass_name (main-group storage).""" - async def fake_search(*, index, body, cluster): # noqa: ANN001 + async def fake_search(*, index, body, cluster): source_fields = body.get("_source") or [] if "cpc_subclass_number" in source_fields: return { @@ -130,7 +131,7 @@ async def test_resolve_symbols_main_group_from_cpc_subclass_field(): @pytest.mark.anyio async def test_resolve_symbols_keeps_subgroup_and_subclass_roles(): - async def fake_search(*, index, body, cluster): # noqa: ANN001 + async def fake_search(*, index, body, cluster): source_fields = body.get("_source") or [] if "cpc_subgroup_number" in source_fields: return { diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index da90c7f2..99ce3d54 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Business logic for persons / authors. """ @@ -9,7 +8,6 @@ import json import logging import time from datetime import datetime -from typing import List, Optional from pydantic import ValidationError @@ -28,7 +26,7 @@ from inse.persons.model import ( CareerMetrics, CustomAuthor, CustomAuthorsListResponse, - PersonBio + PersonBio, ) from inse.persons.query_builder import build_authors_search_rescored from inse.works.logic import enrich_topic_descriptions @@ -41,7 +39,7 @@ INDEX_NAME = "openalex-authors" UDE_INSTITUTION_ID = "https://openalex.org/I62318514" # Universität Duisburg-Essen -async def find_ude_author_by_name(display_name: str) -> Optional[dict]: +async def find_ude_author_by_name(display_name: str) -> dict | None: query = { "_source": ["display_name"], "query": { @@ -90,7 +88,7 @@ async def find_ude_author_by_name(display_name: str) -> Optional[dict]: "display_name": hit.get("_source", {}).get("display_name"), } -async def get_author_name_by_id(author_id: str) -> Optional[str]: +async def get_author_name_by_id(author_id: str) -> str | None: try: query = { "_source": ["id", "display_name"], @@ -106,10 +104,10 @@ async def get_author_name_by_id(author_id: str) -> Optional[str]: return None return hits[0].get("_source", {}).get("display_name") except Exception as e: - logger.exception(f"Error fetching author name for id {author_id}: {str(e)}") + logger.exception(f"Error fetching author name for id {author_id}: {e!s}") return None -async def get_author_name_with_alternatives_by_id(author_id: str) -> Optional[List[str]]: +async def get_author_name_with_alternatives_by_id(author_id: str) -> list[str] | None: try: query = { "_source": ["id", "display_name","display_name_alternatives"], @@ -127,12 +125,12 @@ async def get_author_name_with_alternatives_by_id(author_id: str) -> Optional[Li names.append(hits[0].get("_source", {}).get("display_name")) return names except Exception as e: - logger.exception(f"Error fetching author name for id {author_id}: {str(e)}") + logger.exception(f"Error fetching author name for id {author_id}: {e!s}") return None async def search_persons( - author_id: Optional[str] = None, - query: Optional[str] = None, + author_id: str | None = None, + query: str | None = None, ) -> AuthorsListResponse: if author_id: query_ = { @@ -222,7 +220,7 @@ async def count_authors_by_last_name(last_name: str) -> int: return await _count_authors(query) -async def _fetch_author_display_name(author_id: str) -> Optional[str]: +async def _fetch_author_display_name(author_id: str) -> str | None: query = { "query_string": { "default_field": "_id", @@ -446,7 +444,7 @@ def _build_papers(works: list) -> list: return papers -async def get_data_for_bio(author_id: str) -> Optional[dict]: +async def get_data_for_bio(author_id: str) -> dict | None: display_name = await _fetch_author_display_name(author_id) if display_name is None: return None @@ -463,7 +461,7 @@ async def get_data_for_bio(author_id: str) -> Optional[dict]: async def generate_person_bio( - author_id: str, include: Optional[set[str]] = None + author_id: str, include: set[str] | None = None ) -> str: start_time = time.time() author_data = await get_data_for_bio(author_id) @@ -503,7 +501,7 @@ async def generate_person_bio( async def get_person_by_id( - author_id: str, include: Optional[str] = None + author_id: str, include: str | None = None ) -> CustomAuthorsListResponse: source = include.split(",") if include else None @@ -535,9 +533,9 @@ async def get_person_by_id( async def search_persons_by_name( author_name: str, - limit: Optional[int] = 10, - page_offset: Optional[int] = 0, - include: Optional[str] = None, + limit: int | None = 10, + page_offset: int | None = 0, + include: str | None = None, ) -> AuthorsListResponse: if not author_name: raise BadRequestException("name must be provided") @@ -573,7 +571,7 @@ async def search_persons_by_name( ) except ElasticsearchException as e: - raise ElasticsearchException(f"Elasticsearch search failed: {str(e)}") from e + raise ElasticsearchException(f"Elasticsearch search failed: {e!s}") from e total_count = response.get("hits", {}).get("total", {}).get("value", 0) hits = response.get("hits", {}).get("hits", []) @@ -585,7 +583,7 @@ async def search_persons_by_name( async def search_persons_autocomplete( - author_name: str, limit: Optional[int] = 5, include: Optional[str] = None + author_name: str, limit: int | None = 5, include: str | None = None ) -> AuthorsListResponse: if not author_name: raise BadRequestException("name must be provided") @@ -623,7 +621,7 @@ async def search_persons_autocomplete( try: response = await elasticsearch.search(index="openalex-authors", body=body) except ElasticsearchException as e: - raise ElasticsearchException(f"Elasticsearch search failed: {str(e)}") from e + raise ElasticsearchException(f"Elasticsearch search failed: {e!s}") from e hits = response.get("hits", {}).get("hits", []) @@ -651,7 +649,7 @@ async def search_persons_autocomplete( return AuthorsListResponse(results=persons) -def _enrich_author_data(author_data) -> Optional[CustomAuthor]: +def _enrich_author_data(author_data) -> CustomAuthor | None: if not author_data: return None if not isinstance(author_data, dict): @@ -695,18 +693,18 @@ def _enrich_author_data(author_data) -> Optional[CustomAuthor]: async def advanced_search_persons( - query: Optional[str] = None, - institution_id: Optional[str] = None, - sort_by: Optional[str] = None, - sort_order: Optional[str] = None, - topics: Optional[List[str]] = None, + query: str | None = None, + institution_id: str | None = None, + sort_by: str | None = None, + sort_order: str | None = None, + topics: list[str] | None = None, page: int = 1, page_size: int = 10, - include: Optional[set[str]] = None, + include: set[str] | None = None, year_filter_enabled: bool = True, - filter_mode: Optional[str] = "from", - filter_year: Optional[int] = None, - filter_year_to: Optional[int] = None, + filter_mode: str | None = "from", + filter_year: int | None = None, + filter_year_to: int | None = None, ) -> CustomAuthorsListResponse: try: query_body = build_authors_search_rescored( @@ -734,7 +732,7 @@ async def advanced_search_persons( results=[], meta=Meta(count=0, page=page, per_page=page_size) ) except ElasticsearchException as e: - logger.error(f"Elasticsearch search failed: {str(e)}") + logger.error(f"Elasticsearch search failed: {e!s}") raise total_count = response_dict.get("hits", {}).get("total", {}).get("value", 0) hits = response_dict.get("hits", {}).get("hits", []) diff --git a/service/src/main/inse/persons/model.py b/service/src/main/inse/persons/model.py index 300ec2d9..220d5fb2 100644 --- a/service/src/main/inse/persons/model.py +++ b/service/src/main/inse/persons/model.py @@ -1,32 +1,31 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Data models for persons / authors. """ -from pydantic import BaseModel -from pydantic import Field -from typing import List, Optional -from inse.models.openalex.author import Author -from inse.models.openalex.meta import Meta -from inse.models.openalex.authors_list_response import AuthorsListResponse +from pydantic import BaseModel, Field + +from inse.models.openalex.author import Author +from inse.models.openalex.authors_list_response import AuthorsListResponse from inse.models.openalex.group_by_result import GroupByResult +from inse.models.openalex.meta import Meta + class CareerMetrics(BaseModel): - first_publication_year: Optional[int] = Field( + first_publication_year: int | None = Field( default=None, description="First publication year of the author." ) - last_publication_year: Optional[int] = Field( + last_publication_year: int | None = Field( default=None, description="Last publication year of the author." ) - career_age: Optional[int] = Field( + career_age: int | None = Field( default=None, description="Difference between last and first publication year." ) - career_span: Optional[int] = Field( + career_span: int | None = Field( default=None, description="Inclusive span from first to last publication year." ) - career_stage: Optional[str] = Field( + career_stage: str | None = Field( default=None, description="Threshold-based career stage derived from active publication years.", ) @@ -36,13 +35,13 @@ class CareerMetrics(BaseModel): publication_count: int = Field( default=0, description="Number of publications used for career metrics." ) - publications_per_active_year: Optional[float] = Field( + publications_per_active_year: float | None = Field( default=None, description="Average publications per active publication year." ) - publications_per_career_year: Optional[float] = Field( + publications_per_career_year: float | None = Field( default=None, description="Average publications per year over the full career span." ) - years_since_last_publication: Optional[int] = Field( + years_since_last_publication: int | None = Field( default=None, description="Years since the last publication." ) has_suspicious_publication_years: bool = Field( @@ -51,21 +50,21 @@ class CareerMetrics(BaseModel): class CustomAuthor(Author): - relevance_rating: Optional[str] = Field( + relevance_rating: str | None = Field( default=None, description="The relevance suitability rating." ) - career_metrics: Optional[CareerMetrics] = Field( + career_metrics: CareerMetrics | None = Field( default=None, description="Publication-history-based career metrics." ) class CustomAuthorsListResponse(AuthorsListResponse): - placeholder: Optional[CustomAuthor] = Field( + placeholder: CustomAuthor | None = Field( default=None, description="A placeholder field for generation." ) - results: Optional[List[CustomAuthor]] = None - meta: Optional[Meta] = None - group_by: Optional[List[GroupByResult]] = None + results: list[CustomAuthor] | None = None + meta: Meta | None = None + group_by: list[GroupByResult] | None = None class PersonBio(BaseModel): @@ -73,14 +72,14 @@ class PersonBio(BaseModel): class PersonFilters(BaseModel): - institution: Optional[str] = None - cited_by_count: Optional[int] = None + institution: str | None = None + cited_by_count: int | None = None # more filters class PersonSearchRequest(BaseModel): - name: Optional[str] = None + name: str | None = None filters: PersonFilters = PersonFilters() - include: Optional[str] = None - limit: Optional[int] = 10 - page_offset: Optional[int] = 0 + include: str | None = None + limit: int | None = 10 + page_offset: int | None = 0 diff --git a/service/src/main/inse/persons/query_builder.py b/service/src/main/inse/persons/query_builder.py index bd2b7288..0a34b4a1 100644 --- a/service/src/main/inse/persons/query_builder.py +++ b/service/src/main/inse/persons/query_builder.py @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Set +from typing import Any from inse.authors.institution_membership_query import ( build_institution_membership_query, @@ -8,20 +8,20 @@ from inse.authors.institution_membership_query import ( def build_authors_search_rescored( using: Any = None, - index: Optional[str] = None, - query: Optional[str] = None, - institution_id: Optional[str] = None, - sort_by: Optional[str] = None, - sort_order: Optional[str] = None, - topics: Optional[List[str]] = None, + index: str | None = None, + query: str | None = None, + institution_id: str | None = None, + sort_by: str | None = None, + sort_order: str | None = None, + topics: list[str] | None = None, page: int = 1, page_size: int = 10, - include: Optional[Set[str]] = None, + include: set[str] | None = None, year_filter_enabled: bool = True, - track_total_hits: Optional[bool] = False, - filter_mode: Optional[str] = "from", - filter_year: Optional[int] = None, - filter_year_to: Optional[int] = None, + track_total_hits: bool | None = False, + filter_mode: str | None = "from", + filter_year: int | None = None, + filter_year_to: int | None = None, name_quality_boost=True, h_index_boost=True, citations_boost=True, @@ -50,7 +50,7 @@ def build_authors_search_rescored( } # 2. Build Filters - filter_clauses: List[dict] = [] + filter_clauses: list[dict] = [] if institution_id: if year_filter_enabled: membership_mode = ( diff --git a/service/src/main/inse/persons/service.py b/service/src/main/inse/persons/service.py index f4cc3d57..3f66255c 100644 --- a/service/src/main/inse/persons/service.py +++ b/service/src/main/inse/persons/service.py @@ -1,21 +1,15 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for persons / authors. """ -from typing import Annotated, Literal, Optional +from typing import Annotated, Literal + +from fastapi import APIRouter, HTTPException, Path, Query, status -from fastapi import APIRouter -from fastapi import HTTPException -from fastapi import Path -from fastapi import Query -from fastapi import status -from typing import List -from . import logic -from . import model from inse.models.openalex.authors_list_response import AuthorsListResponse +from . import logic, model router = APIRouter( prefix="/api/inse-service", @@ -39,7 +33,7 @@ async def search_persons( str, Query(description="Search query (e.g., Arman AND Arzani)") ] = None, include: Annotated[ - Optional[str], + str | None, Query( description=( "Comma-separated include tags: topics_full, topic_share, summary_stats, ids, " @@ -69,7 +63,7 @@ async def generate_person_bio( str, Query(description="OpenAlex author ID (e.g., A5093075883)") ], include: Annotated[ - Optional[str], + str | None, Query( description=("Comma-separated list to include tags"), example="topics_full,topic_share", @@ -96,7 +90,7 @@ async def get_person_by_id( str, Path(description="OpenAlex author ID", examples=["A5093075883"]) ], include: Annotated[ - Optional[str], + str | None, Query( description=( "Which data do we require? include tags: topics_full, topic_share, summary_stats, ids, " @@ -119,7 +113,7 @@ async def get_person_by_id( async def search_persons_by_name( author_name: Annotated[str, Query(description="Authors name (e.g., Arman Arzani)")], include: Annotated[ - Optional[str], + str | None, Query( description=( "Which data do we require? include tags: topics_full, topic_share, summary_stats, ids, " @@ -128,8 +122,8 @@ async def search_persons_by_name( example="topics_full,topic_share", ), ], - limit:Annotated[Optional[int], Query(description=("Limit of search page results"),example ="2")]= None, - page_offset : Annotated[Optional[int], Query(description=("Offset of the result page"),example="2")] = None, + limit:Annotated[int | None, Query(description=("Limit of search page results"),example ="2")]= None, + page_offset : Annotated[int | None, Query(description=("Offset of the result page"),example="2")] = None, ): return await logic.search_persons_by_name(author_name=author_name, include=include, page_offset=page_offset, limit=limit) @@ -142,7 +136,7 @@ async def search_persons_by_name( tags=['Persons']) async def search_persons_autocomplete( author_name: Annotated[str, Query(description="Authors name (e.g., Arman Arzani)")], - include : Annotated[Optional[str], Query( + include : Annotated[str | None, Query( description=( "Which data do we require? include tags: topics_full, topic_share, summary_stats, ids, " "last_known_institutions, ..." @@ -162,20 +156,20 @@ async def search_persons_autocomplete( ) async def search_persons_list( query: Annotated[ - Optional[str], Query(description="Search query (e.g., Arman AND Arzani)") + str | None, Query(description="Search query (e.g., Arman AND Arzani)") ] = None, institution_id: Annotated[ - Optional[str], + str | None, Query(alias="institutionId", description="Filter by OpenAlex institution ID"), ] = None, sort_by: Annotated[ - Optional[str], Query(alias="sortBy", description="Value to sort by") + str | None, Query(alias="sortBy", description="Value to sort by") ] = None, sort_order: Annotated[ - Optional[str], Query(alias="sortOrder", description="asc or desc?") + str | None, Query(alias="sortOrder", description="asc or desc?") ] = None, topic: Annotated[ - Optional[List[str]], Query(description="Filter by topic display names") + list[str] | None, Query(description="Filter by topic display names") ] = None, page: Annotated[ int, Query(description="Page number (1-indexed)", ge=1) @@ -184,7 +178,7 @@ async def search_persons_list( int, Query(alias="pageSize", description="Results per page", ge=1, le=100) ] = 10, include: Annotated[ - Optional[str], + str | None, Query( description="Comma-separated include tags", example="topics_full,topic_share", @@ -198,14 +192,14 @@ async def search_persons_list( ), ] = True, filter_mode: Annotated[ - Optional[Literal["in", "from", "between"]], + Literal["in", "from", "between"] | None, Query(alias="filterMode", description="Affiliation year filter mode"), ] = "from", filter_year: Annotated[ - Optional[int], Query(alias="filterYear", description="Filter year") + int | None, Query(alias="filterYear", description="Filter year") ] = None, filter_year_to: Annotated[ - Optional[int], + int | None, Query(alias="filterYearTo", description="Upper filter year for 'between'"), ] = None, ): diff --git a/service/src/main/inse/projects/bund_institutions/model.py b/service/src/main/inse/projects/bund_institutions/model.py index 7a4099fe..20cab386 100644 --- a/service/src/main/inse/projects/bund_institutions/model.py +++ b/service/src/main/inse/projects/bund_institutions/model.py @@ -1,4 +1,3 @@ -from typing import Optional from inse.model import Page from pydantic import BaseModel @@ -12,14 +11,14 @@ class BundInstitutionSummary(BaseModel): so the same institution may appear multiple times (once per project). """ - department: Optional[str] = None - department_fullname: Optional[str] = None - name: Optional[str] = None - recepient: Optional[str] = None - municipality: Optional[str] = None - place: Optional[str] = None - state: Optional[str] = None - country: Optional[str] = None + department: str | None = None + department_fullname: str | None = None + name: str | None = None + recepient: str | None = None + municipality: str | None = None + place: str | None = None + state: str | None = None + country: str | None = None @classmethod def from_source(cls, source: dict) -> "BundInstitutionSummary": @@ -39,4 +38,3 @@ class BundInstitutionSummary(BaseModel): class BundInstitutionSummaryPage(Page[BundInstitutionSummary]): """A paginated response containing a list of institutions.""" - pass \ No newline at end of file diff --git a/service/src/main/inse/projects/bund_institutions/router.py b/service/src/main/inse/projects/bund_institutions/router.py index 51c2ae68..8c6924fa 100644 --- a/service/src/main/inse/projects/bund_institutions/router.py +++ b/service/src/main/inse/projects/bund_institutions/router.py @@ -2,10 +2,12 @@ import logging from typing import Annotated from fastapi import APIRouter, Query - from inse.projects.bund_institutions.model import BundInstitutionSummaryPage +from inse.projects.bund_institutions.service import ( + autocomplete_institutions_for_selector, + get_institutions_by_names, +) from inse.tags import Tags -from inse.projects.bund_institutions.service import autocomplete_institutions_for_selector, get_institutions_by_names logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/projects/bund_institutions/service.py b/service/src/main/inse/projects/bund_institutions/service.py index c550391e..73834884 100644 --- a/service/src/main/inse/projects/bund_institutions/service.py +++ b/service/src/main/inse/projects/bund_institutions/service.py @@ -1,11 +1,11 @@ import logging -from typing import Dict, List, Optional from inse.integrations import elasticsearch -from inse.model import ESIndex, ESCluster - -from inse.projects.bund_institutions.model import BundInstitutionSummary -from inse.projects.bund_institutions.model import BundInstitutionSummaryPage +from inse.model import ESCluster, ESIndex +from inse.projects.bund_institutions.model import ( + BundInstitutionSummary, + BundInstitutionSummaryPage, +) logger = logging.getLogger(__name__) @@ -26,10 +26,10 @@ _INSTITUTION_SOURCE_FIELDS = [ async def search_institutions( page: int = 0, size: int = 10, - query: Optional[Dict] = None, - source: Optional[List[str]] = None, - sort: Optional[List[Dict]] = None, - body: Optional[Dict] = None, + query: dict | None = None, + source: list[str] | None = None, + sort: list[dict] | None = None, + body: dict | None = None, ) -> BundInstitutionSummaryPage: """Searches for institutions in the BUND Projects Elasticsearch index based on the provided parameters. @@ -61,7 +61,7 @@ async def search_institutions( hits_block = response.get("hits", {}) hits = hits_block.get("hits", []) - institutions: List[BundInstitutionSummary] = [ + institutions: list[BundInstitutionSummary] = [ BundInstitutionSummary.from_source(hit.get("_source", {})) for hit in hits ] @@ -73,7 +73,7 @@ async def search_institutions( ) -async def get_institutions_by_names(institution_names: List[str]) -> BundInstitutionSummaryPage: +async def get_institutions_by_names(institution_names: list[str]) -> BundInstitutionSummaryPage: """Retrieves institutions based on a list of institution (Ausführende Stelle) names. Args: @@ -99,7 +99,7 @@ async def get_institutions_by_names(institution_names: List[str]) -> BundInstitu async def autocomplete_institutions( - query: str, page: int = 0, size: int = 10, source: Optional[List[str]] = None + query: str, page: int = 0, size: int = 10, source: list[str] | None = None ) -> BundInstitutionSummaryPage: """Autocompletes institutions based on a search term, matching against both the executing agency (Ausführende Stelle) and recipient (Zuwendungsempfänger) fields. diff --git a/service/src/main/inse/projects/dfg_institutions/model.py b/service/src/main/inse/projects/dfg_institutions/model.py index 32f18aec..f4042936 100644 --- a/service/src/main/inse/projects/dfg_institutions/model.py +++ b/service/src/main/inse/projects/dfg_institutions/model.py @@ -1,8 +1,9 @@ from inse.model import Page + #from inse.models.projects_dfg_v2.institute.dfg_institute import DFGInstitute from inse.projects.model import DfgInstitutionSummary + class DfgInstitutionSummaryPage(Page[DfgInstitutionSummary]): """A paginated response containing a list of institutions.""" - pass diff --git a/service/src/main/inse/projects/dfg_institutions/router.py b/service/src/main/inse/projects/dfg_institutions/router.py index a3e74631..a67dcfb0 100644 --- a/service/src/main/inse/projects/dfg_institutions/router.py +++ b/service/src/main/inse/projects/dfg_institutions/router.py @@ -2,10 +2,12 @@ import logging from typing import Annotated from fastapi import APIRouter, Query - from inse.projects.dfg_institutions.model import DfgInstitutionSummaryPage +from inse.projects.dfg_institutions.service import ( + autocomplete_institutions_for_selector, + get_institutions_by_ids, +) from inse.tags import Tags -from inse.projects.dfg_institutions.service import autocomplete_institutions_for_selector, get_institutions_by_ids logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/projects/dfg_institutions/service.py b/service/src/main/inse/projects/dfg_institutions/service.py index 71c687b0..d7f8e9e1 100644 --- a/service/src/main/inse/projects/dfg_institutions/service.py +++ b/service/src/main/inse/projects/dfg_institutions/service.py @@ -1,11 +1,11 @@ import logging -from typing import Dict, List, Optional from inse.integrations import elasticsearch -from inse.model import ESIndex, ESCluster +from inse.model import ESCluster, ESIndex +from inse.projects.dfg_institutions.model import DfgInstitutionSummaryPage + #from inse.models.projects_dfg_v2.institute.dfg_institute import DFGInstitute from inse.projects.model import DfgInstitutionSummary -from inse.projects.dfg_institutions.model import DfgInstitutionSummaryPage logger = logging.getLogger(__name__) @@ -13,10 +13,10 @@ logger = logging.getLogger(__name__) async def search_institutions( page: int = 0, size: int = 10, - query: Optional[Dict] = None, - source: Optional[List[str]] = None, - sort: Optional[List[Dict]] = None, - body: Optional[Dict] = None, + query: dict | None = None, + source: list[str] | None = None, + sort: list[dict] | None = None, + body: dict | None = None, ) -> DfgInstitutionSummaryPage: """Searches for institutions in the DFG Institutes Elasticsearch index based on the provided parameters. @@ -44,7 +44,7 @@ async def search_institutions( hits_block = response.get("hits", {}) hits = hits_block.get("hits", []) - institutions: List[DfgInstitutionSummary] = [] + institutions: list[DfgInstitutionSummary] = [] for hit in hits: _source = hit.get("_source", {}) # Handle nested institute object if present @@ -62,7 +62,7 @@ async def search_institutions( ) -async def get_institutions_by_ids(institution_ids: List[str]) -> DfgInstitutionSummaryPage: +async def get_institutions_by_ids(institution_ids: list[str]) -> DfgInstitutionSummaryPage: """Retrieves institutions based on a list of institution IDs. Args: @@ -98,7 +98,7 @@ async def get_institutions_by_ids(institution_ids: List[str]) -> DfgInstitutionS async def autocomplete_institutions( - query: str, page: int = 0, size: int = 10, source: Optional[List[str]] = None + query: str, page: int = 0, size: int = 10, source: list[str] | None = None ) -> DfgInstitutionSummaryPage: """Autocompletes institutions based on a search term. diff --git a/service/src/main/inse/projects/dfg_persons/model.py b/service/src/main/inse/projects/dfg_persons/model.py index 1acf1c6e..e221a975 100644 --- a/service/src/main/inse/projects/dfg_persons/model.py +++ b/service/src/main/inse/projects/dfg_persons/model.py @@ -1,8 +1,9 @@ from inse.model import Page + #from inse.models.projects_dfg_v2.institute.dfg_institute import DFGInstitute from inse.projects.model import DfgPersonSummary + class DfgPersonSummaryPage(Page[DfgPersonSummary]): """A paginated response containing a list of persons.""" - pass diff --git a/service/src/main/inse/projects/dfg_persons/router.py b/service/src/main/inse/projects/dfg_persons/router.py index a3f6f18f..a2e5b849 100644 --- a/service/src/main/inse/projects/dfg_persons/router.py +++ b/service/src/main/inse/projects/dfg_persons/router.py @@ -2,10 +2,12 @@ import logging from typing import Annotated from fastapi import APIRouter, Query - from inse.projects.dfg_persons.model import DfgPersonSummaryPage +from inse.projects.dfg_persons.service import ( + autocomplete_persons_for_selector, + get_persons_by_ids, +) from inse.tags import Tags -from inse.projects.dfg_persons.service import autocomplete_persons_for_selector, get_persons_by_ids logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/projects/dfg_persons/service.py b/service/src/main/inse/projects/dfg_persons/service.py index a0929cb7..3af9819c 100644 --- a/service/src/main/inse/projects/dfg_persons/service.py +++ b/service/src/main/inse/projects/dfg_persons/service.py @@ -1,10 +1,9 @@ import logging -from typing import Dict, List, Optional from inse.integrations import elasticsearch -from inse.model import ESIndex, ESCluster -from inse.projects.model import DfgPersonSummary, DfgInstitutionSummary -from inse.projects.dfg_persons.model import DfgPersonSummaryPage +from inse.model import ESCluster, ESIndex +from inse.projects.dfg_persons.model import DfgPersonSummaryPage +from inse.projects.model import DfgInstitutionSummary, DfgPersonSummary logger = logging.getLogger(__name__) @@ -12,10 +11,10 @@ logger = logging.getLogger(__name__) async def search_persons( page: int = 0, size: int = 10, - query: Optional[Dict] = None, - source: Optional[List[str]] = None, - sort: Optional[List[Dict]] = None, - body: Optional[Dict] = None, + query: dict | None = None, + source: list[str] | None = None, + sort: list[dict] | None = None, + body: dict | None = None, ) -> DfgPersonSummaryPage: """Searches for persons in the DFG Persons Elasticsearch index. @@ -44,7 +43,7 @@ async def search_persons( hits_block = response.get("hits", {}) hits = hits_block.get("hits", []) - persons: List[DfgPersonSummary] = [] + persons: list[DfgPersonSummary] = [] for hit in hits: _source = hit.get("_source", {}) @@ -109,7 +108,7 @@ async def search_persons( ) -async def get_persons_by_ids(person_ids: List[str]) -> DfgPersonSummaryPage: +async def get_persons_by_ids(person_ids: list[str]) -> DfgPersonSummaryPage: """Retrieves persons by their IDs. Args: @@ -150,7 +149,7 @@ async def autocomplete_persons( query: str, page: int = 0, size: int = 10, - source: Optional[List[str]] = None, + source: list[str] | None = None, ) -> DfgPersonSummaryPage: """Autocomplete persons based on full name or ORCID. diff --git a/service/src/main/inse/projects/eu_cordis_projects_client.py b/service/src/main/inse/projects/eu_cordis_projects_client.py index 473148a3..c0df87bb 100644 --- a/service/src/main/inse/projects/eu_cordis_projects_client.py +++ b/service/src/main/inse/projects/eu_cordis_projects_client.py @@ -1,62 +1,82 @@ -import logging import asyncio -from typing import Any, Dict, List, Optional, Union, Tuple, Set +import logging from collections import defaultdict +from typing import Any + +from inse.authors.v2.model import Author, AuthorPage +from inse.authors.v2.service import get_authors_by_ids from inse.config import get_settings from inse.integrations import elasticsearch from inse.model import ESCluster, ESIndex -from inse.authors.v2.model import AuthorPage,Author -from inse.authors.v2.service import get_authors_by_ids + # Import base models from inse.models.cordis_eu_project import CordisEuProject +from inse.models.openalex.topic import Topic +from inse.models.projects_eu_cordis.fp7.fp7_eurosci_voc import Fp7EurosciVoc +from inse.models.projects_eu_cordis.fp7.fp7_legal_basis import Fp7LegalBasis +from inse.models.projects_eu_cordis.fp7.fp7_organization import Fp7Organization # Import FP7 models from inse.models.projects_eu_cordis.fp7.fp7_project import Fp7Project -from inse.models.projects_eu_cordis.fp7.fp7_organization import Fp7Organization -from inse.models.projects_eu_cordis.fp7.fp7_publication import Fp7Publication +from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails from inse.models.projects_eu_cordis.fp7.fp7_project_ipr import Fp7ProjectIPR +from inse.models.projects_eu_cordis.fp7.fp7_publication import Fp7Publication from inse.models.projects_eu_cordis.fp7.fp7_report_summary import Fp7ReportSummary from inse.models.projects_eu_cordis.fp7.fp7_topic import Fp7Topic from inse.models.projects_eu_cordis.fp7.fp7_web_link import Fp7WebLink -from inse.models.projects_eu_cordis.fp7.fp7_eurosci_voc import Fp7EurosciVoc -from inse.models.projects_eu_cordis.fp7.fp7_legal_basis import Fp7LegalBasis -from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails +from inse.models.projects_eu_cordis.horizon2020.h2020_deliverable import ( + H2020Deliverable, +) +from inse.models.projects_eu_cordis.horizon2020.h2020_erc_pi import H2020ErcPI +from inse.models.projects_eu_cordis.horizon2020.h2020_eurosci_voc import H2020EurosciVoc +from inse.models.projects_eu_cordis.horizon2020.h2020_legal_basis import H2020LegalBasis +from inse.models.projects_eu_cordis.horizon2020.h2020_organization import ( + H2020Organization, +) # Import H2020 models from inse.models.projects_eu_cordis.horizon2020.h2020_project import H2020Project -from inse.models.projects_eu_cordis.horizon2020.h2020_organization import H2020Organization -from inse.models.projects_eu_cordis.horizon2020.h2020_publication import H2020Publication -from inse.models.projects_eu_cordis.horizon2020.h2020_deliverable import H2020Deliverable -from inse.models.projects_eu_cordis.horizon2020.h2020_report_summary import H2020ReportSummary +from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import ( + H2020ProjectDetails, +) +from inse.models.projects_eu_cordis.horizon2020.h2020_publication import ( + H2020Publication, +) +from inse.models.projects_eu_cordis.horizon2020.h2020_report_summary import ( + H2020ReportSummary, +) from inse.models.projects_eu_cordis.horizon2020.h2020_topic import H2020Topic from inse.models.projects_eu_cordis.horizon2020.h2020_web_link import H2020WebLink -from inse.models.projects_eu_cordis.horizon2020.h2020_eurosci_voc import H2020EurosciVoc -from inse.models.projects_eu_cordis.horizon2020.h2020_legal_basis import H2020LegalBasis -from inse.models.projects_eu_cordis.horizon2020.h2020_erc_pi import H2020ErcPI -from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails +from inse.models.projects_eu_cordis.horizon_europe.heu_deliverable import HEUDeliverable +from inse.models.projects_eu_cordis.horizon_europe.heu_eurosci_voc import HEUEurosciVoc +from inse.models.projects_eu_cordis.horizon_europe.heu_legal_basis import HEULegalBasis +from inse.models.projects_eu_cordis.horizon_europe.heu_organization import ( + HEUOrganization, +) # Import Horizon Europe models from inse.models.projects_eu_cordis.horizon_europe.heu_project import HEUProject -from inse.models.projects_eu_cordis.horizon_europe.heu_organization import HEUOrganization +from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import ( + HEUProjectDetails, +) from inse.models.projects_eu_cordis.horizon_europe.heu_publication import HEUPublication -from inse.models.projects_eu_cordis.horizon_europe.heu_deliverable import HEUDeliverable -from inse.models.projects_eu_cordis.horizon_europe.heu_report_summary import HEUReportSummary +from inse.models.projects_eu_cordis.horizon_europe.heu_report_summary import ( + HEUReportSummary, +) from inse.models.projects_eu_cordis.horizon_europe.heu_topic import HEUTopic from inse.models.projects_eu_cordis.horizon_europe.heu_web_link import HEUWebLink -from inse.models.projects_eu_cordis.horizon_europe.heu_eurosci_voc import HEUEurosciVoc -from inse.models.projects_eu_cordis.horizon_europe.heu_legal_basis import HEULegalBasis -from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails -from inse.projects.model import EuCordisProjectType, EuCordisProjectSummary +from inse.projects.logic import ( + get_eu_project_ids_by_openalex_topic_ids, + get_openalex_topics_for_eu_projects, +) from inse.projects.model import ( - EuCordisProjectType, + EuCordisEurosciVocSummary, + EuCordisOrganizationSummary, EuCordisProjectSearchPage, EuCordisProjectSummary, - EuCordisOrganizationSummary, + EuCordisProjectType, EuCordisTopicSummary, - EuCordisEurosciVocSummary, ) -from inse.projects.logic import get_eu_project_ids_by_openalex_topic_ids, get_openalex_topics_for_eu_projects -from inse.models.openalex.topic import Topic settings = get_settings() logger = logging.getLogger(__name__) @@ -98,7 +118,7 @@ _HEU_ENTITY_CONFIGS = [ ] async def get_enriched_cordis_project_by_id( project_id: str, -) -> Optional[Union[Fp7ProjectDetails, H2020ProjectDetails, HEUProjectDetails]]: +) -> Fp7ProjectDetails | H2020ProjectDetails | HEUProjectDetails | None: if not project_id: return None @@ -137,8 +157,8 @@ async def get_enriched_cordis_project_by_id( # helpers async def _fetch_openalex_author_data_for_project_ids( - project_ids: List[str], -) -> Tuple[Dict[str, AuthorPage], Dict[str, Dict[str, List[Author]]]]: + project_ids: list[str], +) -> tuple[dict[str, AuthorPage], dict[str, dict[str, list[Author]]]]: """ Single batched fetch that returns, per project_id: - an AuthorPage of all OpenAlex authors across all of the project's publications @@ -156,7 +176,7 @@ async def _fetch_openalex_author_data_for_project_ids( size=10000, ) - dois_by_project: Dict[str, Set[str]] = {} + dois_by_project: dict[str, set[str]] = {} for hit in response.get("hits", {}).get("hits", []): source = hit.get("_source", {}) pid = source.get("projectID") @@ -180,14 +200,14 @@ async def _fetch_openalex_author_data_for_project_ids( author_page = await get_authors_by_ids(author_ids=all_author_ids) authors_by_id = {author.id: author for author in author_page.elements} - author_page_by_project: Dict[str, AuthorPage] = {} - doi_author_map_by_project: Dict[str, Dict[str, List[Author]]] = {} + author_page_by_project: dict[str, AuthorPage] = {} + doi_author_map_by_project: dict[str, dict[str, list[Author]]] = {} for pid in project_ids: dois = dois_by_project.get(pid, set()) - doi_authors: Dict[str, List[Author]] = {} - project_author_ids: Set[str] = set() + doi_authors: dict[str, list[Author]] = {} + project_author_ids: set[str] = set() for doi in dois: ids_for_doi = author_ids_by_doi.get(doi, []) doi_authors[doi] = [authors_by_id[aid] for aid in ids_for_doi if aid in authors_by_id] @@ -207,8 +227,8 @@ async def _fetch_openalex_author_data_for_project_ids( async def get_openalex_authors_for_cordis_project_ids( - project_ids: List[str], -) -> Dict[str, AuthorPage]: + project_ids: list[str], +) -> dict[str, AuthorPage]: """Returns a mapping of project_id -> AuthorPage for a batch of projects.""" author_page_by_project, _ = await _fetch_openalex_author_data_for_project_ids(project_ids) return author_page_by_project @@ -217,7 +237,7 @@ async def get_openalex_authors_for_cordis_project_ids( async def _fetch_authors_and_topics_for_project( project_id: str, project_type: EuCordisProjectType, -) -> Tuple[Optional[AuthorPage], List[Topic], Dict[str, List[Author]]]: +) -> tuple[AuthorPage | None, list[Topic], dict[str, list[Author]]]: """Fetches OpenAlex authors (project-level + per-DOI map) and mapped topics for a single project.""" (author_page_by_project, doi_author_map_by_project), topics_lookup = await asyncio.gather( _fetch_openalex_author_data_for_project_ids([project_id]), @@ -241,9 +261,9 @@ async def _fetch_authors_and_topics_for_project( def _attach_authors_to_publications( - publications: List[Any], - doi_author_map: Dict[str, List[Author]], -) -> List[Any]: + publications: list[Any], + doi_author_map: dict[str, list[Author]], +) -> list[Any]: """Sets oa_authors on each publication by matching its doi/qaProcessedDoi against doi_author_map.""" for pub in publications: doi = getattr(pub, "doi", None) @@ -260,8 +280,8 @@ def _attach_authors_to_publications( async def _fetch_related_entities_parallel( project_id: str, - entity_configs: List[Dict[str, Any]], -) -> Dict[str, List[Any]]: + entity_configs: list[dict[str, Any]], +) -> dict[str, list[Any]]: """ Fetches all related entity types for a project in parallel. @@ -272,7 +292,7 @@ async def _fetch_related_entities_parallel( Returns: Dictionary mapping each config 'key' to a list of validated entities. """ - async def _fetch_one(config: Dict[str, Any]): + async def _fetch_one(config: dict[str, Any]): entities = await _fetch_related_entities( project_ids=[project_id], index_pattern=config["index_pattern"], @@ -283,7 +303,7 @@ async def _fetch_related_entities_parallel( tasks = [_fetch_one(cfg) for cfg in entity_configs] completed = await asyncio.gather(*tasks, return_exceptions=True) - results: Dict[str, List[Any]] = {} + results: dict[str, list[Any]] = {} for cfg, res in zip(entity_configs, completed): key = cfg["key"] if isinstance(res, Exception): @@ -297,10 +317,10 @@ async def _fetch_related_entities_parallel( async def _fetch_related_entities( - project_ids: List[str], + project_ids: list[str], index_pattern: str, model_class: Any, -) -> Dict[str, List[Any]]: +) -> dict[str, list[Any]]: """ Fetches and groups related entities from Elasticsearch by project ID. @@ -325,7 +345,7 @@ async def _fetch_related_entities( logger.warning(f"Failed to fetch from {index_pattern}: {e}") return {} - grouped: Dict[str, List[Any]] = {} + grouped: dict[str, list[Any]] = {} for hit in response.get("hits", {}).get("hits", []): source = hit.get("_source", {}) @@ -346,9 +366,9 @@ async def _fetch_related_entities( async def _enrich_fp7_project( project_id: str, - project_source: Dict[str, Any], + project_source: dict[str, Any], project_type: EuCordisProjectType, -) -> Optional[Fp7ProjectDetails]: +) -> Fp7ProjectDetails | None: """Enriches a single FP7 project with all related data.""" try: project = Fp7Project.model_validate(project_source) @@ -372,9 +392,9 @@ async def _enrich_fp7_project( async def _enrich_h2020_project( project_id: str, - project_source: Dict[str, Any], + project_source: dict[str, Any], project_type: EuCordisProjectType, -) -> Optional[H2020ProjectDetails]: +) -> H2020ProjectDetails | None: try: project = H2020Project.model_validate(project_source) except Exception as e: @@ -397,9 +417,9 @@ async def _enrich_h2020_project( async def _enrich_heu_project( project_id: str, - project_source: Dict[str, Any], + project_source: dict[str, Any], project_type: EuCordisProjectType, -) -> Optional[HEUProjectDetails]: +) -> HEUProjectDetails | None: try: project = HEUProject.model_validate(project_source) except Exception as e: @@ -422,8 +442,8 @@ async def _enrich_heu_project( def _eu_project_type_index_filter( - project_ids_by_type: Dict[EuCordisProjectType, List[str]], -) -> Optional[Dict[str, Any]]: + project_ids_by_type: dict[EuCordisProjectType, list[str]], +) -> dict[str, Any] | None: should_clauses = [] for project_type, project_ids in project_ids_by_type.items(): @@ -452,7 +472,7 @@ def _eu_project_type_index_filter( } -def _eu_year_filters(field: str, years: List[str]) -> Dict[str, Any]: +def _eu_year_filters(field: str, years: list[str]) -> dict[str, Any]: should = [] for year in years: @@ -492,10 +512,10 @@ def _eu_sort_field(sort_by: str) -> str: async def get_eu_project_ids_by_organization_filters( - project_types: List[EuCordisProjectType], - organization_ids: Optional[List[str]] = None, - organization_names: Optional[List[str]] = None, -) -> Dict[EuCordisProjectType, List[str]]: + project_types: list[EuCordisProjectType], + organization_ids: list[str] | None = None, + organization_names: list[str] | None = None, +) -> dict[EuCordisProjectType, list[str]]: """ Returns project IDs matching ALL selected organizations. If organization_ids=[A,B], a project must have both A and B. @@ -507,10 +527,10 @@ async def get_eu_project_ids_by_organization_filters( if not organization_ids and not organization_names: return {} - result: Dict[EuCordisProjectType, List[str]] = {} + result: dict[EuCordisProjectType, list[str]] = {} for project_type in project_types: - project_org_matches: Dict[str, Set[str]] = defaultdict(set) + project_org_matches: dict[str, set[str]] = defaultdict(set) should = [] @@ -582,9 +602,9 @@ async def get_eu_project_ids_by_organization_filters( return result async def get_eu_organizations_for_projects( - project_ids_by_type: Dict[EuCordisProjectType, List[str]], -) -> Dict[Tuple[EuCordisProjectType, str], List[EuCordisOrganizationSummary]]: - lookup: Dict[Tuple[EuCordisProjectType, str], List[EuCordisOrganizationSummary]] = {} + project_ids_by_type: dict[EuCordisProjectType, list[str]], +) -> dict[tuple[EuCordisProjectType, str], list[EuCordisOrganizationSummary]]: + lookup: dict[tuple[EuCordisProjectType, str], list[EuCordisOrganizationSummary]] = {} for project_type, project_ids in project_ids_by_type.items(): if not project_ids: @@ -633,9 +653,9 @@ async def get_eu_organizations_for_projects( async def get_eu_cordis_topics_for_projects( - project_ids_by_type: Dict[EuCordisProjectType, List[str]], -) -> Dict[Tuple[EuCordisProjectType, str], List[EuCordisTopicSummary]]: - lookup: Dict[Tuple[EuCordisProjectType, str], List[EuCordisTopicSummary]] = {} + project_ids_by_type: dict[EuCordisProjectType, list[str]], +) -> dict[tuple[EuCordisProjectType, str], list[EuCordisTopicSummary]]: + lookup: dict[tuple[EuCordisProjectType, str], list[EuCordisTopicSummary]] = {} for project_type, project_ids in project_ids_by_type.items(): if not project_ids: @@ -669,9 +689,9 @@ async def get_eu_cordis_topics_for_projects( async def get_eu_euroscivoc_for_projects( - project_ids_by_type: Dict[EuCordisProjectType, List[str]], -) -> Dict[Tuple[EuCordisProjectType, str], List[EuCordisEurosciVocSummary]]: - lookup: Dict[Tuple[EuCordisProjectType, str], List[EuCordisEurosciVocSummary]] = {} + project_ids_by_type: dict[EuCordisProjectType, list[str]], +) -> dict[tuple[EuCordisProjectType, str], list[EuCordisEurosciVocSummary]]: + lookup: dict[tuple[EuCordisProjectType, str], list[EuCordisEurosciVocSummary]] = {} for project_type, project_ids in project_ids_by_type.items(): if not project_ids: @@ -711,22 +731,22 @@ class _NoMatchingEuProjects(Exception): async def _build_eu_cordis_search_query( - project_types: Optional[List[EuCordisProjectType]] = None, - organization_ids: Optional[List[str]] = None, - organization_names: Optional[List[str]] = None, - author_project_ids: Optional[List[str]] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - title: Optional[str] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - framework_programmes: Optional[List[str]] = None, - funding_schemes: Optional[List[str]] = None, - statuses: Optional[List[str]] = None, + project_types: list[EuCordisProjectType] | None = None, + organization_ids: list[str] | None = None, + organization_names: list[str] | None = None, + author_project_ids: list[str] | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + title: str | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, + countries: list[str] | None = None, + framework_programmes: list[str] | None = None, + funding_schemes: list[str] | None = None, + statuses: list[str] | None = None, fuzzy: bool = False, -) -> Tuple[Dict[str, Any], List[EuCordisProjectType], List[Any]]: +) -> tuple[dict[str, Any], list[EuCordisProjectType], list[Any]]: """ Builds the (query, project_types, indices) tuple shared by every EU CORDIS project search/aggregation. Centralizing this means the filters applied to @@ -745,7 +765,7 @@ async def _build_eu_cordis_search_query( indices = [project_type.to_project_index() for project_type in project_types] - must_clauses: List[Dict[str, Any]] = [] + must_clauses: list[dict[str, Any]] = [] # === Author filter resolved in service layer === if author_project_ids is not None: @@ -868,7 +888,7 @@ async def _build_eu_cordis_search_query( # === Country filter requires organization lookup === if countries: - country_project_ids_by_type: Dict[EuCordisProjectType, List[str]] = {} + country_project_ids_by_type: dict[EuCordisProjectType, list[str]] = {} for project_type in project_types: response = await elasticsearch.search( @@ -907,20 +927,20 @@ async def _build_eu_cordis_search_query( async def search_eu_cordis_projects( page: int, size: int, - project_types: Optional[List[EuCordisProjectType]] = None, - organization_ids: Optional[List[str]] = None, - organization_names: Optional[List[str]] = None, - author_project_ids: Optional[List[str]] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - title: Optional[str] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - framework_programmes: Optional[List[str]] = None, - funding_schemes: Optional[List[str]] = None, - statuses: Optional[List[str]] = None, + project_types: list[EuCordisProjectType] | None = None, + organization_ids: list[str] | None = None, + organization_names: list[str] | None = None, + author_project_ids: list[str] | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + title: str | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, + countries: list[str] | None = None, + framework_programmes: list[str] | None = None, + funding_schemes: list[str] | None = None, + statuses: list[str] | None = None, sort_by: str = "title", sort_direction: str = "asc", fuzzy: bool = False, @@ -995,7 +1015,7 @@ async def search_eu_cordis_projects( hits = response.get("hits", {}).get("hits", []) total = response.get("hits", {}).get("total", {}).get("value", 0) - project_ids_by_type: Dict[EuCordisProjectType, List[str]] = defaultdict(list) + project_ids_by_type: dict[EuCordisProjectType, list[str]] = defaultdict(list) for hit in hits: project_type = EuCordisProjectType.from_index_name(hit.get("_index", "")) @@ -1008,7 +1028,7 @@ async def search_eu_cordis_projects( euroscivoc_lookup = await get_eu_euroscivoc_for_projects(project_ids_by_type) openalex_topics_lookup = await get_openalex_topics_for_eu_projects(project_ids_by_type) - elements: List[EuCordisProjectSummary] = [] + elements: list[EuCordisProjectSummary] = [] for hit in hits: source = hit.get("_source", {}) @@ -1045,22 +1065,22 @@ async def search_eu_cordis_projects( async def get_eu_cordis_projects_funding_data( - project_types: Optional[List[EuCordisProjectType]] = None, - organization_ids: Optional[List[str]] = None, - organization_names: Optional[List[str]] = None, - author_project_ids: Optional[List[str]] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - title: Optional[str] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - framework_programmes: Optional[List[str]] = None, - funding_schemes: Optional[List[str]] = None, - statuses: Optional[List[str]] = None, + project_types: list[EuCordisProjectType] | None = None, + organization_ids: list[str] | None = None, + organization_names: list[str] | None = None, + author_project_ids: list[str] | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + title: str | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, + countries: list[str] | None = None, + framework_programmes: list[str] | None = None, + funding_schemes: list[str] | None = None, + statuses: list[str] | None = None, fuzzy: bool = False, -) -> List[Dict[str, Any]]: +) -> list[dict[str, Any]]: """ Fetches ONLY the fields needed for a funding-over-time aggregation (id, startDate, endDate, ecMaxContribution) for every EU CORDIS project @@ -1094,12 +1114,12 @@ async def get_eu_cordis_projects_funding_data( except _NoMatchingEuProjects: return [] - results: List[Dict[str, Any]] = [] + results: list[dict[str, Any]] = [] page_size = 5000 - search_after: Optional[List[Any]] = None + search_after: list[Any] | None = None while True: - body: Dict[str, Any] = { + body: dict[str, Any] = { "size": page_size, "track_total_hits": False, "_source": ["id", "startDate", "endDate", "ecMaxContribution"], @@ -1152,7 +1172,7 @@ def _to_openalex_doi_url(raw_doi: str) -> str: return raw_doi return f"https://doi.org/{raw_doi}" -async def get_dois_by_cordis_eu_project_id(project_id: str) -> List[str]: +async def get_dois_by_cordis_eu_project_id(project_id: str) -> list[str]: """Retrieves the raw DOIs of publications associated with a given CORDIS EU project ID.""" query = {"bool": {"filter": [{"term": {"projectID": project_id}}]}} @@ -1175,8 +1195,8 @@ async def get_dois_by_cordis_eu_project_id(project_id: str) -> List[str]: return list(set(dois)) # Remove duplicates async def get_openalex_author_ids_by_dois( - dois: List[str], -) -> Dict[str, List[str]]: + dois: list[str], +) -> dict[str, list[str]]: """Retrieves the OpenAlex author IDs (full URL form) authoring works for each given (raw, non-prefixed) DOI. Returns a mapping of the *original raw DOI* (as passed in) -> list of author_ids, so callers can trace authors back to @@ -1210,7 +1230,7 @@ async def get_openalex_author_ids_by_dois( size=10000, cluster=ESCluster.NES, ) - result: Dict[str, List[str]] = {} + result: dict[str, list[str]] = {} for hit in response.get("hits", {}).get("hits", []): source = hit.get("_source", {}) doi_url = source.get("doi") @@ -1228,8 +1248,8 @@ async def get_openalex_author_ids_by_dois( async def get_openalex_authors_for_cordis_project_ids( - project_ids: List[str], -) -> Dict[str, AuthorPage]: + project_ids: list[str], +) -> dict[str, AuthorPage]: """Returns a mapping of project_id -> AuthorPage for a batch of projects.""" if not project_ids: return {} @@ -1242,7 +1262,7 @@ async def get_openalex_authors_for_cordis_project_ids( source=["projectID", "doi","qaProcessedDoi"], size=10000, ) - dois_by_project: Dict[str, Set[str]] = {} + dois_by_project: dict[str, set[str]] = {} for hit in response.get("hits", {}).get("hits", []): source = hit.get("_source", {}) pid = source.get("projectID") @@ -1261,9 +1281,9 @@ async def get_openalex_authors_for_cordis_project_ids( author_ids_by_doi = await get_openalex_author_ids_by_dois(dois=all_dois) # aggregate per project, dedupe author_ids within a project - author_ids_by_project: Dict[str, List[str]] = {} + author_ids_by_project: dict[str, list[str]] = {} for pid, dois in dois_by_project.items(): - project_author_ids: Set[str] = set() + project_author_ids: set[str] = set() for doi in dois: project_author_ids.update(author_ids_by_doi.get(doi, [])) author_ids_by_project[pid] = list(project_author_ids) @@ -1275,7 +1295,7 @@ async def get_openalex_authors_for_cordis_project_ids( authors_by_id = {author.id: author for author in author_page.elements} # split the fetched authors back out per project - result: Dict[str, AuthorPage] = {} + result: dict[str, AuthorPage] = {} for pid in project_ids: ids_for_project = author_ids_by_project.get(pid, []) authors_for_project = [ @@ -1291,8 +1311,8 @@ async def get_openalex_authors_for_cordis_project_ids( return result async def get_openalex_authors_for_projects_ids( - project_ids_by_type: Dict[EuCordisProjectType, List[str]], -) -> Dict[Tuple[EuCordisProjectType, str], AuthorPage]: + project_ids_by_type: dict[EuCordisProjectType, list[str]], +) -> dict[tuple[EuCordisProjectType, str], AuthorPage]: """Adapts get_openalex_authors_for_cordis_project_ids to the (project_type, project_id)-keyed lookup convention used across this module.""" all_project_ids = [ @@ -1307,7 +1327,7 @@ async def get_openalex_authors_for_projects_ids( project_ids=all_project_ids ) - result: Dict[Tuple[EuCordisProjectType, str], AuthorPage] = {} + result: dict[tuple[EuCordisProjectType, str], AuthorPage] = {} for project_type, project_ids in project_ids_by_type.items(): for pid in project_ids: result[(project_type, pid)] = author_pages_by_project_id.get( diff --git a/service/src/main/inse/projects/eu_organizations/router.py b/service/src/main/inse/projects/eu_organizations/router.py index 263587c4..26ed44bc 100644 --- a/service/src/main/inse/projects/eu_organizations/router.py +++ b/service/src/main/inse/projects/eu_organizations/router.py @@ -1,10 +1,11 @@ import logging -from typing import Annotated, List +from typing import Annotated from fastapi import APIRouter, Query - -from inse.projects.eu_organizations.service import autocomplete_organizations_for_selector, get_organizations_by_ids - +from inse.projects.eu_organizations.service import ( + autocomplete_organizations_for_selector, + get_organizations_by_ids, +) from inse.projects.model import EuCordisOrganizationSelectorPage from inse.tags import Tags @@ -23,7 +24,7 @@ router = APIRouter(prefix=EU_ORGANIZATIONS_PREFIX, tags=[Tags.PROJECTS]) ) async def get_eu_organizations_by_ids( organization_ids: Annotated[ - List[str], + list[str], Query(description="CORDIS organisation IDs to retrieve."), ] = [], ) -> EuCordisOrganizationSelectorPage: diff --git a/service/src/main/inse/projects/eu_organizations/service.py b/service/src/main/inse/projects/eu_organizations/service.py index 376cb592..24d76420 100644 --- a/service/src/main/inse/projects/eu_organizations/service.py +++ b/service/src/main/inse/projects/eu_organizations/service.py @@ -1,5 +1,4 @@ import logging -from typing import Dict, List, Optional from inse.integrations import elasticsearch from inse.model import ESCluster, ESIndex @@ -12,7 +11,7 @@ from inse.projects.model import ( logger = logging.getLogger(__name__) -def _project_type_from_org_index(index_name: str) -> Optional[EuCordisProjectType]: +def _project_type_from_org_index(index_name: str) -> EuCordisProjectType | None: if index_name == ESIndex.CORDIS_EU_FP7_ORGANIZATIONS.value: return EuCordisProjectType.FP7 if index_name == ESIndex.CORDIS_EU_HORIZON_2020_ORGANIZATIONS.value: @@ -23,7 +22,7 @@ def _project_type_from_org_index(index_name: str) -> Optional[EuCordisProjectTyp async def get_organizations_by_ids( - organization_ids: List[str], + organization_ids: list[str], ) -> EuCordisOrganizationSelectorPage: if not organization_ids: return EuCordisOrganizationSelectorPage(elements=[], total=0, page=0, size=0) @@ -52,7 +51,7 @@ async def get_organizations_by_ids( }, ) - elements: List[EuCordisOrganizationSelectorSummary] = [] + elements: list[EuCordisOrganizationSelectorSummary] = [] for hit in response.get("hits", {}).get("hits", []): source = hit.get("_source", {}) @@ -139,7 +138,7 @@ async def autocomplete_organizations_for_selector( }, ) - elements: List[EuCordisOrganizationSelectorSummary] = [] + elements: list[EuCordisOrganizationSelectorSummary] = [] for hit in response.get("hits", {}).get("hits", []): source = hit.get("_source", {}) diff --git a/service/src/main/inse/projects/logic.py b/service/src/main/inse/projects/logic.py index 9cf20a54..7a37ce66 100644 --- a/service/src/main/inse/projects/logic.py +++ b/service/src/main/inse/projects/logic.py @@ -1,8 +1,6 @@ -import json import logging -from typing import Any, Dict, List, Optional, Set, Tuple - from collections import defaultdict +from typing import Any from inse.integrations import elasticsearch from inse.model import ESCluster, ESIndex @@ -10,7 +8,7 @@ from inse.projects.model import EuCordisProjectType logger = logging.getLogger(__name__) -async def get_dfg_author_names_by_ids(author_ids: List[int]) -> Optional[List[str]]: +async def get_dfg_author_names_by_ids(author_ids: list[int]) -> list[str] | None: try: body = { "_source": ["id", "full_name"], @@ -25,10 +23,10 @@ async def get_dfg_author_names_by_ids(author_ids: List[int]) -> Optional[List[st return [] return [hit.get("_source", {}).get("full_name") for hit in hits] except Exception as e: - logger.exception(f"Error fetching author names for ids {author_ids}: {str(e)}") + logger.exception(f"Error fetching author names for ids {author_ids}: {e!s}") return [] -async def get_dfg_institution_names_by_ids(institution_ids: List[int]) -> Optional[List[str]]: +async def get_dfg_institution_names_by_ids(institution_ids: list[int]) -> list[str] | None: try: body = { "_source": ["id","institute_name_de","institute_name_en"], @@ -44,7 +42,7 @@ async def get_dfg_institution_names_by_ids(institution_ids: List[int]) -> Option return [] return [hit.get("_source", {}).get("institute_name_de") or hit.get("_source", {}).get("institute_name_en") for hit in hits] except Exception as e: - logger.exception(f"Error fetching institution names for ids {institution_ids}: {str(e)}") + logger.exception(f"Error fetching institution names for ids {institution_ids}: {e!s}") return [] async def get_institution_ids_by_institution_aliases(institution_aliases: list[str]) -> list[int]: @@ -117,7 +115,7 @@ async def get_person_ids_by_institution_ids( ) -async def get_bund_project_ids_by_topic_ids(topic_ids: List[str]) -> List[str]: +async def get_bund_project_ids_by_topic_ids(topic_ids: list[str]) -> list[str]: """ Query the `projects_bund_openalex_topics` index to find BUND project IDs that match any of the given OpenAlex topic IDs. @@ -127,7 +125,7 @@ async def get_bund_project_ids_by_topic_ids(topic_ids: List[str]) -> List[str]: required_topics = set(topic_ids) - project_topics: dict[str, Set[str]] = defaultdict(set) + project_topics: dict[str, set[str]] = defaultdict(set) page_size = 1000 from_ = 0 @@ -181,7 +179,7 @@ async def get_bund_project_ids_by_topic_ids(topic_ids: List[str]) -> List[str]: if required_topics.issubset(found_topics) ] -async def get_dfg_project_ids_by_topic_ids(topic_ids: List[str]) -> List[str]: +async def get_dfg_project_ids_by_topic_ids(topic_ids: list[str]) -> list[str]: """Fetches project IDs whose topic_matches contain EVERY given topic ID, even if the topics are distributed across multiple documents for the same project. """ @@ -190,7 +188,7 @@ async def get_dfg_project_ids_by_topic_ids(topic_ids: List[str]) -> List[str]: required_topics = set(topic_ids) - project_topics: dict[str, Set[str]] = defaultdict(set) + project_topics: dict[str, set[str]] = defaultdict(set) page_size = 1000 from_ = 0 @@ -246,7 +244,7 @@ async def get_dfg_project_ids_by_topic_ids(topic_ids: List[str]) -> List[str]: ] -async def get_openalex_topics_for_bund_projects(project_ids: List[str]) -> Dict[str, List[Dict]]: +async def get_openalex_topics_for_bund_projects(project_ids: list[str]) -> dict[str, list[dict]]: """ Retrieve OpenAlex topic details for a list of BUND project IDs. Returns a dict mapping `project_id` -> list of topic_match objects. @@ -254,7 +252,7 @@ async def get_openalex_topics_for_bund_projects(project_ids: List[str]) -> Dict[ if not project_ids: return {} - body: Dict[str, Any] = { + body: dict[str, Any] = { "size": 10000, "query": { "terms": { @@ -270,7 +268,7 @@ async def get_openalex_topics_for_bund_projects(project_ids: List[str]) -> Dict[ cluster=ESCluster.INSE ) - lookup: Dict[str, List[Dict]] = {} + lookup: dict[str, list[dict]] = {} for hit in response.get("hits", {}).get("hits", []): src = hit["_source"] pid = src.get("project_id") @@ -278,8 +276,8 @@ async def get_openalex_topics_for_bund_projects(project_ids: List[str]) -> Dict[ lookup[pid] = src.get("topic_matches", []) return lookup async def get_openalex_topics_for_dfg_projects( - project_ids: List[str], -) -> Dict[str, List[Dict]]: + project_ids: list[str], +) -> dict[str, list[dict]]: """ Retrieve OpenAlex topic details for a list of DFG project IDs. Returns a dict mapping `project_id` -> list of topic_match objects. @@ -287,7 +285,7 @@ async def get_openalex_topics_for_dfg_projects( if not project_ids: return {} - body: Dict[str, Any] = { + body: dict[str, Any] = { "size": 10000, "query": { "terms": { @@ -303,7 +301,7 @@ async def get_openalex_topics_for_dfg_projects( cluster=ESCluster.INSE ) - lookup: Dict[str, List[Dict]] = {} + lookup: dict[str, list[dict]] = {} for hit in response.get("hits", {}).get("hits", []): src = hit["_source"] pid = src.get("project_id") @@ -367,9 +365,9 @@ async def get_person_institutes( async def get_eu_project_ids_by_openalex_topic_ids( - project_types: List[EuCordisProjectType], - topic_ids: List[str], -) -> Dict[EuCordisProjectType, List[str]]: + project_types: list[EuCordisProjectType], + topic_ids: list[str], +) -> dict[EuCordisProjectType, list[str]]: """ Returns EU CORDIS project IDs whose mapped OpenAlex topic_matches contain EVERY given topic ID. Same semantics as DFG topic filtering. @@ -378,10 +376,10 @@ async def get_eu_project_ids_by_openalex_topic_ids( return {project_type: [] for project_type in project_types} required_topics = set(topic_ids) - result: Dict[EuCordisProjectType, List[str]] = {} + result: dict[EuCordisProjectType, list[str]] = {} for project_type in project_types: - project_topics: Dict[str, Set[str]] = defaultdict(set) + project_topics: dict[str, set[str]] = defaultdict(set) page_size = 1000 from_ = 0 @@ -438,12 +436,12 @@ async def get_eu_project_ids_by_openalex_topic_ids( async def get_openalex_topics_for_eu_projects( - project_ids_by_type: Dict[EuCordisProjectType, List[str]], -) -> Dict[Tuple[EuCordisProjectType, str], List[Dict[str, Any]]]: + project_ids_by_type: dict[EuCordisProjectType, list[str]], +) -> dict[tuple[EuCordisProjectType, str], list[dict[str, Any]]]: """ Fetches mapped OpenAlex topic matches for EU CORDIS projects. """ - topic_lookup: Dict[Tuple[EuCordisProjectType, str], List[Dict[str, Any]]] = {} + topic_lookup: dict[tuple[EuCordisProjectType, str], list[dict[str, Any]]] = {} for project_type, project_ids in project_ids_by_type.items(): if not project_ids: diff --git a/service/src/main/inse/projects/model.py b/service/src/main/inse/projects/model.py index 5e568242..64dbf6d5 100644 --- a/service/src/main/inse/projects/model.py +++ b/service/src/main/inse/projects/model.py @@ -1,21 +1,26 @@ -from datetime import date import datetime +from datetime import date from enum import StrEnum -from typing import List, Optional, Dict, Any - -from pydantic import BaseModel, Field, field_validator +from typing import Any +from inse.authors.v2.model import AuthorPage +from inse.model import ESIndex from inse.models.bund_project import BundProject from inse.models.eu_project import EuProject -from inse.model import ESIndex -from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails -from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails -from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails -from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import DFGProjectFachgebieteInner from inse.models.openalex.topic import Topic, TopicDomain, TopicField, TopicSubfield -from inse.authors.v2.model import AuthorPage +from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import ( + DFGProjectFachgebieteInner, +) +from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails +from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import ( + H2020ProjectDetails, +) +from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import ( + HEUProjectDetails, +) from inse.projects.bund_institutions.model import BundInstitutionSummary -from typing import Union +from pydantic import BaseModel, Field, field_validator + class ProjectType(StrEnum): BUND = "bund" @@ -70,13 +75,13 @@ class Page(BaseModel): total: int = Field(default=0, description="The total number of items.") class BundProjectSummary(BundProject): - oa_topics: Optional[list[Topic]] = Field( + oa_topics: list[Topic] | None = Field( default=None, validation_alias="oa_topics", description="The OpenAlex topics of the project", examples=[["Artificial Intelligence", "Machine Learning"]], ) - institution: Optional[BundInstitutionSummary] = Field( + institution: BundInstitutionSummary | None = Field( default=None, description="The executing agency / recipient institution for this project, " "derived from the project's own agency fields.", @@ -131,7 +136,7 @@ class BundProjectSummary(BundProject): ) @staticmethod - def _topic_from_match(match: Dict[str, Any]) -> Topic: + def _topic_from_match(match: dict[str, Any]) -> Topic: """Builds a Topic model from a flattened topic_match dict. Same logic as DfgProjectSummary._topic_from_match and EuCordisProjectSummary.topic_from_match @@ -154,7 +159,7 @@ class BundProjectSummary(BundProject): class BundProjectPage(Page): - elements: List[BundProjectSummary] = Field( + elements: list[BundProjectSummary] = Field( default_factory=list, description="The bund projects on this page." ) @@ -162,7 +167,7 @@ class BundProjectPage(Page): class BundProjectList(BaseModel): - elements: List[BundProjectSummary] = Field( + elements: list[BundProjectSummary] = Field( default_factory=list, description="All bund projects." ) total: int = Field(default=0, description="The total number of bund projects.") @@ -171,22 +176,22 @@ class BundProjectList(BaseModel): class DfgInstitutionSummary(BaseModel): """A summary of a DFG institution.""" id: int - institute_name_de: Optional[str] = None - institute_name_en: Optional[str] = None - root_id: Optional[int] = None - root_name_de: Optional[str] = None - root_name_en: Optional[str] = None - address_country_de: Optional[str] = None - address_country_en: Optional[str] = None + institute_name_de: str | None = None + institute_name_en: str | None = None + root_id: int | None = None + root_name_de: str | None = None + root_name_en: str | None = None + address_country_de: str | None = None + address_country_en: str | None = None class DfgPersonSummary(BaseModel): person_id: int - orcid_id: Optional[str] = None - project_ref_id: Optional[int] = None - full_name: Optional[str] = None - role_label_en: Optional[str] = None, - role_label_de: Optional[str] = None, - institution: Optional[DfgInstitutionSummary] = None + orcid_id: str | None = None + project_ref_id: int | None = None + full_name: str | None = None + role_label_en: str | None = None, + role_label_de: str | None = None, + institution: DfgInstitutionSummary | None = None @@ -195,49 +200,49 @@ class DfgProjectSummary(BaseModel): description="The unique identifier of the DFG project." ) - link: Optional[str] = Field( + link: str | None = Field( default=None, description="The link to the DFG project details." ) - title: Optional[str] = Field( + title: str | None = Field( default=None, description="The title of the DFG project." ) - professional_classification: Optional[str] = Field( + professional_classification: str | None = Field( default=None, description="The professional classification of the DFG project." ) - funding_start: Optional[str] = Field( + funding_start: str | None = Field( default=None, description="The funding start date of the DFG project." ) - funding_end: Optional[str] = Field( + funding_end: str | None = Field( default=None, description="The funding end date of the DFG project." ) - institutions: List[DfgInstitutionSummary] = Field( + institutions: list[DfgInstitutionSummary] = Field( default_factory=list, description="Institutions associated with the project." ) - names: List[str] = Field( + names: list[str] = Field( default_factory=list, description="The names of the persons involved in the DFG project.", ) - persons: List[DfgPersonSummary] = Field( + persons: list[DfgPersonSummary] = Field( default_factory=list, description="The persons involved in the DFG project.", ) - subject_classifications: Optional[List[DFGProjectFachgebieteInner]] = Field( + subject_classifications: list[DFGProjectFachgebieteInner] | None = Field( default=None, description="The subject classifications of the DFG project.", ) - topics: Optional[List[Topic]] = Field( + topics: list[Topic] | None = Field( default=None, description="The topics associated with the DFG project.", ) @@ -344,7 +349,7 @@ class DfgProjectSummary(BaseModel): topics=topics ) @staticmethod - def _topic_from_match(match: Dict[str, Any]) -> Topic: + def _topic_from_match(match: dict[str, Any]) -> Topic: """Builds a (partial) Topic model from a flattened topic_match dict coming from the `projects_dfg_openalex_topics` index. @@ -380,7 +385,7 @@ class DfgProjectSummary(BaseModel): ) class DfgProjectPage(Page): - elements: List[DfgProjectSummary] = Field( + elements: list[DfgProjectSummary] = Field( default_factory=list, description="The DFG projects on this page." ) @@ -403,10 +408,10 @@ class ProjectsFilteringProperties(BaseModel): project_type: ProjectType = Field(description="The type of projects to filter by.") page: int = Field(description="The page number for pagination.") size: int = Field(description="The page size for pagination.") - raw_oa_institution_id: Optional[str] = Field( + raw_oa_institution_id: str | None = Field( default=None, description="The raw OA institution ID to filter by." ) - query: Optional[str] = Field( + query: str | None = Field( default=None, description="The query string to filter projects by." ) sort_by: ProjectsSortBy = Field( @@ -422,15 +427,15 @@ class EuCordisProjectResponse(BaseModel): Response model for EU Cordis project endpoints. """ success: bool = Field(description="Indicates if the request was successful") - project_type: Optional[str] = Field( + project_type: str | None = Field( default=None, description="The type of project: 'fp7', 'h2020', or 'heu'" ) - eu_project_data: Optional[Union[Fp7ProjectDetails, H2020ProjectDetails, HEUProjectDetails]] = Field( + eu_project_data: Fp7ProjectDetails | H2020ProjectDetails | HEUProjectDetails | None = Field( default=None, description="The project data" ) - error: Optional[str] = Field( + error: str | None = Field( default=None, description="Error message if the request failed" ) @@ -442,17 +447,17 @@ class FundingProject(BaseModel): examples=[ProjectType.BUND, ProjectType.EU, ProjectType.DFG], ) id: str = Field(description="The unique identifier of the project.") - title: Optional[str] = Field(default=None, description="The title of the project.") - acronym: Optional[str] = Field( + title: str | None = Field(default=None, description="The title of the project.") + acronym: str | None = Field( default=None, description="The acronym of the project (if available)." ) - start_date: Optional[date] = Field( + start_date: date | None = Field( default=None, description="The funding start date of the project." ) - end_date: Optional[date] = Field( + end_date: date | None = Field( default=None, description="The funding end date of the project." ) - funding_amount: Optional[float] = Field( + funding_amount: float | None = Field( default=None, description="The total funding amount for the project." ) @@ -529,14 +534,14 @@ class FundingProject(BaseModel): class FundingProjectPage(Page): - elements: List[FundingProject] = Field( + elements: list[FundingProject] = Field( default_factory=list, description="The funding projects on this page." ) #EU CORDIS PROJECTS class EuProjectPage(Page): - elements: List[EuProject] = Field( + elements: list[EuProject] = Field( default_factory=list, description="The EU projects on this page." ) @@ -607,20 +612,20 @@ class EuCordisProjectType(StrEnum): class EuCordisOrganizationSummary(BaseModel): - id: Optional[str] = None - organisation_id: Optional[str] = None - name: Optional[str] = None - short_name: Optional[str] = None - country: Optional[str] = None - city: Optional[str] = None - role: Optional[str] = None - activity_type: Optional[str] = None - project_id: Optional[str] = None - ec_contribution: Optional[float] = None - total_cost: Optional[float] = None + id: str | None = None + organisation_id: str | None = None + name: str | None = None + short_name: str | None = None + country: str | None = None + city: str | None = None + role: str | None = None + activity_type: str | None = None + project_id: str | None = None + ec_contribution: float | None = None + total_cost: float | None = None @classmethod - def from_es_source(cls, source: Dict[str, Any]) -> "EuCordisOrganizationSummary": + def from_es_source(cls, source: dict[str, Any]) -> "EuCordisOrganizationSummary": return cls( id=source.get("id"), organisation_id=source.get("organisationID"), @@ -638,13 +643,13 @@ class EuCordisOrganizationSummary(BaseModel): class EuCordisTopicSummary(BaseModel): - id: Optional[str] = None - project_id: Optional[str] = None - title: Optional[str] = None - topic: Optional[str] = None + id: str | None = None + project_id: str | None = None + title: str | None = None + topic: str | None = None @classmethod - def from_es_source(cls, source: Dict[str, Any]) -> "EuCordisTopicSummary": + def from_es_source(cls, source: dict[str, Any]) -> "EuCordisTopicSummary": return cls( id=source.get("id"), project_id=source.get("projectID"), @@ -655,15 +660,15 @@ class EuCordisTopicSummary(BaseModel): class EuCordisEurosciVocSummary(BaseModel): - id: Optional[str] = None - project_id: Optional[str] = None - code: Optional[str] = None - title: Optional[str] = None - description: Optional[str] = None - path: Optional[str] = None + id: str | None = None + project_id: str | None = None + code: str | None = None + title: str | None = None + description: str | None = None + path: str | None = None @classmethod - def from_es_source(cls, source: Dict[str, Any]) -> "EuCordisEurosciVocSummary": + def from_es_source(cls, source: dict[str, Any]) -> "EuCordisEurosciVocSummary": return cls( id=source.get("id"), project_id=source.get("projectID"), @@ -678,35 +683,35 @@ class EuCordisProjectSummary(BaseModel): id: str project_type: EuCordisProjectType - title: Optional[str] = None - acronym: Optional[str] = None - objective: Optional[str] = None - keywords: Optional[str] = None + title: str | None = None + acronym: str | None = None + objective: str | None = None + keywords: str | None = None - framework_programme: Optional[str] = None - funding_scheme: Optional[str] = None - status: Optional[str] = None + framework_programme: str | None = None + funding_scheme: str | None = None + status: str | None = None - start_date: Optional[date] = None - end_date: Optional[date] = None + start_date: date | None = None + end_date: date | None = None - ec_max_contribution: Optional[float] = None - total_cost: Optional[float] = None - authors: Optional[AuthorPage] = None - organizations: List[EuCordisOrganizationSummary] = Field(default_factory=list) - cordis_topics: List[EuCordisTopicSummary] = Field(default_factory=list) - eurosci_voc: List[EuCordisEurosciVocSummary] = Field(default_factory=list) - topics: List[Topic] = Field(default_factory=list, description="Mapped OpenAlex topics.") + ec_max_contribution: float | None = None + total_cost: float | None = None + authors: AuthorPage | None = None + organizations: list[EuCordisOrganizationSummary] = Field(default_factory=list) + cordis_topics: list[EuCordisTopicSummary] = Field(default_factory=list) + eurosci_voc: list[EuCordisEurosciVocSummary] = Field(default_factory=list) + topics: list[Topic] = Field(default_factory=list, description="Mapped OpenAlex topics.") @classmethod def from_hit( cls, - hit: Dict[str, Any], - authors: Optional[AuthorPage] = None, - organizations: Optional[List[EuCordisOrganizationSummary]] = None, - cordis_topics: Optional[List[EuCordisTopicSummary]] = None, - eurosci_voc: Optional[List[EuCordisEurosciVocSummary]] = None, - topics: Optional[List[Topic]] = None, + hit: dict[str, Any], + authors: AuthorPage | None = None, + organizations: list[EuCordisOrganizationSummary] | None = None, + cordis_topics: list[EuCordisTopicSummary] | None = None, + eurosci_voc: list[EuCordisEurosciVocSummary] | None = None, + topics: list[Topic] | None = None, ) -> "EuCordisProjectSummary": source = hit.get("_source", {}) project_type = EuCordisProjectType.from_index_name(hit.get("_index", "")) @@ -738,7 +743,7 @@ class EuCordisProjectSummary(BaseModel): ) @staticmethod - def topic_from_match(match: Dict[str, Any]) -> Topic: + def topic_from_match(match: dict[str, Any]) -> Topic: domain_name = match.get("domain") field_name = match.get("field") subfield_name = match.get("subfield") @@ -757,26 +762,26 @@ class EuCordisProjectSummary(BaseModel): class EuCordisProjectSearchPage(Page): - elements: List[EuCordisProjectSummary] = Field( + elements: list[EuCordisProjectSummary] = Field( default_factory=list, description="The EU CORDIS project summaries on this page.", ) class EuCordisOrganizationSelectorSummary(BaseModel): - id: Optional[str] = None - organisation_id: Optional[str] = None - name: Optional[str] = None - short_name: Optional[str] = None - country: Optional[str] = None - city: Optional[str] = None - project_type: Optional[EuCordisProjectType] = None + id: str | None = None + organisation_id: str | None = None + name: str | None = None + short_name: str | None = None + country: str | None = None + city: str | None = None + project_type: EuCordisProjectType | None = None @classmethod def from_es_source( cls, - source: Dict[str, Any], - project_type: Optional[EuCordisProjectType] = None, + source: dict[str, Any], + project_type: EuCordisProjectType | None = None, ) -> "EuCordisOrganizationSelectorSummary": return cls( id=source.get("id"), @@ -791,4 +796,4 @@ class EuCordisOrganizationSelectorSummary(BaseModel): class EuCordisOrganizationSelectorPage(Page): - elements: List[EuCordisOrganizationSelectorSummary] = Field(default_factory=list) \ No newline at end of file + elements: list[EuCordisOrganizationSelectorSummary] = Field(default_factory=list) \ No newline at end of file diff --git a/service/src/main/inse/projects/projects_search_client.py b/service/src/main/inse/projects/projects_search_client.py index 82240cc1..b6b0a041 100644 --- a/service/src/main/inse/projects/projects_search_client.py +++ b/service/src/main/inse/projects/projects_search_client.py @@ -1,27 +1,33 @@ import json import logging -from typing import Any, Dict, List, Optional, Set - import urllib +from typing import Any + from inse.config import get_settings -from inse.models.bund_project import BundProject +from inse.integrations import elasticsearch +from inse.model import ESCluster, ESIndex +from inse.models.bund_project_details import BundProjectDetails +from inse.models.dfg_project_details import DfgProjectDetails +from inse.projects.logic import ( + get_bund_project_ids_by_topic_ids, + get_dfg_project_ids_by_topic_ids, + get_institution_ids_by_institution_aliases, + get_openalex_topics_for_bund_projects, + get_openalex_topics_for_dfg_projects, + get_person_ids_by_institution_ids, + get_person_institutes, +) from inse.projects.model import ( - BundProjectSummary, BundProjectPage, + BundProjectSummary, DfgProjectPage, DfgProjectSummary, FundingProject, FundingProjectPage, - ProjectType, ProjectsFilteringProperties, ProjectsSortBy, - SortDirection, + ProjectType, ) -from inse.models.dfg_project_details import DfgProjectDetails -from inse.models.bund_project_details import BundProjectDetails -from inse.integrations import elasticsearch -from inse.model import ESCluster, ESIndex -from inse.projects.logic import get_person_ids_by_institution_ids, get_dfg_project_ids_by_topic_ids,get_bund_project_ids_by_topic_ids, get_openalex_topics_for_dfg_projects, get_person_institutes, get_openalex_topics_for_bund_projects, get_institution_ids_by_institution_aliases settings = get_settings() @@ -34,7 +40,7 @@ logger.setLevel(settings.logging_level) async def search_bund_projects( filter_properties: ProjectsFilteringProperties, - institution_names: List[str] = [], + institution_names: list[str] = [], ) -> BundProjectPage: """Searches for Bund projects based on the provided filtering properties and institution names. @@ -46,7 +52,7 @@ async def search_bund_projects( BundProjectPage: The page of Bund projects that match the filtering criteria. """ - must_clauses: List[Dict[str, Any]] = [] + must_clauses: list[dict[str, Any]] = [] if len(institution_names) > 0: must_clauses.append( { @@ -79,7 +85,7 @@ async def search_bund_projects( } ) - query: Optional[Dict[str, Any]] = None + query: dict[str, Any] | None = None if must_clauses: query = {"bool": {"must": must_clauses}} @@ -106,7 +112,7 @@ async def search_bund_projects( def _complete_response_to_bund_project_page( - response: Dict[str, Any], page: int, size: int + response: dict[str, Any], page: int, size: int ) -> BundProjectPage: """Converts the raw Elasticsearch response into a BundProjectPage object. @@ -126,7 +132,7 @@ def _complete_response_to_bund_project_page( return BundProjectPage(elements=elements, total=total_hits, page=page, size=size) -async def get_bund_project_by_id(project_id: str) -> Optional[BundProjectDetails]: +async def get_bund_project_by_id(project_id: str) -> BundProjectDetails | None: """Decodes project_id and fetches the details of a single Bund project based on its project ID. Args: @@ -178,7 +184,7 @@ def _get_raw_doi(doi: str) -> str: return doi -async def get_cordis_eu_publications_by_dois(dois: List[str]): +async def get_cordis_eu_publications_by_dois(dois: list[str]): """Retrieves Cordis EU publications associated with the given list of DOIs. Args: @@ -225,7 +231,7 @@ async def get_cordis_eu_publications_by_dois(dois: List[str]): return response -async def get_cordis_eu_project_ids_by_dois(dois: List[str]) -> List[str]: +async def get_cordis_eu_project_ids_by_dois(dois: list[str]) -> list[str]: """Retrieves the project IDs of Cordis EU projects associated with the given list of DOIs. Args: @@ -247,7 +253,7 @@ async def get_cordis_eu_project_ids_by_dois(dois: List[str]) -> List[str]: # DFG -async def get_dfg_publications_by_dois(dois: List[str]): +async def get_dfg_publications_by_dois(dois: list[str]): """Retrieves DFG publications associated with the given list of DOIs. Args: @@ -294,7 +300,7 @@ async def get_dfg_publications_by_dois(dois: List[str]): return response -async def get_dfg_project_ids_by_names(names: List[str]) -> List[str]: +async def get_dfg_project_ids_by_names(names: list[str]) -> list[str]: query = { "bool": { "should": [ @@ -325,7 +331,7 @@ async def get_dfg_project_ids_by_names(names: List[str]) -> List[str]: } return list(project_ids) -async def get_dfg_project_ids_by_dois(dois: List[str]) -> List[str]: +async def get_dfg_project_ids_by_dois(dois: list[str]) -> list[str]: """Retrieves the project IDs of DFG projects associated with the given list of DOIs. Args: @@ -347,16 +353,16 @@ async def get_dfg_project_ids_by_dois(dois: List[str]) -> List[str]: async def search_dfg_projects( page: int, size: int, - institution_aliases: Optional[List[str]] = None, - project_ids: Optional[List[int]] = None, - institution_ids: Optional[List[int]] = [], - names: Optional[List[str]] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - title: Optional[str] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, + institution_aliases: list[str] | None = None, + project_ids: list[int] | None = None, + institution_ids: list[int] | None = [], + names: list[str] | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + title: str | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, sort_by: str = "id", sort_direction: str = "asc", fuzzy: bool = False, @@ -387,7 +393,7 @@ async def search_dfg_projects( """ from_ = page * size - body: Dict[str, Any] = { + body: dict[str, Any] = { "size": size, "from": from_, "track_total_hits": True, @@ -409,7 +415,7 @@ async def search_dfg_projects( "query": {}, } - must_clauses: List[Dict[str, Any]] = [] + must_clauses: list[dict[str, Any]] = [] if project_ids: must_clauses.append({"terms": {"id": project_ids}}) # === Primary search clause: mutually exclusive fuzzy(topic_ids) vs keyword phrase search === @@ -629,7 +635,7 @@ def _complete_response_to_dfg_project_page( return DfgProjectPage(elements=elements, total=total_hits, page=page, size=size) -async def get_dfg_project_by_id(project_id: str) -> Optional[DfgProjectDetails]: +async def get_dfg_project_by_id(project_id: str) -> DfgProjectDetails | None: """Fetches the details of a single DFG project based on its project ID. Args: @@ -657,7 +663,7 @@ async def get_dfg_project_by_id(project_id: str) -> Optional[DfgProjectDetails]: #BUND -def _bund_year_filters(field: str, years: List[str]) -> Dict[str, Any]: +def _bund_year_filters(field: str, years: list[str]) -> dict[str, Any]: should = [] for year in years: @@ -684,17 +690,17 @@ def _bund_year_filters(field: str, years: List[str]) -> Dict[str, Any]: } async def search_bund_projects_with_filters( - executing_agency: Optional[List[str]] = None, - oa_institution_aliases: Optional[List[str]] = None, - raw_oa_institution_id: Optional[str] = None, - funding_arts: Optional[List[str]] = None, # actually EuCordisProjectType, but treated as strings - title: Optional[str] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, - countries: Optional[List[str]] = None, + executing_agency: list[str] | None = None, + oa_institution_aliases: list[str] | None = None, + raw_oa_institution_id: str | None = None, + funding_arts: list[str] | None = None, # actually EuCordisProjectType, but treated as strings + title: str | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, + countries: list[str] | None = None, page: int = 0, size: int = 10, sort_by: str = "title", @@ -746,14 +752,14 @@ async def search_bund_projects_with_filters( "funding_end", ] - body: Dict[str, Any] = { + body: dict[str, Any] = { "size": size, "from": from_, "_source": source_fields, "query": {}, } - must_clauses: List[Dict[str, Any]] = [] + must_clauses: list[dict[str, Any]] = [] if oa_institution_aliases: must_clauses.append( { @@ -887,7 +893,7 @@ async def search_bund_projects_with_filters( async def search_all_projects( projects_filtering_properties: ProjectsFilteringProperties, - selected_project_types: Optional[Set[ProjectType]] = None, + selected_project_types: set[ProjectType] | None = None, ) -> FundingProjectPage: """Searches for projects across all project types based on the provided filtering properties and selected project types. @@ -1004,7 +1010,7 @@ async def search_all_projects( def _response_to_funding_project_page( - response: Dict[str, Any], page: int, size: int + response: dict[str, Any], page: int, size: int ) -> FundingProjectPage: """Converts the raw Elasticsearch response into a FundingProjectPage object. @@ -1022,7 +1028,7 @@ def _response_to_funding_project_page( return FundingProjectPage(elements=projects, total=total, page=page, size=size) -def _hit_to_funding_project(hit: Dict[str, Any]) -> FundingProject: +def _hit_to_funding_project(hit: dict[str, Any]) -> FundingProject: """Converts a single Elasticsearch hit into a FundingProject object based on the index it belongs to. Args: diff --git a/service/src/main/inse/projects/router.py b/service/src/main/inse/projects/router.py index 82d980c3..5c7c426f 100644 --- a/service/src/main/inse/projects/router.py +++ b/service/src/main/inse/projects/router.py @@ -1,33 +1,33 @@ import logging -from typing import Annotated, Optional, Set, List +from typing import Annotated from fastapi import APIRouter, Body, Depends, Path, Query, status - -from inse.projects.model import ( - BundProjectPage, - DfgProjectPage, - FundingProjectPage, - InstitutionFunderSummary, - ProjectType, - ProjectsFilteringProperties, - ProjectsSortBy, - SortDirection, - EuCordisProjectResponse -) -from inse.models.dfg_project_details import DfgProjectDetails -from inse.models.bund_project_details import BundProjectDetails -from inse.tags import Tags -from inse.projects import service as projects_service - from inse.institutions.institutions_search_client import ( InstitutionsSearchClient, ) from inse.institutions.router import get_institutions_search_client - -from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails -from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails +from inse.models.bund_project_details import BundProjectDetails +from inse.models.dfg_project_details import DfgProjectDetails from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails -from typing import Union +from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import ( + H2020ProjectDetails, +) +from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import ( + HEUProjectDetails, +) +from inse.projects import service as projects_service +from inse.projects.model import ( + BundProjectPage, + DfgProjectPage, + EuCordisProjectResponse, + FundingProjectPage, + InstitutionFunderSummary, + ProjectsFilteringProperties, + ProjectsSortBy, + ProjectType, + SortDirection, +) +from inse.tags import Tags logger = logging.getLogger(__name__) @@ -104,43 +104,43 @@ async def search_bund_projects( InstitutionsSearchClient, Depends(get_institutions_search_client) ], executing_agency: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Executing Agencies (Ausführende Stellen) to filter by."), ] = None, funding_arts: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Project types to include: fp7, h2020, heu."), ] = None, title: Annotated[ - Optional[str], + str | None, Query(description="Project title/acronym search."), ] = None, keywords: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Raw keywords to search in title/objective/keywords/topics."), ] = None, topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="OpenAlex topic IDs used for fuzzy topic resolution."), ] = None, filter_topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Additional OpenAlex topic IDs used as mandatory filters."), ] = None, funding_start_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding start years."), ] = None, funding_end_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding end years."), ] = None, countries: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Organization countries."), ] = None, raw_oa_institution_id: Annotated[ - Optional[str], + str | None, Query(description="The ID of the institution to filter by."), ] = None, page: Annotated[int, Query(description="The page number.", ge=0)] = 0, @@ -199,6 +199,8 @@ async def get_single_bund_project( ######## from inse.projects.model import EuCordisProjectSearchPage, EuCordisProjectType from inse.projects.service import search_eu_cordis_projects + + @router.get( "/eu/search", summary="Search EU CORDIS projects.", @@ -223,67 +225,67 @@ async def search_eu_cordis_projects_endpoint( InstitutionsSearchClient, Depends(get_institutions_search_client) ], raw_oa_institution_id: Annotated[ - Optional[str], + str | None, Query(description="OpenAlex institution ID to filter by."), ] = None, author_id: Annotated[ - Optional[str], + str | None, Query(description="OpenAlex author ID to filter by."), ] = None, author_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Additional OpenAlex author IDs to filter by. All selected authors must match."), ] = None, organization_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="CORDIS organisation IDs. All selected organizations must match."), ] = None, organization_names: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="CORDIS organization names. All selected organizations must match."), ] = None, project_types: Annotated[ - Optional[List[EuCordisProjectType]], + list[EuCordisProjectType] | None, Query(description="Project types to include: fp7, h2020, heu."), ] = None, title: Annotated[ - Optional[str], + str | None, Query(description="Project title/acronym search."), ] = None, keywords: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Raw keywords to search in title/objective/keywords/topics."), ] = None, topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="OpenAlex topic IDs used for fuzzy topic resolution."), ] = None, filter_topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Additional OpenAlex topic IDs used as mandatory filters."), ] = None, funding_start_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding start years."), ] = None, funding_end_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding end years."), ] = None, countries: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Organization countries."), ] = None, framework_programmes: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Framework programme filters."), ] = None, funding_schemes: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding scheme filters."), ] = None, statuses: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Project status filters."), ] = None, page: Annotated[int, Query(description="The page number.", ge=0)] = 0, @@ -423,12 +425,12 @@ async def get_single_eu_cordis_project( ) except Exception as e: - logger.error(f"Error retrieving project with ID {id}: {str(e)}", exc_info=True) + logger.error(f"Error retrieving project with ID {id}: {e!s}", exc_info=True) return EuCordisProjectResponse( success=False, project_type=None, eu_project_data=None, - error=f"Internal server error: {str(e)}" + error=f"Internal server error: {e!s}" ) @@ -455,42 +457,42 @@ async def get_institution_bund_projects_funding_over_time( InstitutionsSearchClient, Depends(get_institutions_search_client) ], raw_oa_institution_id: Annotated[ - Optional[str], Query(description="The institution ID to filter by.") + str | None, Query(description="The institution ID to filter by.") ] = None, executing_agency: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Executing Agencies (Ausführende Stellen) to filter by."), ] = None, funding_arts: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Project types to include: fp7, h2020, heu."), ] = None, title: Annotated[ - Optional[str], + str | None, Query(description="Project title/acronym search."), ] = None, keywords: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Raw keywords to search in title/objective/keywords/topics."), ] = None, topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="OpenAlex topic IDs used for fuzzy topic resolution."), ] = None, filter_topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Additional OpenAlex topic IDs used as mandatory filters."), ] = None, funding_start_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding start years."), ] = None, funding_end_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding end years."), ] = None, countries: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Organization countries."), ] = None, fuzzy: Annotated[ @@ -537,67 +539,67 @@ async def get_institution_cordis_eu_projects_funding_over_time( InstitutionsSearchClient, Depends(get_institutions_search_client) ], raw_oa_institution_id: Annotated[ - Optional[str], + str | None, Query(description="OpenAlex institution ID to filter by."), ] = None, author_id: Annotated[ - Optional[str], + str | None, Query(description="OpenAlex author ID to filter by."), ] = None, author_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Additional OpenAlex author IDs to filter by. All selected authors must match."), ] = None, organization_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="CORDIS organisation IDs. All selected organizations must match."), ] = None, organization_names: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="CORDIS organization names. All selected organizations must match."), ] = None, project_types: Annotated[ - Optional[List[EuCordisProjectType]], + list[EuCordisProjectType] | None, Query(description="Project types to include: fp7, h2020, heu."), ] = None, title: Annotated[ - Optional[str], + str | None, Query(description="Project title/acronym search."), ] = None, keywords: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Raw keywords to search in title/objective/keywords/topics."), ] = None, topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="OpenAlex topic IDs used for fuzzy topic resolution."), ] = None, filter_topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Additional OpenAlex topic IDs used as mandatory filters."), ] = None, funding_start_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding start years."), ] = None, funding_end_years: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding end years."), ] = None, countries: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Organization countries."), ] = None, framework_programmes: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Framework programme filters."), ] = None, funding_schemes: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Funding scheme filters."), ] = None, statuses: Annotated[ - Optional[List[str]], + list[str] | None, Query(description="Project status filters."), ] = None, fuzzy: Annotated[ @@ -646,31 +648,31 @@ async def get_dfg_projects( InstitutionsSearchClient, Depends(get_institutions_search_client) ], raw_oa_institution_id: Annotated[ - Optional[str], Query(description="The openalex institution ID to filter by.") + str | None, Query(description="The openalex institution ID to filter by.") ] = None, - author_id: Annotated[Optional[str], Query(description="The openalex author ID to filter by.")] = None, - author_filter_ids: Annotated[Optional[List[int]], Query(description="The dfg author IDs to filter by.")] = None, + author_id: Annotated[str | None, Query(description="The openalex author ID to filter by.")] = None, + author_filter_ids: Annotated[list[int] | None, Query(description="The dfg author IDs to filter by.")] = None, institution_ids: Annotated[ - Optional[List[int]], Query(description="The institution IDs to filter by.") + list[int] | None, Query(description="The institution IDs to filter by.") ] = None, title: Annotated[ - Optional[str], Query(description="The title to filter by.") + str | None, Query(description="The title to filter by.") ] = None, keywords: Annotated[ - Optional[List[str]], Query(description="Raw keywords to search in title/abstract/subject fields.") + list[str] | None, Query(description="Raw keywords to search in title/abstract/subject fields.") ] = None, topic_ids: Annotated[ - Optional[List[str]], Query(description="The openalex topic IDs to filter by.") + list[str] | None, Query(description="The openalex topic IDs to filter by.") ] = None, filter_topic_ids: Annotated[ - Optional[List[str]], + list[str] | None, Query( description="Additional topic IDs to merge into the fuzzy topic-id resolution " "(union with topic_ids). Only used when fuzzy=True." ), ] = None, - funding_start_years: Annotated[Optional[List[str]], Query(description="The funding start years to filter by.")] = None, - funding_end_years: Annotated[Optional[List[str]], Query(description="The funding end years to filter by.")] = None, + funding_start_years: Annotated[list[str] | None, Query(description="The funding start years to filter by.")] = None, + funding_end_years: Annotated[list[str] | None, Query(description="The funding end years to filter by.")] = None, page: Annotated[int, Query(description="The page number.", ge=0)] = 0, size: Annotated[int, Query(description="The page size.", ge=1)] = 20, @@ -740,13 +742,13 @@ async def search_projects( page: Annotated[int, Query(description="The page number.", ge=0)] = 0, size: Annotated[int, Query(description="The page size.", ge=1)] = 10, selected_project_types: Annotated[ - Optional[Set[ProjectType]], + set[ProjectType] | None, Query( description="The set of project types to filter by (e.g., 'bund', 'eu', 'dfg'). If not provided, projects of all types will be included." ), ] = None, title: Annotated[ - Optional[str], Query(description="The title to filter by.") + str | None, Query(description="The title to filter by.") ] = None, sort_by: Annotated[ ProjectsSortBy, Query(description="The field to sort by.") diff --git a/service/src/main/inse/projects/service.py b/service/src/main/inse/projects/service.py index 376ab2c0..4666c640 100644 --- a/service/src/main/inse/projects/service.py +++ b/service/src/main/inse/projects/service.py @@ -1,8 +1,34 @@ import datetime import logging -from typing import Any, Dict, List, Optional, Set +from typing import Any +from inse.exceptions import NotFoundException +from inse.institutions.institutions_search_client import ( + InstitutionsSearchClient, +) +from inse.models.bund_project_details import BundProjectDetails +from inse.models.dfg_project_details import DfgProjectDetails +from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails +from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import ( + H2020ProjectDetails, +) +from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import ( + HEUProjectDetails, +) +from inse.persons.logic import ( + get_author_name_with_alternatives_by_id, +) from inse.projects import projects_search_client +from inse.projects.eu_cordis_projects_client import ( + get_enriched_cordis_project_by_id, + get_eu_cordis_projects_funding_data, +) +from inse.projects.eu_cordis_projects_client import ( + search_eu_cordis_projects as _search_eu_cordis_projects_es, +) +from inse.projects.logic import ( + get_dfg_author_names_by_ids, +) from inse.projects.model import ( BundProjectPage, DfgProjectPage, @@ -10,29 +36,12 @@ from inse.projects.model import ( EuCordisProjectType, FundingProjectPage, InstitutionFunderSummary, - ProjectType, ProjectsFilteringProperties, ProjectsSortBy, + ProjectType, SortDirection, ) -from inse.models.dfg_project_details import DfgProjectDetails -from inse.models.bund_project_details import BundProjectDetails -from inse.institutions.institutions_search_client import ( - InstitutionsSearchClient, -) -from inse.exceptions import NotFoundException -from inse.persons.logic import get_author_name_by_id, get_author_name_with_alternatives_by_id -from inse.projects.logic import get_dfg_author_names_by_ids, get_dfg_institution_names_by_ids from inse.works.logic import get_publication_dois_of_author -from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails -from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails -from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails -from inse.projects.eu_cordis_projects_client import ( - get_enriched_cordis_project_by_id, - get_eu_cordis_projects_funding_data, - search_eu_cordis_projects as _search_eu_cordis_projects_es, -) -from typing import Union logger = logging.getLogger(__name__) @@ -42,8 +51,8 @@ async def search_all_projects( size: int, sort_by: ProjectsSortBy, sort_direction: SortDirection, - selected_project_types: Optional[Set[ProjectType]] = None, - title: Optional[str] = None, + selected_project_types: set[ProjectType] | None = None, + title: str | None = None, ) -> FundingProjectPage: return await projects_search_client.search_all_projects( projects_filtering_properties=ProjectsFilteringProperties( @@ -104,8 +113,8 @@ async def get_bund_projects_by_institution_id( async def _get_dfg_project_ids_for_openalex_authors( - author_ids: List[str], -) -> Optional[List[str]]: + author_ids: list[str], +) -> list[str] | None: """ Resolves OpenAlex authors to DFG project IDs via publication DOIs. @@ -116,7 +125,7 @@ async def _get_dfg_project_ids_for_openalex_authors( if not author_ids: return None - project_sets: List[Set[str]] = [] + project_sets: list[set[str]] = [] for author_id in author_ids: project_ids = [] @@ -150,16 +159,16 @@ async def _get_dfg_project_ids_for_openalex_authors( async def get_dfg_projects_by_author_id( institutions_search_client: InstitutionsSearchClient, - raw_oa_institution_id: Optional[str], - author_id: Optional[str], - author_filter_ids: Optional[List[int]], - institution_ids: Optional[List[int]], - keywords: Optional[List[str]], - topic_ids: Optional[List[str]], - filter_topic_ids: Optional[List[str]], - title: Optional[str], - funding_start_years: Optional[List[str]], - funding_end_years: Optional[List[str]], + raw_oa_institution_id: str | None, + author_id: str | None, + author_filter_ids: list[int] | None, + institution_ids: list[int] | None, + keywords: list[str] | None, + topic_ids: list[str] | None, + filter_topic_ids: list[str] | None, + title: str | None, + funding_start_years: list[str] | None, + funding_end_years: list[str] | None, page: int, size: int, sort_by: str = "topic", @@ -243,22 +252,22 @@ async def get_dfg_projects_by_author_id( async def get_institution_cordis_eu_projects_funding_over_time( institutions_search_client: InstitutionsSearchClient, - raw_oa_institution_id: Optional[str] = None, - project_types: Optional[List[EuCordisProjectType]] = None, - author_id: Optional[str] = None, - author_ids: Optional[List[str]] = None, - organization_ids: Optional[List[str]] = None, - organization_names: Optional[List[str]] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - title: Optional[str] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - framework_programmes: Optional[List[str]] = None, - funding_schemes: Optional[List[str]] = None, - statuses: Optional[List[str]] = None, + raw_oa_institution_id: str | None = None, + project_types: list[EuCordisProjectType] | None = None, + author_id: str | None = None, + author_ids: list[str] | None = None, + organization_ids: list[str] | None = None, + organization_names: list[str] | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + title: str | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, + countries: list[str] | None = None, + framework_programmes: list[str] | None = None, + funding_schemes: list[str] | None = None, + statuses: list[str] | None = None, fuzzy: bool = False, ) -> InstitutionFunderSummary: """ @@ -268,7 +277,7 @@ async def get_institution_cordis_eu_projects_funding_over_time( organization or topic enrichment - so this stays fast even when a filter combination matches many thousands of projects. """ - resolved_organization_names: List[str] = list(organization_names or []) + resolved_organization_names: list[str] = list(organization_names or []) if raw_oa_institution_id: institution_aliases = ( @@ -281,7 +290,7 @@ async def get_institution_cordis_eu_projects_funding_over_time( ) resolved_organization_names.extend(institution_aliases) - all_author_ids: List[str] = [] + all_author_ids: list[str] = [] if author_id: all_author_ids.append(author_id) all_author_ids.extend(author_ids or []) @@ -318,16 +327,16 @@ async def get_institution_cordis_eu_projects_funding_over_time( async def get_institution_bund_projects_funding_over_time( institutions_search_client: InstitutionsSearchClient, - raw_oa_institution_id: Optional[str] = None, - executing_agency: Optional[List[str]] = None, - funding_arts: Optional[List[str]] = None, - title: Optional[str] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, - countries: Optional[List[str]] = None, + raw_oa_institution_id: str | None = None, + executing_agency: list[str] | None = None, + funding_arts: list[str] | None = None, + title: str | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, + countries: list[str] | None = None, fuzzy: bool = False, ) -> InstitutionFunderSummary: """ @@ -360,7 +369,7 @@ async def get_institution_bund_projects_funding_over_time( page_size = 5000 page = 0 - funding_entries: List[Any] = [] + funding_entries: list[Any] = [] while True: response = await projects_search_client.search_bund_projects_with_filters( @@ -399,16 +408,16 @@ async def get_institution_bund_projects_funding_over_time( #Bund async def search_bund_projects_with_filters( institutions_search_client: InstitutionsSearchClient, - executing_agency: Optional[str], - raw_oa_institution_id: Optional[str], - title: Optional[str], - keywords: Optional[List[str]], - funding_arts: Optional[List[str]], - topic_ids: Optional[List[str]], - filter_topic_ids: Optional[List[str]], - funding_start_years: Optional[List[str]], - funding_end_years: Optional[List[str]], - countries: Optional[List[str]], + executing_agency: str | None, + raw_oa_institution_id: str | None, + title: str | None, + keywords: list[str] | None, + funding_arts: list[str] | None, + topic_ids: list[str] | None, + filter_topic_ids: list[str] | None, + funding_start_years: list[str] | None, + funding_end_years: list[str] | None, + countries: list[str] | None, page: int, size: int, sort_by: str = "title", @@ -450,14 +459,14 @@ async def search_bund_projects_with_filters( def _calculate_funding_over_time( project_type: ProjectType, - funding_entries: List[Any], + funding_entries: list[Any], ) -> InstitutionFunderSummary: """ funding_entries: list of (funding_start, funding_end, funding_amount) tuples. Each date value may be a date/datetime, an ISO date string, or None; amount may be numeric or None. """ - funding_per_year: Dict[int, float] = {} + funding_per_year: dict[int, float] = {} for funding_start, funding_end, funding_amount in funding_entries: if not funding_start or not funding_end or not funding_amount: @@ -499,7 +508,7 @@ def _calculate_funding_over_time( funding_per_year.get(year, 0.0) + proportional_share ) - sorted_funding_per_year: Dict[int, float] = {} + sorted_funding_per_year: dict[int, float] = {} if funding_per_year: min_year = min(funding_per_year.keys()) @@ -544,7 +553,7 @@ async def get_single_bund_project( async def get_single_eu_cordis_project( project_id: str, -) -> Optional[Union[Fp7ProjectDetails, H2020ProjectDetails, HEUProjectDetails]]: +) -> Fp7ProjectDetails | H2020ProjectDetails | HEUProjectDetails | None: logger.debug(f"Fetching single EU Cordis project for id={project_id}") project = await get_enriched_cordis_project_by_id(project_id) @@ -557,8 +566,8 @@ async def get_single_eu_cordis_project( async def _get_eu_project_ids_for_openalex_authors( - author_ids: List[str], -) -> Optional[List[str]]: + author_ids: list[str], +) -> list[str] | None: """ Resolves OpenAlex authors to CORDIS EU project IDs via publication DOIs. @@ -569,7 +578,7 @@ async def _get_eu_project_ids_for_openalex_authors( if not author_ids: return None - project_sets: List[Set[str]] = [] + project_sets: list[set[str]] = [] for author_id in author_ids: dois = await get_publication_dois_of_author(raw_oa_author_id=author_id) @@ -594,23 +603,23 @@ async def _get_eu_project_ids_for_openalex_authors( async def search_eu_cordis_projects( page: int, size: int, - project_types: Optional[List[EuCordisProjectType]] = None, - raw_oa_institution_id: Optional[str] = None, - institutions_search_client: Optional[InstitutionsSearchClient] = None, - author_id: Optional[str] = None, - author_ids: Optional[List[str]] = None, - organization_ids: Optional[List[str]] = None, - organization_names: Optional[List[str]] = None, - keywords: Optional[List[str]] = None, - topic_ids: Optional[List[str]] = None, - filter_topic_ids: Optional[List[str]] = None, - title: Optional[str] = None, - funding_start_years: Optional[List[str]] = None, - funding_end_years: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - framework_programmes: Optional[List[str]] = None, - funding_schemes: Optional[List[str]] = None, - statuses: Optional[List[str]] = None, + project_types: list[EuCordisProjectType] | None = None, + raw_oa_institution_id: str | None = None, + institutions_search_client: InstitutionsSearchClient | None = None, + author_id: str | None = None, + author_ids: list[str] | None = None, + organization_ids: list[str] | None = None, + organization_names: list[str] | None = None, + keywords: list[str] | None = None, + topic_ids: list[str] | None = None, + filter_topic_ids: list[str] | None = None, + title: str | None = None, + funding_start_years: list[str] | None = None, + funding_end_years: list[str] | None = None, + countries: list[str] | None = None, + framework_programmes: list[str] | None = None, + funding_schemes: list[str] | None = None, + statuses: list[str] | None = None, sort_by: str = "title", sort_direction: str = "asc", fuzzy: bool = False, @@ -629,7 +638,7 @@ async def search_eu_cordis_projects( funding scheme, status, funding years, country) are ANDed together as in eu_cordis_projects_client.search_eu_cordis_projects. """ - resolved_organization_names: List[str] = list(organization_names or []) + resolved_organization_names: list[str] = list(organization_names or []) if raw_oa_institution_id: if institutions_search_client is None: @@ -646,7 +655,7 @@ async def search_eu_cordis_projects( ) resolved_organization_names.extend(institution_aliases) - all_author_ids: List[str] = [] + all_author_ids: list[str] = [] if author_id: all_author_ids.append(author_id) diff --git a/service/src/main/inse/projects/test_eu_cordis_search_client.py b/service/src/main/inse/projects/test_eu_cordis_search_client.py index b9bc7aa1..342f383b 100644 --- a/service/src/main/inse/projects/test_eu_cordis_search_client.py +++ b/service/src/main/inse/projects/test_eu_cordis_search_client.py @@ -1,6 +1,7 @@ import pytest from inse.projects import eu_cordis_projects_client as eu_cordis_search_client + @pytest.mark.anyio async def test_search_eu_cordis_projects_by_title(): """Test searching EU CORDIS projects by title.""" diff --git a/service/src/main/inse/projects/test_projects_dfg.py b/service/src/main/inse/projects/test_projects_dfg.py index 24ffb9ef..f9eb82b9 100644 --- a/service/src/main/inse/projects/test_projects_dfg.py +++ b/service/src/main/inse/projects/test_projects_dfg.py @@ -1,6 +1,7 @@ import pytest from inse.projects import projects_search_client + @pytest.mark.anyio async def test_search_dfg_projects(): # Test search with name @@ -15,7 +16,7 @@ async def test_search_dfg_projects(): for element in res.elements: assert element.id is not None assert any( - all(part.lower() in name.lower() for part in "Bovensiepen".split()) + all(part.lower() in name.lower() for part in ["Bovensiepen"]) for name in element.names ) @@ -28,6 +29,6 @@ async def test_get_dfg_project_by_id(): assert project.id == known_id assert project.title_de is not None assert any( - all(part.lower() in person.full_name.lower() for part in "Wolfgang Ahrens".split()) + all(part.lower() in person.full_name.lower() for part in ["Wolfgang", "Ahrens"]) for person in project.persons ) diff --git a/service/src/main/inse/ranking/logic.py b/service/src/main/inse/ranking/logic.py index 67e23d7d..06cf19f0 100644 --- a/service/src/main/inse/ranking/logic.py +++ b/service/src/main/inse/ranking/logic.py @@ -1,11 +1,10 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + import asyncio import logging from dataclasses import dataclass from time import time -from typing import Any, List, Optional +from typing import Any import pandas as pd @@ -41,7 +40,7 @@ CANDIDATE_POOL_SIZE = 10000 INSTITUTION_AUTHOR_LIMIT = 20000 -async def _get_author_ids_from_institution(institution_id: str) -> List[str]: +async def _get_author_ids_from_institution(institution_id: str) -> list[str]: """Returns the IDs of active authors of the given institution. Uses the shared active-membership query and scrolls over the result set. @@ -108,7 +107,7 @@ def _keyword_clause(value: str, config: MatchConfig = _KEYWORD_MATCH) -> dict: def _build_keyword_query( - keywords: List[str], + keywords: list[str], operator: KeywordOperator, config: MatchConfig = _KEYWORD_MATCH, ) -> dict: @@ -136,7 +135,7 @@ def _build_keyword_query( } -def _author_filter(author_ids: List[str]) -> dict: +def _author_filter(author_ids: list[str]) -> dict: return { "nested": { @@ -149,11 +148,11 @@ def _author_filter(author_ids: List[str]) -> dict: def _topic_stats_query( - author_ids: List[str], - keywords: List[str], + author_ids: list[str], + keywords: list[str], operator: KeywordOperator, - publication_types: List[PublicationType], - timespan: Optional[Timespan], + publication_types: list[PublicationType], + timespan: Timespan | None, config: MatchConfig = _KEYWORD_MATCH, ) -> dict: """Builds a single query with all stats for Section 1""" @@ -325,7 +324,7 @@ def _topic_stats_query( } -def _max_h_index(citation_counts_desc: List[int]) -> int: +def _max_h_index(citation_counts_desc: list[int]) -> int: """The largest h such that h works have at least h citations each. Expects the counts sorted in descending order. @@ -340,13 +339,13 @@ def _max_h_index(citation_counts_desc: List[int]) -> int: async def topic_stats_for_authors( - author_ids: List[str], - keywords: List[str], + author_ids: list[str], + keywords: list[str], operator: KeywordOperator, - publication_types: List[PublicationType], - timespan: Optional[Timespan], + publication_types: list[PublicationType], + timespan: Timespan | None, filter_type: FilterType = FilterType.KEYWORD, -) -> List[AuthorTopicStats]: +) -> list[AuthorTopicStats]: if not author_ids: return [] @@ -423,11 +422,11 @@ async def topic_stats_for_authors( def _topic_profile_query( - author_ids: List[str], - keywords: List[str], + author_ids: list[str], + keywords: list[str], operator: KeywordOperator, - publication_types: List[PublicationType], - timespan: Optional[Timespan], + publication_types: list[PublicationType], + timespan: Timespan | None, config: MatchConfig = _KEYWORD_MATCH, ) -> dict: """Builds the Section 3 query""" @@ -511,13 +510,13 @@ def _topic_profile_query( async def topic_profile_for_authors( - author_ids: List[str], - keywords: List[str], + author_ids: list[str], + keywords: list[str], operator: KeywordOperator, - publication_types: List[PublicationType], - timespan: Optional[Timespan], + publication_types: list[PublicationType], + timespan: Timespan | None, filter_type: FilterType = FilterType.KEYWORD, -) -> List[AuthorTopicProfile]: +) -> list[AuthorTopicProfile]: if not author_ids: return [] @@ -568,7 +567,7 @@ async def topic_profile_for_authors( return results -async def _get_display_names_by_ids(author_ids: List[str]) -> dict: +async def _get_display_names_by_ids(author_ids: list[str]) -> dict: if not author_ids: return {} @@ -595,9 +594,9 @@ async def _get_display_names_by_ids(author_ids: List[str]) -> dict: async def static_stats_for_authors( - author_ids: List[str], + author_ids: list[str], company_status: CompanyStatusFilter = CompanyStatusFilter.ALL, -) -> List[AuthorStaticStats]: +) -> list[AuthorStaticStats]: """Section 2: per author, keyword-independent stats (companies, news, patents). Companies and news are matched by exact display name, patents by author id. """ @@ -631,7 +630,7 @@ async def static_stats_for_authors( return results -def _publication_type_filter(publication_types: List[PublicationType]) -> dict: +def _publication_type_filter(publication_types: list[PublicationType]) -> dict: """Keeps only works whose type is one of the given publication types.""" type_values = [] for publication_type in publication_types: @@ -652,11 +651,11 @@ def _timespan_filter(timespan: Timespan) -> dict: def _build_query( - keywords: List[str], + keywords: list[str], operator: KeywordOperator, - author_ids: List[str], - publication_types: List[PublicationType], - timespan: Optional[Timespan], + author_ids: list[str], + publication_types: list[PublicationType], + timespan: Timespan | None, config: MatchConfig = _KEYWORD_MATCH, ) -> dict: """Builds the Elasticsearch query that returns the raw stats per author.""" @@ -758,7 +757,7 @@ def _min_max_normalize(values: pd.Series) -> pd.Series: return (values - minimum) / (maximum - minimum) -def _apply_scores(authors: List[RankedAuthor], weights: RankingWeights) -> None: +def _apply_scores(authors: list[RankedAuthor], weights: RankingWeights) -> None: """Normalizes works, citations, company connections and news to [0, 1] and sets each author's weighted score.""" if not authors: return @@ -816,7 +815,7 @@ def _author_score(author: RankedAuthor) -> float: async def _enrich_with_company_counts( - authors: List[RankedAuthor], + authors: list[RankedAuthor], company_status: CompanyStatusFilter = CompanyStatusFilter.ALL, ) -> None: """Sets each author's company_count from a single bulk Handelsregister query. @@ -835,7 +834,7 @@ async def _enrich_with_company_counts( author.companies_count = counts.get(author.display_name, 0) -async def _get_news_counts_by_names(names: List[str]) -> dict: +async def _get_news_counts_by_names(names: list[str]) -> dict: """Returns a mapping ``display_name -> news count`` for the given author names. """ unique_names = sorted({name for name in names if name}) @@ -873,7 +872,7 @@ async def _get_news_counts_by_names(names: List[str]) -> dict: return {bucket.get("key", ""): bucket.get("doc_count", 0) for bucket in buckets} -async def _enrich_with_news_counts(authors: List[RankedAuthor]) -> None: +async def _enrich_with_news_counts(authors: list[RankedAuthor]) -> None: """Sets each author's news_count from a single bulk news query. Matching is by exact display name, so authors without a name match keep 0. """ @@ -888,7 +887,7 @@ async def _enrich_with_news_counts(authors: List[RankedAuthor]) -> None: author.news_count = counts.get(author.display_name, 0) -async def _get_patent_counts_by_author_ids(author_ids: List[str]) -> dict: +async def _get_patent_counts_by_author_ids(author_ids: list[str]) -> dict: short_to_full = {full.rsplit("/", 1)[-1]: full for full in author_ids} @@ -935,7 +934,7 @@ async def _get_patent_counts_by_author_ids(author_ids: List[str]) -> dict: return counts -async def _enrich_with_patent_counts(authors: List[RankedAuthor]) -> None: +async def _enrich_with_patent_counts(authors: list[RankedAuthor]) -> None: if not authors: return @@ -948,9 +947,9 @@ async def _enrich_with_patent_counts(authors: List[RankedAuthor]) -> None: async def _filter_author_ids_by_career_stage( - author_ids: List[str], - career_stages: List[CareerStage], -) -> List[str]: + author_ids: list[str], + career_stages: list[CareerStage], +) -> list[str]: """Filters the given author ids down to those whose career stage is in the list.""" if not author_ids or not career_stages: @@ -1006,16 +1005,16 @@ async def _filter_author_ids_by_career_stage( async def rank_authors_by_keywords( - keywords: List[str], + keywords: list[str], operator: KeywordOperator, institution_id: str, weights: RankingWeights, - career_stages: List[CareerStage], - publication_types: List[PublicationType], - timespan: Optional[Timespan], + career_stages: list[CareerStage], + publication_types: list[PublicationType], + timespan: Timespan | None, company_status: CompanyStatusFilter = CompanyStatusFilter.ALL, filter_type: FilterType = FilterType.KEYWORD, -) -> List[RankedAuthor]: +) -> list[RankedAuthor]: """Ranks the university's authors by a weighted score over works and citations. When career_stages is not empty, the ranked list is filtered down to diff --git a/service/src/main/inse/ranking/model.py b/service/src/main/inse/ranking/model.py index 686f98a4..918ce94a 100644 --- a/service/src/main/inse/ranking/model.py +++ b/service/src/main/inse/ranking/model.py @@ -1,10 +1,8 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Data models for author ranking. """ from enum import StrEnum -from typing import List, Optional from pydantic import BaseModel, Field, field_validator, model_validator @@ -101,7 +99,7 @@ class RankingWeights(BaseModel): class KeywordToAuthorRequest(BaseModel): - keywords: List[str] = Field( + keywords: list[str] = Field( min_length=1, description="One or more keywords to rank the author by.", ) @@ -117,15 +115,15 @@ class KeywordToAuthorRequest(BaseModel): weights: RankingWeights = Field( description="Weights for the ranking metrics. Required.", ) - career_stages: List[CareerStage] = Field( + career_stages: list[CareerStage] = Field( default_factory=list, description="Optional filter: only keep authors in one of these career stages. Empty = no filter.", ) - publication_types: List[PublicationType] = Field( + publication_types: list[PublicationType] = Field( default_factory=list, description="Optional filter: only count works of these publication types. Empty = no filter.", ) - timespan: Optional[Timespan] = Field( + timespan: Timespan | None = Field( default=None, description="Optional filter: only count works whose publication_year is within [from, to].", ) @@ -144,11 +142,11 @@ class KeywordToAuthorRequest(BaseModel): class SelectedAuthorsRequest(BaseModel): - author_ids: List[str] = Field( + author_ids: list[str] = Field( min_length=1, description="OpenAlex IDs of the authors to rank.", ) - keywords: List[str] = Field( + keywords: list[str] = Field( min_length=1, description="One or more keywords defining the topic.", ) @@ -161,11 +159,11 @@ class SelectedAuthorsRequest(BaseModel): description="What the 'keywords' values match against: 'keyword' (OpenAlex " "keyword display names) or 'topic' (OpenAlex topic ids). Defaults to 'keyword'.", ) - publication_types: List[PublicationType] = Field( + publication_types: list[PublicationType] = Field( default_factory=list, description="Optional filter: only count works of these publication types. Empty = no filter.", ) - timespan: Optional[Timespan] = Field( + timespan: Timespan | None = Field( default=None, description="Optional filter: only count works whose publication_year is within [from, to].", ) @@ -186,7 +184,7 @@ class SelectedAuthorsRequest(BaseModel): class AuthorMetricsRequest(BaseModel): - author_ids: List[str] = Field( + author_ids: list[str] = Field( min_length=1, description="OpenAlex IDs of the authors.", ) @@ -248,11 +246,11 @@ class AuthorTopicStats(BaseModel): description="Number of the author's topic works with at least one co-author " "institution of type 'company'.", ) - first_year: Optional[int] = Field( + first_year: int | None = Field( default=None, description="Earliest publication year among the author's topic works.", ) - last_year: Optional[int] = Field( + last_year: int | None = Field( default=None, description="Latest publication year among the author's topic works.", ) @@ -306,7 +304,7 @@ class AuthorTopicProfile(BaseModel): distinct_fields: int = Field( description="Number of distinct primary-topic fields across all works.", ) - subfields: List[SubfieldShare] = Field( + subfields: list[SubfieldShare] = Field( default_factory=list, description="Top subfields over all works, by primary topic, largest first.", ) diff --git a/service/src/main/inse/ranking/orientation_profile_logic.py b/service/src/main/inse/ranking/orientation_profile_logic.py index d8a8c89c..1a7b9558 100644 --- a/service/src/main/inse/ranking/orientation_profile_logic.py +++ b/service/src/main/inse/ranking/orientation_profile_logic.py @@ -1,4 +1,4 @@ -from decimal import Decimal, ROUND_HALF_UP +from decimal import ROUND_HALF_UP, Decimal from typing import Any from inse.authors.v2.service import authors_currently_belong_to_institution @@ -12,7 +12,6 @@ from .orientation_profile_model import ( AuthorOrientationProfileStatus, ) - _SCORE_FIELD = "classification.applied_orientation_score" _PRIMARY_CATEGORY_VALUES = { category.value for category in WorkPrimaryCategory @@ -129,7 +128,7 @@ def _orientation_profile_query( def _rounded_score(value: float) -> int: - return int(Decimal(str(value)).quantize(Decimal("1"), rounding=ROUND_HALF_UP)) + return int(Decimal(str(value)).quantize(Decimal(1), rounding=ROUND_HALF_UP)) def _profile_from_bucket( diff --git a/service/src/main/inse/ranking/router.py b/service/src/main/inse/ranking/router.py index 0efae134..cb645d5a 100644 --- a/service/src/main/inse/ranking/router.py +++ b/service/src/main/inse/ranking/router.py @@ -1,17 +1,13 @@ import logging -from typing import Annotated, List +from typing import Annotated from fastapi import APIRouter, HTTPException, status from inse.auth.model import AccessTokenMetadata from inse.auth.service import CurrentUserAccessTokenPayloadDep from inse.tags import Tags + from . import logic -from .orientation_profile_logic import orientation_profiles_for_authors -from .orientation_profile_model import ( - AuthorOrientationProfile, - AuthorOrientationProfilesRequest, -) from .model import ( AuthorMetricsRequest, AuthorStaticStats, @@ -21,6 +17,11 @@ from .model import ( RankedAuthor, SelectedAuthorsRequest, ) +from .orientation_profile_logic import orientation_profiles_for_authors +from .orientation_profile_model import ( + AuthorOrientationProfile, + AuthorOrientationProfilesRequest, +) logger = logging.getLogger(__name__) @@ -30,7 +31,7 @@ router = APIRouter( ) # Author ranking -@router.post("/rank-author", response_model=List[RankedAuthor]) +@router.post("/rank-author", response_model=list[RankedAuthor]) async def rank_author( request: KeywordToAuthorRequest, access_token_metadata: Annotated[ @@ -68,7 +69,7 @@ async def rank_author( ) # Compare authors table 1 (topic stats) -@router.post("/topic-stats", response_model=List[AuthorTopicStats]) +@router.post("/topic-stats", response_model=list[AuthorTopicStats]) async def topic_stats(request: SelectedAuthorsRequest): logger.info( "topic-stats author_ids=%s keywords=%s operator=%s filter_type=%s publication_types=%s timespan=%s", @@ -89,7 +90,7 @@ async def topic_stats(request: SelectedAuthorsRequest): ) # Compare authors section 3 (topic profile over ALL works of each author) -@router.post("/topic-profile", response_model=List[AuthorTopicProfile]) +@router.post("/topic-profile", response_model=list[AuthorTopicProfile]) async def topic_profile(request: SelectedAuthorsRequest): logger.info( "topic-profile author_ids=%s keywords=%s operator=%s filter_type=%s " @@ -111,7 +112,7 @@ async def topic_profile(request: SelectedAuthorsRequest): ) # Compare authors table 2 (author-level stats, keyword/time-independent) -@router.post("/static-stats", response_model=List[AuthorStaticStats]) +@router.post("/static-stats", response_model=list[AuthorStaticStats]) async def static_stats(request: AuthorMetricsRequest): logger.info( "static-stats author_ids=%s company_status=%s", @@ -126,7 +127,7 @@ async def static_stats(request: AuthorMetricsRequest): @router.post( "/orientation-profiles", - response_model=List[AuthorOrientationProfile], + response_model=list[AuthorOrientationProfile], ) async def orientation_profiles( request: AuthorOrientationProfilesRequest, diff --git a/service/src/main/inse/service.py b/service/src/main/inse/service.py index 4e4a6593..0702fe30 100644 --- a/service/src/main/inse/service.py +++ b/service/src/main/inse/service.py @@ -1,20 +1,18 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ This module contains the rest api of the service. """ import logging -from typing import Annotated, List -from fastapi import Query -from inse.config import get_settings -from fastapi import APIRouter +from typing import Annotated +from fastapi import APIRouter, Query + +from inse.config import get_settings from . import logic - logger = logging.getLogger(__name__) ### startup @@ -57,7 +55,7 @@ def build_topic_cache( ) def count_topic_hierarchy( topic_names: Annotated[ - List[str], + list[str], Query( alias="topic", description="Topic names (repeat parameter).", diff --git a/service/src/main/inse/test_service.py b/service/src/main/inse/test_service.py index 30c00152..b9c6b742 100644 --- a/service/src/main/inse/test_service.py +++ b/service/src/main/inse/test_service.py @@ -1,8 +1,8 @@ + from fastapi.testclient import TestClient -from fastapi import HTTPException + from inse.main import app -from . import model -from unittest.mock import patch + client = TestClient(app) URL_SERVICE_PREFIX="/inse-service" diff --git a/service/src/main/inse/topics/__init__.py b/service/src/main/inse/topics/__init__.py index 6909a227..4fca66e1 100644 --- a/service/src/main/inse/topics/__init__.py +++ b/service/src/main/inse/topics/__init__.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ OpenAlex topics module. """ diff --git a/service/src/main/inse/topics/logic.py b/service/src/main/inse/topics/logic.py index cec2bfa6..a4e22667 100644 --- a/service/src/main/inse/topics/logic.py +++ b/service/src/main/inse/topics/logic.py @@ -1,28 +1,28 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Business logic for OpenAlex topics. """ +import asyncio import logging from copy import deepcopy from typing import Any -import asyncio + from pydantic import ValidationError from inse.exceptions import ( - UpstreamAPIException, BadRequestException, ElasticsearchException, + UpstreamAPIException, ) - +from inse.model import ESCluster, ESIndex from inse.models.openalex.autocomplete_response import AutocompleteResponse from inse.models.openalex.autocomplete_response_meta import AutocompleteResponseMeta from inse.models.openalex.autocomplete_response_results_inner import ( AutocompleteResponseResultsInner, ) from inse.models.openalex.topics_list_response import TopicsListResponse -from inse.model import ESCluster, ESIndex + from .search_client import TopicsSearchClient logger = logging.getLogger(__name__) @@ -512,8 +512,8 @@ async def vector_search_topics_batch( """ Perform concurrent semantic/hybrid search for a list of keywords. """ - from inse.topics.model import KeywordsTopicsResponse, KeywordTopicMatch from inse.models.openalex.topic import Topic + from inse.topics.model import KeywordsTopicsResponse, KeywordTopicMatch if not keywords: return KeywordsTopicsResponse(results=[]) diff --git a/service/src/main/inse/topics/model.py b/service/src/main/inse/topics/model.py index e631f7da..c740fa4a 100644 --- a/service/src/main/inse/topics/model.py +++ b/service/src/main/inse/topics/model.py @@ -1,20 +1,20 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from typing import List, Optional + + from pydantic import BaseModel, Field from inse.models.openalex.topic import Topic + # Vector search for Keyword list class KeywordsTopicsRequest(BaseModel): - keywords: List[str] = Field(..., description="List of keywords/sentences to query by similarity.") + keywords: list[str] = Field(..., description="List of keywords/sentences to query by similarity.") class KeywordTopicMatch(BaseModel): keyword: str - topic: Optional[Topic] = Field(None, description="The top matching topic from OpenAlex, or None if no match is found.") + topic: Topic | None = Field(None, description="The top matching topic from OpenAlex, or None if no match is found.") class KeywordsTopicsResponse(BaseModel): - results: List[KeywordTopicMatch] = Field(..., description="Top matching topics for each keyword in the requested list.") + results: list[KeywordTopicMatch] = Field(..., description="Top matching topics for each keyword in the requested list.") diff --git a/service/src/main/inse/topics/search_client.py b/service/src/main/inse/topics/search_client.py index b6ec024a..71024fd0 100644 --- a/service/src/main/inse/topics/search_client.py +++ b/service/src/main/inse/topics/search_client.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Elasticsearch search client for OpenAlex topics. """ @@ -9,10 +8,8 @@ import base64 import json from typing import Any -from inse.model import ESCluster, ESIndex - -from .. import config from inse.integrations.elasticsearch import search as elasticsearch_search +from inse.model import ESCluster, ESIndex class TopicsSearchClient: diff --git a/service/src/main/inse/topics/service.py b/service/src/main/inse/topics/service.py index 2555f52d..06c8cb55 100644 --- a/service/src/main/inse/topics/service.py +++ b/service/src/main/inse/topics/service.py @@ -1,20 +1,18 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for OpenAlex topics. """ from typing import Annotated -from fastapi import APIRouter -from fastapi import Query +from fastapi import APIRouter, Query from inse.models.openalex.autocomplete_response import AutocompleteResponse from inse.models.openalex.topics_list_response import TopicsListResponse from inse.tags import Tags + from . import logic from .model import KeywordsTopicsRequest, KeywordsTopicsResponse - router = APIRouter(prefix="/api/topics", tags=[Tags.TOPICS]) diff --git a/service/src/main/inse/topics/v2/test_service.py b/service/src/main/inse/topics/v2/test_service.py index 02d97a0a..7053ae43 100644 --- a/service/src/main/inse/topics/v2/test_service.py +++ b/service/src/main/inse/topics/v2/test_service.py @@ -1,7 +1,6 @@ from unittest.mock import AsyncMock, patch import pytest - from inse.topics.v2.service import search_topics diff --git a/service/src/main/inse/university_ranking/logic.py b/service/src/main/inse/university_ranking/logic.py index 2f368665..bed2d7c9 100644 --- a/service/src/main/inse/university_ranking/logic.py +++ b/service/src/main/inse/university_ranking/logic.py @@ -1,10 +1,18 @@ -import logging import datetime -from typing import List, Dict, Any -from .model import UniversityTopicData, YearlyData, UniversityRanking, DashboardMetric, RankingResponse +import logging +from typing import Any + from inse.integrations import elasticsearch from inse.models.openalex.topic import Topic +from .model import ( + DashboardMetric, + RankingResponse, + UniversityRanking, + UniversityTopicData, + YearlyData, +) + logger = logging.getLogger(__name__) START_YEAR = 2000 @@ -207,7 +215,7 @@ async def get_ranking_data(topic_query: str, metric: DashboardMetric) -> Ranking logger.error("Error executing ranking aggregations on openalex-works: %s", e) # Map the accumulated results back into the timeseries response model - timeseries: List[UniversityTopicData] = [] + timeseries: list[UniversityTopicData] = [] inst_name_map = {inst["id"]: inst["display_name"] for inst in top_10} for inst_id, year_dict in accumulated_data.items(): @@ -230,13 +238,13 @@ async def get_ranking_data(topic_query: str, metric: DashboardMetric) -> Ranking return RankingResponse(timeseries=timeseries, rankings=rankings) -def _compute_rankings(data: List[UniversityTopicData], metric: DashboardMetric) -> List[UniversityRanking]: +def _compute_rankings(data: list[UniversityTopicData], metric: DashboardMetric) -> list[UniversityRanking]: """Computes ranking metrics based on the timeseries data.""" latest_year = END_YEAR five_years_ago = latest_year - 5 three_years_ago = latest_year - 3 - processed: List[Dict[str, Any]] = [] + processed: list[dict[str, Any]] = [] for item in data: latest = next((d for d in item.yearly_data if d.year == latest_year), YearlyData(year=latest_year, publications=0, citations=0)) prev = next((d for d in item.yearly_data if d.year == latest_year - 1), YearlyData(year=latest_year-1, publications=0, citations=0)) diff --git a/service/src/main/inse/university_ranking/model.py b/service/src/main/inse/university_ranking/model.py index 8582eb9b..6bf31d44 100644 --- a/service/src/main/inse/university_ranking/model.py +++ b/service/src/main/inse/university_ranking/model.py @@ -1,10 +1,13 @@ -from pydantic import BaseModel -from typing import List, Literal, Dict, Optional +from typing import Literal + from inse.models.openalex.topic import Topic +from pydantic import BaseModel DashboardMetric = Literal['publications', 'citations'] from enum import Enum + + class TrendSearchType(str, Enum): PUBLICATIONS = "publications" AUTHORS = "authors" @@ -21,7 +24,7 @@ class YearlyData(BaseModel): class UniversityTopicData(BaseModel): university: str topic: Topic - yearly_data: List[YearlyData] + yearly_data: list[YearlyData] class UniversityRanking(BaseModel): rank: int @@ -34,9 +37,9 @@ class UniversityRanking(BaseModel): class RankingResponse(BaseModel): # Raw timeseries data for the ECharts line race - timeseries: List[UniversityTopicData] + timeseries: list[UniversityTopicData] # Computed metrics for the ranking table - rankings: List[UniversityRanking] + rankings: list[UniversityRanking] # Trend Analysis Models class TopicYearlyData(BaseModel): @@ -50,20 +53,21 @@ class TrendSeries(BaseModel): entity_id: str entity_name: str entity_type: Literal['institution', 'country', 'region', 'author'] - country_code: Optional[str] = None + country_code: str | None = None # Map topic display name to its yearly data - topic_data: Dict[str, List[TopicYearlyData]] + topic_data: dict[str, list[TopicYearlyData]] class TrendResponse(BaseModel): - series: List[TrendSeries] - years: List[int] - location_mappings: Optional[Dict[str, List[str]]] = None + series: list[TrendSeries] + years: list[int] + location_mappings: dict[str, list[str]] | None = None from inse.models.openalex.dehydrated_institution import DehydratedInstitution + class TopInstitutionItem(DehydratedInstitution): - works_count: Optional[int] = None - exact_topic_count: Optional[int] = None + works_count: int | None = None + exact_topic_count: int | None = None class AutocompleteLocationItem(BaseModel): id: str @@ -76,4 +80,4 @@ class TopTopicItem(BaseModel): count: int class TopTopicsResponse(BaseModel): - items: List[TopTopicItem] \ No newline at end of file + items: list[TopTopicItem] \ No newline at end of file diff --git a/service/src/main/inse/university_ranking/service.py b/service/src/main/inse/university_ranking/service.py index f22427ed..868c561d 100644 --- a/service/src/main/inse/university_ranking/service.py +++ b/service/src/main/inse/university_ranking/service.py @@ -1,18 +1,18 @@ import logging -from typing import List, Optional -from fastapi import APIRouter, Query, Depends -from inse.tags import Tags +from fastapi import APIRouter, Depends, Query from inse.exceptions import BadRequestException +from inse.tags import Tags + from . import logic, trend_logic from .model import ( - RankingResponse, - DashboardMetric, - TrendResponse, - TopInstitutionItem, AutocompleteLocationItem, + DashboardMetric, + RankingResponse, + TopInstitutionItem, + TopTopicsResponse, + TrendResponse, TrendSearchType, - TopTopicsResponse ) from .trend_strategies import TrendStrategy @@ -25,12 +25,12 @@ router = APIRouter( def get_trend_strategy(search_type: TrendSearchType = Query(TrendSearchType.PUBLICATIONS)) -> TrendStrategy: from .trend_strategies import ( - PublicationsTrendStrategy, + AllTrendStrategy, AuthorsTrendStrategy, + NewsTrendStrategy, PatentsTrendStrategy, ProjectsTrendStrategy, - NewsTrendStrategy, - AllTrendStrategy, + PublicationsTrendStrategy, ) if search_type == TrendSearchType.PUBLICATIONS: return PublicationsTrendStrategy() @@ -66,13 +66,13 @@ async def get_rankings( summary="Returns timeseries publication data for compared institutions, countries, and regions." ) async def get_trend( - topics: List[str] = Query(..., description="List of topics to analyze"), - keywords: Optional[List[str]] = Query(None, description="List of raw keywords corresponding to topics"), + topics: list[str] = Query(..., description="List of topics to analyze"), + keywords: list[str] | None = Query(None, description="List of raw keywords corresponding to topics"), fuzzy: bool = Query(True, description="True if using mapped topics, False if using raw keywords"), - institutions: Optional[List[str]] = Query(None, description="List of OpenAlex Institution IDs"), - countries: Optional[List[str]] = Query(None, description="List of country codes"), - regions: Optional[List[str]] = Query(None, description="List of region identifiers"), - authors: Optional[List[str]] = Query(None, description="List of OpenAlex Author IDs"), + institutions: list[str] | None = Query(None, description="List of OpenAlex Institution IDs"), + countries: list[str] | None = Query(None, description="List of country codes"), + regions: list[str] | None = Query(None, description="List of region identifiers"), + authors: list[str] | None = Query(None, description="List of OpenAlex Author IDs"), strategy: TrendStrategy = Depends(get_trend_strategy) ): if not topics or len(topics) == 0: @@ -89,13 +89,13 @@ async def get_trend( @router.get( "/top-institutions", - response_model=List[TopInstitutionItem], + response_model=list[TopInstitutionItem], summary="Returns top institutions filtered by country/region and sorted by topic-level publications count." ) async def get_top_institutions( topic: str = Query(..., description="Research topic"), - region: Optional[str] = Query(None, description="Region identifier (e.g. EU)"), - country: Optional[str] = Query(None, description="Country code (e.g. DE)"), + region: str | None = Query(None, description="Region identifier (e.g. EU)"), + country: str | None = Query(None, description="Country code (e.g. DE)"), limit: int = Query(10, description="Max suggestions to return") ): return await trend_logic.get_top_institutions_by_region( @@ -107,7 +107,7 @@ async def get_top_institutions( @router.get( "/autocomplete-locations", - response_model=List[AutocompleteLocationItem], + response_model=list[AutocompleteLocationItem], summary="Returns country and continent options for autocomplete inputs." ) async def get_autocomplete_locations( diff --git a/service/src/main/inse/university_ranking/test_trend_strategies.py b/service/src/main/inse/university_ranking/test_trend_strategies.py index b8bd8f9d..9e8d08f8 100644 --- a/service/src/main/inse/university_ranking/test_trend_strategies.py +++ b/service/src/main/inse/university_ranking/test_trend_strategies.py @@ -1,24 +1,22 @@ import pytest -from inse.university_ranking.trend_strategies import ( - PublicationsTrendStrategy, - AuthorsTrendStrategy, - PatentsTrendStrategy, - ProjectsTrendStrategy, - NewsTrendStrategy, - AllTrendStrategy, -) -from inse.university_ranking.trend_query_builder import ( - TrendQueryBuilder, - TrendMetadataResolver, - clean_inst_id, - to_full_inst_url, -) from inse.university_ranking.trend_logic import ( autocomplete_locations, get_top_institutions_by_region, get_top_topics_for_entity, get_trend_data, ) +from inse.university_ranking.trend_query_builder import ( + TrendQueryBuilder, + clean_inst_id, + to_full_inst_url, +) +from inse.university_ranking.trend_strategies import ( + AllTrendStrategy, + NewsTrendStrategy, + PatentsTrendStrategy, + ProjectsTrendStrategy, + PublicationsTrendStrategy, +) def test_clean_and_to_full_inst_url(): diff --git a/service/src/main/inse/university_ranking/trend_logic.py b/service/src/main/inse/university_ranking/trend_logic.py index 733760ca..45265114 100644 --- a/service/src/main/inse/university_ranking/trend_logic.py +++ b/service/src/main/inse/university_ranking/trend_logic.py @@ -1,22 +1,19 @@ import logging -import datetime -from typing import List, Dict, Any, Optional -import asyncio +from typing import Any from inse.integrations import elasticsearch -from inse.model import ESIndex, ESCluster +from inse.model import ESCluster, ESIndex + from .model import ( - TrendResponse, - TopInstitutionItem, AutocompleteLocationItem, + TopInstitutionItem, + TrendResponse, ) from .trend_query_builder import ( TrendMetadataResolver, TrendQueryBuilder, clean_inst_id, to_full_inst_url, - DEFAULT_INSTITUTION_ID, - DEFAULT_INSTITUTION_NAME, ) logger = logging.getLogger(__name__) @@ -24,7 +21,7 @@ logger = logging.getLogger(__name__) DEFAULT_TOP_TOPICS_SIZE = 20 -async def autocomplete_locations(query: str) -> List[AutocompleteLocationItem]: +async def autocomplete_locations(query: str) -> list[AutocompleteLocationItem]: """Returns country and continent options matching the autocomplete query using an ES multi-search.""" stripped = query.strip() if not stripped: @@ -113,10 +110,10 @@ async def autocomplete_locations(query: str) -> List[AutocompleteLocationItem]: async def get_top_institutions_by_region( topic: str, - region: Optional[str] = None, - country: Optional[str] = None, + region: str | None = None, + country: str | None = None, limit: int = 10, -) -> List[TopInstitutionItem]: +) -> list[TopInstitutionItem]: """Search top educational institutions by region or country based on publication counts for the specific topic.""" country_codes = [] if country: @@ -146,7 +143,7 @@ async def get_top_institutions_by_region( else: topic_filter = {"match_phrase": {"topics.display_name": topic_display_name}} - must_clauses: List[Dict[str, Any]] = [ + must_clauses: list[dict[str, Any]] = [ {"term": {"type": "education"}}, topic_filter, ] @@ -194,10 +191,10 @@ async def get_top_institutions_by_region( async def get_trend_data( - topics: List[str], - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, + topics: list[str], + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, ) -> TrendResponse: """Retrieves publication trend data by delegating to PublicationsTrendStrategy.""" from .trend_strategies import PublicationsTrendStrategy @@ -216,7 +213,7 @@ async def get_top_topics_for_entity( start_year: int, end_year: int, search_type: str, -) -> Dict[str, Any]: +) -> dict[str, Any]: """Retrieves the top research topics for a specified entity and search type.""" if search_type == "patents" and entity_type == "institution": from inse.patents.org.logic import get_org_patents_by_institution_id @@ -239,7 +236,7 @@ async def get_top_topics_for_entity( break page += 1 - topic_counts: Dict[str, int] = {} + topic_counts: dict[str, int] = {} for p in patents: try: yr = int(p.publication_year) if p.publication_year else None @@ -273,7 +270,9 @@ async def get_top_topics_for_entity( aliases = [short_id, entity_id, full_id] if entity_type == "institution": try: - from inse.institutions.institutions_search_client import InstitutionsSearchClient + from inse.institutions.institutions_search_client import ( + InstitutionsSearchClient, + ) inst_client = InstitutionsSearchClient() resolved_aliases = await inst_client.get_institution_aliases_by_oa_institution_id(short_id) if resolved_aliases: @@ -297,12 +296,10 @@ async def get_top_topics_for_entity( aliases = list(dict.fromkeys([a for a in aliases if a])) include_german = True - if entity_type == "country" and entity_id.strip().upper() != "DE": - include_german = False - elif entity_type == "region" and "DE" not in entity_id.strip().upper(): + if entity_type == "country" and entity_id.strip().upper() != "DE" or entity_type == "region" and "DE" not in entity_id.strip().upper(): include_german = False - project_ids_by_index: Dict[str, List[str]] = {} + project_ids_by_index: dict[str, list[str]] = {} # 1. BUND - filter by institution/country and date range if include_german: @@ -407,7 +404,7 @@ async def get_top_topics_for_entity( logger.warning("Failed to fetch EU project IDs for %s: %s", org_idx.value, e) # Batch multi-search for topic aggregation across chunks - topic_counts: Dict[str, int] = {} + topic_counts: dict[str, int] = {} msearch_queries = [] for topic_idx, p_ids in project_ids_by_index.items(): @@ -482,7 +479,7 @@ async def get_top_topics_for_entity( except Exception as e: logger.warning("Failed scanning aktuell for news IDs in date range: %s", e) - topic_counts: Dict[str, int] = {} + topic_counts: dict[str, int] = {} if news_ids: msearch_queries = [] for i in range(0, len(news_ids), 2000): diff --git a/service/src/main/inse/university_ranking/trend_query_builder.py b/service/src/main/inse/university_ranking/trend_query_builder.py index cb93db74..dc639132 100644 --- a/service/src/main/inse/university_ranking/trend_query_builder.py +++ b/service/src/main/inse/university_ranking/trend_query_builder.py @@ -1,8 +1,10 @@ import asyncio import logging -from typing import Dict, List, Any, Optional, Tuple, Set +from typing import Any + from inse.integrations import elasticsearch from inse.model import ESIndex + logger = logging.getLogger(__name__) # Default fallback institution: University of Duisburg-Essen @@ -33,12 +35,12 @@ class TrendMetadataResolver: @staticmethod async def resolve_all( - query_institutions: Optional[List[str]] = None, - query_countries: Optional[List[str]] = None, - query_regions: Optional[List[str]] = None, - topics: Optional[List[str]] = None, + query_institutions: list[str] | None = None, + query_countries: list[str] | None = None, + query_regions: list[str] | None = None, + topics: list[str] | None = None, include_aliases: bool = False, - ) -> Dict[str, Any]: + ) -> dict[str, Any]: """Resolves metadata concurrently for entities.""" institutions = query_institutions or [] countries = [c.strip().upper() for c in (query_countries or []) if c.strip()] @@ -49,9 +51,9 @@ class TrendMetadataResolver: inst_full_ids = list(set([to_full_inst_url(i) for i in institutions if i])) async def fetch_institutions(): - names: Dict[str, str] = {DEFAULT_INSTITUTION_ID: DEFAULT_INSTITUTION_NAME} - codes: Dict[str, str] = {} - aliases_map: Dict[str, List[str]] = {} + names: dict[str, str] = {DEFAULT_INSTITUTION_ID: DEFAULT_INSTITUTION_NAME} + codes: dict[str, str] = {} + aliases_map: dict[str, list[str]] = {} if not inst_full_ids: return names, codes, aliases_map try: @@ -74,10 +76,12 @@ class TrendMetadataResolver: codes[short_id] = c_code if include_aliases: - from inse.institutions.institutions_search_client import InstitutionsSearchClient + from inse.institutions.institutions_search_client import ( + InstitutionsSearchClient, + ) inst_client = InstitutionsSearchClient() - async def get_alias(inst_id_str: str) -> Tuple[str, List[str]]: + async def get_alias(inst_id_str: str) -> tuple[str, list[str]]: s_id = clean_inst_id(inst_id_str) try: resolved = await inst_client.get_institution_aliases_by_oa_institution_id(s_id) @@ -97,7 +101,7 @@ class TrendMetadataResolver: return names, codes, aliases_map async def fetch_countries(): - names: Dict[str, str] = {} + names: dict[str, str] = {} if not countries: return names try: @@ -116,8 +120,8 @@ class TrendMetadataResolver: return names async def fetch_continents(): - names: Dict[str, str] = {} - ccodes: Dict[str, List[str]] = {} + names: dict[str, str] = {} + ccodes: dict[str, list[str]] = {} if not regions: return names, ccodes try: @@ -145,8 +149,8 @@ class TrendMetadataResolver: return names, ccodes async def fetch_topics(): - topic_ids: Dict[str, str] = {} - topic_display_names: Dict[str, str] = {} + topic_ids: dict[str, str] = {} + topic_display_names: dict[str, str] = {} if not topic_names: return topic_ids, topic_display_names @@ -230,10 +234,10 @@ class TrendQueryBuilder: @staticmethod def build_topic_clause( topic_display_name: str, - resolved_topic_id: Optional[str] = None, - keyword: Optional[str] = None, + resolved_topic_id: str | None = None, + keyword: str | None = None, fuzzy: bool = True, - ) -> Dict[str, Any]: + ) -> dict[str, Any]: """Builds a topic or keyword matching clause.""" target_id = resolved_topic_id if not target_id and topic_display_name: @@ -278,7 +282,7 @@ class TrendQueryBuilder: } @staticmethod - def build_date_range_filter(field_name: str, start_year: int, end_year: int) -> Dict[str, Any]: + def build_date_range_filter(field_name: str, start_year: int, end_year: int) -> dict[str, Any]: """Builds a date range filter on publication_year or similar.""" return { "range": { @@ -291,12 +295,12 @@ class TrendQueryBuilder: @staticmethod def build_entity_nested_filter( - inst_ids: Optional[List[str]] = None, - country_codes: Optional[List[str]] = None, - author_urls: Optional[List[str]] = None, - ) -> Dict[str, Any]: + inst_ids: list[str] | None = None, + country_codes: list[str] | None = None, + author_urls: list[str] | None = None, + ) -> dict[str, Any]: """Builds a nested filter for OpenAlex works authorships/institutions.""" - should_clauses: List[Dict[str, Any]] = [] + should_clauses: list[dict[str, Any]] = [] if inst_ids: should_clauses.append({ @@ -330,10 +334,10 @@ class TrendQueryBuilder: @staticmethod def build_trend_aggregations( - topic_filters: Dict[str, Dict[str, Any]], - entity_filters: Dict[str, Dict[str, Any]], + topic_filters: dict[str, dict[str, Any]], + entity_filters: dict[str, dict[str, Any]], years_count: int, - ) -> Dict[str, Any]: + ) -> dict[str, Any]: """Builds a two-layer nested aggregation (topics -> entities -> publication_year).""" return { "topics_agg": { @@ -355,7 +359,7 @@ class TrendQueryBuilder: } @staticmethod - def build_bund_keyword_query(keyword: str) -> Dict[str, Any]: + def build_bund_keyword_query(keyword: str) -> dict[str, Any]: """Builds keyword filter clause for BUND projects.""" return { "bool": { @@ -365,7 +369,7 @@ class TrendQueryBuilder: } @staticmethod - def build_dfg_keyword_query(keyword: str) -> Dict[str, Any]: + def build_dfg_keyword_query(keyword: str) -> dict[str, Any]: """Builds keyword filter clause for DFG projects.""" return { "bool": { @@ -394,7 +398,7 @@ class TrendQueryBuilder: } @staticmethod - def build_cordis_keyword_query(keyword: str) -> Dict[str, Any]: + def build_cordis_keyword_query(keyword: str) -> dict[str, Any]: """Builds keyword filter clause for EU CORDIS projects.""" return { "bool": { @@ -404,7 +408,7 @@ class TrendQueryBuilder: } @staticmethod - def build_bund_receiver_clause(aliases: List[str]) -> Dict[str, Any]: + def build_bund_receiver_clause(aliases: list[str]) -> dict[str, Any]: """Builds Zuwendungsempfänger matching clause for BUND projects.""" return { "bool": { diff --git a/service/src/main/inse/university_ranking/trend_strategies.py b/service/src/main/inse/university_ranking/trend_strategies.py index 21ad15c4..f46c6be2 100644 --- a/service/src/main/inse/university_ranking/trend_strategies.py +++ b/service/src/main/inse/university_ranking/trend_strategies.py @@ -1,22 +1,23 @@ import abc import asyncio -import logging import datetime -from typing import List, Dict, Any, Optional, Tuple +import logging +from typing import Any + import numpy as np +from inse.integrations import elasticsearch +from inse.model import ESCluster, ESIndex from sklearn.preprocessing import MinMaxScaler -from inse.integrations import elasticsearch -from inse.model import ESIndex, ESCluster from .model import ( + TopicYearlyData, TrendResponse, TrendSeries, - TopicYearlyData, ) from .trend_query_builder import ( + AKTUELLES_SEARCH_FIELDS, DEFAULT_INSTITUTION_ID, DEFAULT_INSTITUTION_NAME, - AKTUELLES_SEARCH_FIELDS, TrendMetadataResolver, TrendQueryBuilder, clean_inst_id, @@ -62,26 +63,26 @@ class TrendStrategy(abc.ABC): @abc.abstractmethod async def get_trend( self, - topics: List[str], - keywords: Optional[List[str]] = None, + topics: list[str], + keywords: list[str] | None = None, fuzzy: bool = True, - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, - authors: Optional[List[str]] = None, + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, + authors: list[str] | None = None, ) -> TrendResponse: pass - def _get_years_range(self, start_year: int = 2000) -> List[int]: + def _get_years_range(self, start_year: int = 2000) -> list[int]: end_year = datetime.datetime.now().year - 1 return list(range(start_year, end_year + 1)) def _normalize_series( self, - years_range: List[int], - accumulated_data: Dict[str, Dict[str, Dict[int, tuple]]], - topics: List[str], - ) -> Dict[tuple, Dict[str, List[float]]]: + years_range: list[int], + accumulated_data: dict[str, dict[str, dict[int, tuple]]], + topics: list[str], + ) -> dict[tuple, dict[str, list[float]]]: series_keys = [] raw_lists = [] cumsum_lists = [] @@ -123,13 +124,13 @@ class TrendStrategy(abc.ABC): class PublicationsTrendStrategy(TrendStrategy): async def get_trend( self, - topics: List[str], - keywords: Optional[List[str]] = None, + topics: list[str], + keywords: list[str] | None = None, fuzzy: bool = True, - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, - authors: Optional[List[str]] = None, + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, + authors: list[str] | None = None, ) -> TrendResponse: years_range = self._get_years_range() start_year, end_year = years_range[0], years_range[-1] @@ -154,7 +155,7 @@ class PublicationsTrendStrategy(TrendStrategy): location_mappings = continent_country_codes.copy() - filters_map: Dict[str, Dict[str, Any]] = {} + filters_map: dict[str, dict[str, Any]] = {} for inst_id in query_institutions: full_url = to_full_inst_url(inst_id) filters_map[f"inst_{full_url}"] = { @@ -185,7 +186,7 @@ class PublicationsTrendStrategy(TrendStrategy): if not filters_map: return TrendResponse(series=[], years=years_range, location_mappings=location_mappings) - accumulated_data: Dict[str, Dict[str, Dict[int, tuple]]] = { + accumulated_data: dict[str, dict[str, dict[int, tuple]]] = { key: {t: {yr: (0, 1) for yr in years_range} for t in topics} for key in filters_map } @@ -228,7 +229,7 @@ class PublicationsTrendStrategy(TrendStrategy): try: res = await elasticsearch.search( - index=f"{str(ESIndex.OPENALEX_WORKS)}*", + index=f"{ESIndex.OPENALEX_WORKS!s}*", body={"query": query, "aggs": aggregations}, size=0, cluster=ESCluster.NES, @@ -248,7 +249,7 @@ class PublicationsTrendStrategy(TrendStrategy): normalized_lookup = self._normalize_series(years_range, accumulated_data, topics) - series_list: List[TrendSeries] = [] + series_list: list[TrendSeries] = [] for entity_key, topic_dict in accumulated_data.items(): if entity_key.startswith("inst_"): entity_id = entity_key[len("inst_"):] @@ -265,9 +266,9 @@ class PublicationsTrendStrategy(TrendStrategy): else: continue - topic_data_map: Dict[str, List[TopicYearlyData]] = {} + topic_data_map: dict[str, list[TopicYearlyData]] = {} for topic, year_dict in topic_dict.items(): - yearly_data_items: List[TopicYearlyData] = [] + yearly_data_items: list[TopicYearlyData] = [] lookup = normalized_lookup.get((entity_key, topic), {}) norm_vals = lookup.get("normalized", [0.0] * len(years_range)) cum_vals = lookup.get("cumulative", [0.0] * len(years_range)) @@ -301,13 +302,13 @@ class PublicationsTrendStrategy(TrendStrategy): class AuthorsTrendStrategy(TrendStrategy): async def get_trend( self, - topics: List[str], - keywords: Optional[List[str]] = None, + topics: list[str], + keywords: list[str] | None = None, fuzzy: bool = True, - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, - authors: Optional[List[str]] = None, + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, + authors: list[str] | None = None, ) -> TrendResponse: years_range = self._get_years_range() start_year, end_year = years_range[0], years_range[-1] @@ -319,7 +320,7 @@ class AuthorsTrendStrategy(TrendStrategy): query_authors_clean = [clean_inst_id(a) for a in query_authors if a] # Resolve author display names - resolved_names: Dict[str, str] = {} + resolved_names: dict[str, str] = {} try: res = await elasticsearch.search( index="openalex-authors", @@ -342,7 +343,7 @@ class AuthorsTrendStrategy(TrendStrategy): query_authors_full = [to_full_inst_url(a) for a in query_authors if a] - filters_map: Dict[str, Dict[str, Any]] = {} + filters_map: dict[str, dict[str, Any]] = {} for auth_id, auth_url in zip(query_authors, query_authors_full): clean_id = clean_inst_id(auth_id) filters_map[f"author_{clean_id}"] = { @@ -352,7 +353,7 @@ class AuthorsTrendStrategy(TrendStrategy): } } - accumulated_data: Dict[str, Dict[str, Dict[int, tuple]]] = { + accumulated_data: dict[str, dict[str, dict[int, tuple]]] = { key: {t: {yr: (0, 1) for yr in years_range} for t in topics} for key in filters_map } @@ -387,7 +388,7 @@ class AuthorsTrendStrategy(TrendStrategy): try: res = await elasticsearch.search( - index=f"{str(ESIndex.OPENALEX_WORKS)}*", + index=f"{ESIndex.OPENALEX_WORKS!s}*", body={"query": query, "aggs": aggregations}, size=0, cluster=ESCluster.NES, @@ -407,14 +408,14 @@ class AuthorsTrendStrategy(TrendStrategy): normalized_lookup = self._normalize_series(years_range, accumulated_data, topics) - series_list: List[TrendSeries] = [] + series_list: list[TrendSeries] = [] for entity_key, topic_dict in accumulated_data.items(): entity_id = entity_key[len("author_"):] entity_name = resolved_names.get(entity_id, resolved_names.get(clean_inst_id(entity_id), entity_id)) - topic_data_map: Dict[str, List[TopicYearlyData]] = {} + topic_data_map: dict[str, list[TopicYearlyData]] = {} for topic, year_dict in topic_dict.items(): - yearly_data_items: List[TopicYearlyData] = [] + yearly_data_items: list[TopicYearlyData] = [] lookup = normalized_lookup.get((entity_key, topic), {}) norm_vals = lookup.get("normalized", [0.0] * len(years_range)) cum_vals = lookup.get("cumulative", [0.0] * len(years_range)) @@ -447,13 +448,13 @@ class AuthorsTrendStrategy(TrendStrategy): class PatentsTrendStrategy(TrendStrategy): async def get_trend( self, - topics: List[str], - keywords: Optional[List[str]] = None, + topics: list[str], + keywords: list[str] | None = None, fuzzy: bool = True, - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, - authors: Optional[List[str]] = None, + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, + authors: list[str] | None = None, ) -> TrendResponse: years_range = self._get_years_range() primary_inst_id = DEFAULT_INSTITUTION_ID @@ -503,7 +504,7 @@ class PatentsTrendStrategy(TrendStrategy): return True return False - def matches_patent(patent, topic: str, keyword: Optional[str], is_fuzzy: bool) -> bool: + def matches_patent(patent, topic: str, keyword: str | None, is_fuzzy: bool) -> bool: if matches_topic(patent, topic): return True t_lower = topic.lower() @@ -519,7 +520,7 @@ class PatentsTrendStrategy(TrendStrategy): return True return False - accumulated_data: Dict[str, Dict[str, Dict[int, tuple]]] = { + accumulated_data: dict[str, dict[str, dict[int, tuple]]] = { f"inst_{primary_inst_id}": {t: {yr: (0, 1) for yr in years_range} for t in topics}, f"inst_{world_inst_id}": {t: {yr: (0, 1) for yr in years_range} for t in topics}, } @@ -599,14 +600,14 @@ class PatentsTrendStrategy(TrendStrategy): normalized_lookup = self._normalize_series(years_range, accumulated_data, topics) - series_list: List[TrendSeries] = [] + series_list: list[TrendSeries] = [] for inst_id, entity_name in series_entities: entity_key = f"inst_{inst_id}" topic_dict = accumulated_data[entity_key] - topic_data_map: Dict[str, List[TopicYearlyData]] = {} + topic_data_map: dict[str, list[TopicYearlyData]] = {} for topic, year_dict in topic_dict.items(): - yearly_data_items: List[TopicYearlyData] = [] + yearly_data_items: list[TopicYearlyData] = [] lookup = normalized_lookup.get((entity_key, topic), {}) norm_vals = lookup.get("normalized", [0.0] * len(years_range)) cum_vals = lookup.get("cumulative", [0.0] * len(years_range)) @@ -640,13 +641,13 @@ class PatentsTrendStrategy(TrendStrategy): class ProjectsTrendStrategy(TrendStrategy): async def get_trend( self, - topics: List[str], - keywords: Optional[List[str]] = None, + topics: list[str], + keywords: list[str] | None = None, fuzzy: bool = True, - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, - authors: Optional[List[str]] = None, + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, + authors: list[str] | None = None, ) -> TrendResponse: years_range = self._get_years_range() start_year, end_year = years_range[0], years_range[-1] @@ -678,7 +679,7 @@ class ProjectsTrendStrategy(TrendStrategy): location_mappings = continent_country_codes.copy() - filters_map: Dict[str, Tuple[str, Any]] = {} + filters_map: dict[str, tuple[str, Any]] = {} for inst_id in dedup_inst_shorts: filters_map[f"inst_{inst_id}"] = ("institution", inst_id) @@ -694,9 +695,9 @@ class ProjectsTrendStrategy(TrendStrategy): return TrendResponse(series=[], years=years_range, location_mappings=location_mappings) # Resolve DFG project IDs for institutions via scan/search without size limit cutoffs - dfg_institution_projects: Dict[str, List[str]] = {} + dfg_institution_projects: dict[str, list[str]] = {} - async def resolve_dfg_projects(inst_id: str) -> Tuple[str, List[str]]: + async def resolve_dfg_projects(inst_id: str) -> tuple[str, list[str]]: aliases = resolved_aliases.get(inst_id, []) if not aliases: return inst_id, [] @@ -724,7 +725,7 @@ class ProjectsTrendStrategy(TrendStrategy): dfg_institution_projects[inst_id] = p_ids # Fetch matched project IDs for each topic using elasticsearch.scan (uncapped full retrieval) - topic_project_ids: Dict[str, Dict[str, List[str]]] = {} + topic_project_ids: dict[str, dict[str, list[str]]] = {} indices_mapping = { ESIndex.PROJECTS_CORDIS_EU_HEUROPE_TOPICS.value: ( ESIndex.CORDIS_EU_HORIZON_EUROPE_ORGANIZATIONS, @@ -747,7 +748,7 @@ class ProjectsTrendStrategy(TrendStrategy): topic_project_ids[t] = {ind: [] for ind in indices_mapping} map_query = {"term": {"topic_matches.topic_display_name.keyword": t}} - async def scan_topic_projects(mapping_index: str) -> Tuple[str, List[str]]: + async def scan_topic_projects(mapping_index: str) -> tuple[str, list[str]]: p_ids = set() try: async for hit in elasticsearch.scan( @@ -767,14 +768,14 @@ class ProjectsTrendStrategy(TrendStrategy): for ind_name, p_ids in scan_results: topic_project_ids[t][ind_name] = p_ids - accumulated_data: Dict[str, Dict[str, Dict[int, tuple]]] = { + accumulated_data: dict[str, dict[str, dict[int, tuple]]] = { key: {t: {yr: (0, 1) for yr in years_range} for t in topics} for key in filters_map } # Batch all project queries into single msearch request msearch_queries = [] - meta_indices: List[Tuple[str, str, str]] = [] # (entity_key, topic, agg_type) + meta_indices: list[tuple[str, str, str]] = [] # (entity_key, topic, agg_type) async def prepare_project_trend_queries(entity_key: str, entity_type: str, entity_val: Any, topic: str, keyword: str): eu_indices = [ @@ -795,7 +796,7 @@ class ProjectsTrendStrategy(TrendStrategy): ), ] - async def get_eu_entity_project_ids(org_index: ESIndex) -> List[str]: + async def get_eu_entity_project_ids(org_index: ESIndex) -> list[str]: filter_clauses = [] if entity_type == "institution": aliases = resolved_aliases.get(entity_val, []) @@ -826,9 +827,7 @@ class ProjectsTrendStrategy(TrendStrategy): # BUND include_bund = True - if entity_type == "country" and entity_val != "DE": - include_bund = False - elif entity_type == "region" and "DE" not in entity_val: + if entity_type == "country" and entity_val != "DE" or entity_type == "region" and "DE" not in entity_val: include_bund = False if include_bund: @@ -873,9 +872,7 @@ class ProjectsTrendStrategy(TrendStrategy): # DFG include_dfg = True - if entity_type == "country" and entity_val != "DE": - include_dfg = False - elif entity_type == "region" and "DE" not in entity_val: + if entity_type == "country" and entity_val != "DE" or entity_type == "region" and "DE" not in entity_val: include_dfg = False if include_dfg: @@ -998,7 +995,7 @@ class ProjectsTrendStrategy(TrendStrategy): normalized_lookup = self._normalize_series(years_range, accumulated_data, topics) - series_list: List[TrendSeries] = [] + series_list: list[TrendSeries] = [] for entity_key, topic_dict in accumulated_data.items(): entity_type, entity_val = filters_map[entity_key] if entity_type == "institution": @@ -1011,9 +1008,9 @@ class ProjectsTrendStrategy(TrendStrategy): entity_id = entity_key[len("region_"):] entity_name = resolved_continent_names.get(entity_id, f"Continent {entity_id}") - topic_data_map: Dict[str, List[TopicYearlyData]] = {} + topic_data_map: dict[str, list[TopicYearlyData]] = {} for topic, year_dict in topic_dict.items(): - yearly_data_items: List[TopicYearlyData] = [] + yearly_data_items: list[TopicYearlyData] = [] lookup = normalized_lookup.get((entity_key, topic), {}) norm_vals = lookup.get("normalized", [0.0] * len(years_range)) cum_vals = lookup.get("cumulative", [0.0] * len(years_range)) @@ -1047,13 +1044,13 @@ class ProjectsTrendStrategy(TrendStrategy): class NewsTrendStrategy(TrendStrategy): async def get_trend( self, - topics: List[str], - keywords: Optional[List[str]] = None, + topics: list[str], + keywords: list[str] | None = None, fuzzy: bool = True, - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, - authors: Optional[List[str]] = None, + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, + authors: list[str] | None = None, ) -> TrendResponse: years_range = self._get_years_range() start_year, end_year = years_range[0], years_range[-1] @@ -1066,7 +1063,7 @@ class NewsTrendStrategy(TrendStrategy): STOP_WORDS = {"in", "and", "or", "und", "oder", "der", "die", "das", "von", "mit", "zu", "at", "by", "on", "for", "to", "a", "an", "the"} # Scan UDE news OpenAlex topics index to get matching news IDs without size limit cutoffs - async def fetch_news_ids_for_term(idx: int, t_name: str) -> List[str]: + async def fetch_news_ids_for_term(idx: int, t_name: str) -> list[str]: news_ids: Set[str] = set() if fuzzy: term = t_name @@ -1118,7 +1115,7 @@ class NewsTrendStrategy(TrendStrategy): matching_ids_list = await asyncio.gather(*(fetch_news_ids_for_term(idx, t) for idx, t in enumerate(topics))) - async def count_by_year(t_name: str, news_ids: List[str]): + async def count_by_year(t_name: str, news_ids: list[str]): if not news_ids: return entity_key = f"news_topic_{t_name}" @@ -1169,16 +1166,16 @@ class NewsTrendStrategy(TrendStrategy): normalized_lookup = self._normalize_series(years_range, accumulated_data, topics) - series_list: List[TrendSeries] = [] + series_list: list[TrendSeries] = [] for t_name in topics: entity_key = f"news_topic_{t_name}" - topic_data_map: Dict[str, List[TopicYearlyData]] = {} + topic_data_map: dict[str, list[TopicYearlyData]] = {} lookup = normalized_lookup.get((entity_key, t_name), {}) norm_vals = lookup.get("normalized", [0.0] * len(years_range)) cum_vals = lookup.get("cumulative", [0.0] * len(years_range)) - yearly_data_items: List[TopicYearlyData] = [] + yearly_data_items: list[TopicYearlyData] = [] for idx, yr in enumerate(years_range): count, _ = accumulated_data[entity_key][t_name][yr] yearly_data_items.append( @@ -1209,13 +1206,13 @@ class NewsTrendStrategy(TrendStrategy): class AllTrendStrategy(TrendStrategy): async def get_trend( self, - topics: List[str], - keywords: Optional[List[str]] = None, + topics: list[str], + keywords: list[str] | None = None, fuzzy: bool = True, - institutions: Optional[List[str]] = None, - countries: Optional[List[str]] = None, - regions: Optional[List[str]] = None, - authors: Optional[List[str]] = None, + institutions: list[str] | None = None, + countries: list[str] | None = None, + regions: list[str] | None = None, + authors: list[str] | None = None, ) -> TrendResponse: target_inst = institutions[0] if (institutions and len(institutions) > 0) else DEFAULT_INSTITUTION_ID short_id = clean_inst_id(target_inst).upper() @@ -1247,10 +1244,10 @@ class AllTrendStrategy(TrendStrategy): pat_series = pat_res.series[0] if pat_res.series else None proj_series = proj_res.series[0] if proj_res.series else None - composite_series: List[TrendSeries] = [] + composite_series: list[TrendSeries] = [] - def add_composite(series_obj: Optional[TrendSeries], c_id: str, c_name: str): - topic_data_map: Dict[str, List[TopicYearlyData]] = {} + def add_composite(series_obj: TrendSeries | None, c_id: str, c_name: str): + topic_data_map: dict[str, list[TopicYearlyData]] = {} for topic in topics: if series_obj and topic in series_obj.topic_data: topic_data_map[topic] = series_obj.topic_data[topic] @@ -1273,7 +1270,7 @@ class AllTrendStrategy(TrendStrategy): add_composite(proj_series, "projects", "Drittmittelförderung") if is_ude and news_res: - merged_news_topic_data: Dict[str, List[TopicYearlyData]] = {} + merged_news_topic_data: dict[str, list[TopicYearlyData]] = {} for topic in topics: term_key = f"news_topic_{topic}" matching_series = next((s for s in news_res.series if s.entity_id == term_key), None) diff --git a/service/src/main/inse/util.py b/service/src/main/inse/util.py index c41c469d..f59020aa 100644 --- a/service/src/main/inse/util.py +++ b/service/src/main/inse/util.py @@ -1,18 +1,16 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ This module contains utility functions for the service implementation. """ -from typing import Optional from typing import TypeVar -from inse.models.openalex import Author -from . import model + from inse.exceptions import NotFoundException +from inse.models.openalex import Author T = TypeVar('T') -def raise_not_found_if_none(value: Optional[T]) -> T: +def raise_not_found_if_none(value: T | None) -> T: ''' Returns the value, if it is set, or raises a 404, if the value is None.''' if value == None: raise NotFoundException("Not found.") @@ -37,7 +35,9 @@ def get_persons_data(hit:dict): return author from sentence_transformers import SentenceTransformer + from .config import settings + # Sentence Transformer Model _model: SentenceTransformer | None = None @@ -69,4 +69,4 @@ def get_model(): except Exception: # Fallback if local_files_only fails in unexpected local dev environments _model = SentenceTransformer(model_name) - return _model \ No newline at end of file + return _model diff --git a/service/src/main/inse/utils.py b/service/src/main/inse/utils.py index 5feacd56..5eee5a23 100644 --- a/service/src/main/inse/utils.py +++ b/service/src/main/inse/utils.py @@ -1,6 +1,5 @@ import re - author_id_pattern = re.compile(r"https://openalex\.org/A\d+", re.IGNORECASE) work_id_pattern = re.compile(r"https://openalex\.org/W\d+", re.IGNORECASE) diff --git a/service/src/main/inse/works/__init__.py b/service/src/main/inse/works/__init__.py index fe9a01ed..fa5b98ea 100644 --- a/service/src/main/inse/works/__init__.py +++ b/service/src/main/inse/works/__init__.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Works domain package. """ diff --git a/service/src/main/inse/works/logic.py b/service/src/main/inse/works/logic.py index 6384b39b..11355c84 100644 --- a/service/src/main/inse/works/logic.py +++ b/service/src/main/inse/works/logic.py @@ -1,28 +1,29 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Business logic for publication works. """ import logging -from time import time -from typing import Any, List +from typing import Any from pydantic import ValidationError -from starlette.status import HTTP_404_NOT_FOUND -from inse import config +from inse.exceptions import ( + ElasticsearchException, + UpstreamAPIException, +) from inse.integrations import elasticsearch +from inse.model import ESCluster, ESIndex +from inse.models.openalex.meta import Meta +from inse.models.openalex.topic_count import TopicCount +from inse.models.openalex.topics_by_time import TopicsByTime +from inse.models.openalex.topics_by_year import TopicsByYear from inse.models.openalex.work import Work from inse.models.openalex.work_page import WorkPage from inse.models.openalex.works_list_response import WorksListResponse -from inse.models.openalex.meta import Meta -from inse.models.openalex.topic_count import TopicCount -from inse.models.openalex.topics_by_year import TopicsByYear -from inse.models.openalex.topics_by_time import TopicsByTime -from inse.exceptions import MissingApiKeyError, ElasticsearchException, UpstreamAPIException + from .search_client import OpenAlexWorksSearchClient -from inse.model import ESCluster, ESIndex + logger = logging.getLogger(__name__) TOPIC_DETAIL_SOURCE_FIELDS = [ @@ -120,7 +121,7 @@ async def get_all_author_works( async def get_primary_topic_counts( author_id: str, client: OpenAlexWorksSearchClient | None = None, -) -> List[TopicCount]: +) -> list[TopicCount]: topic_counts = await _get_primary_topic_counts_from_es(author_id) topic_ids = [item["id"] for item in topic_counts if item["id"]] @@ -187,7 +188,7 @@ async def _get_primary_topic_counts_from_es(author_id: str) -> list[dict]: cluster=ESCluster.NES, body=body, ) - except ElasticsearchException as exc: + except ElasticsearchException: logger.exception("OpenAlex primary topic aggregation request failed.") raise @@ -234,7 +235,7 @@ async def get_work( return elements[0] -async def enrich_topic_descriptions(topics: List) -> None: +async def enrich_topic_descriptions(topics: list) -> None: """Batch-fill missing descriptions on dehydrated topics. OpenAlex work and author documents carry dehydrated topics without a @@ -256,7 +257,7 @@ async def enrich_topic_descriptions(topics: List) -> None: topic.description = info.get("description") -async def _enrich_work_topic_descriptions(works: List[Work]) -> None: +async def _enrich_work_topic_descriptions(works: list[Work]) -> None: topics = [] for work in works: @@ -268,7 +269,7 @@ async def _enrich_work_topic_descriptions(works: List[Work]) -> None: await enrich_topic_descriptions(topics) -async def _get_topic_details(topic_ids: List[str]) -> dict[str, dict]: +async def _get_topic_details(topic_ids: list[str]) -> dict[str, dict]: if not topic_ids: return {} @@ -704,7 +705,7 @@ async def _get_publication_year_counts_from_es(author_id: str) -> tuple[list[dic cluster=ESCluster.NES, body=body, ) - except ElasticsearchException as exc: + except ElasticsearchException: logger.exception("OpenAlex publication year aggregation request failed.") raise @@ -773,7 +774,7 @@ async def _get_timeline_topic_counts_from_es( cluster=ESCluster.NES, body=body, ) - except ElasticsearchException as exc: + except ElasticsearchException: logger.exception("OpenAlex timeline topic aggregation request failed.") raise @@ -998,7 +999,7 @@ def _parse_full_work_search_response(data: dict) -> tuple[list[Work], int]: async def get_publication_dois_of_author( raw_oa_author_id: str, -) -> List[str]: +) -> list[str]: query = { "bool": { "must": [ @@ -1025,7 +1026,7 @@ async def get_publication_dois_of_author( query=query, cluster=ESCluster.NES, ) - except ElasticsearchException as exc: + except ElasticsearchException: logger.exception("Request for publication DOIs of author failed.") raise diff --git a/service/src/main/inse/works/model.py b/service/src/main/inse/works/model.py index e16d723a..93fe4320 100644 --- a/service/src/main/inse/works/model.py +++ b/service/src/main/inse/works/model.py @@ -1,36 +1,32 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ Pydantic models for publication works. """ -from typing import List -from typing import Optional -from pydantic import BaseModel -from pydantic import Field +from pydantic import BaseModel, Field from inse.models.openalex.work import Work class WorkSummary(BaseModel): - doi: Optional[str] = Field( + doi: str | None = Field( default=None, description="The optional DOI of the work." ) - title: Optional[str] = Field(default=None, description="The title of the work.") - type: Optional[str] = Field(default=None, description="The work type.") - language: Optional[str] = Field(default=None, description="The work language.") - publication_year: Optional[int] = Field( + title: str | None = Field(default=None, description="The title of the work.") + type: str | None = Field(default=None, description="The work type.") + language: str | None = Field(default=None, description="The work language.") + publication_year: int | None = Field( default=None, description="The publication year." ) cited_by_count: int = Field(default=0, description="The number of citations.") - topics: List[str] = Field( + topics: list[str] = Field( default_factory=list, description="The display names of the work topics." ) class WorkPage(BaseModel): - elements: List[WorkSummary] = Field( + elements: list[WorkSummary] = Field( default_factory=list, description="The works on this page." ) page: int = Field(default=1, description="The current page number.") @@ -39,5 +35,5 @@ class WorkPage(BaseModel): class WorkList(BaseModel): - elements: List[Work] = Field(default_factory=list, description="All works.") + elements: list[Work] = Field(default_factory=list, description="All works.") total: int = Field(default=0, description="The total number of works.") diff --git a/service/src/main/inse/works/search_client.py b/service/src/main/inse/works/search_client.py index 2e52a9a6..1db79d30 100644 --- a/service/src/main/inse/works/search_client.py +++ b/service/src/main/inse/works/search_client.py @@ -1,16 +1,16 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ HTTP client for the OpenAlex works Elasticsearch index. """ import logging +import urllib from typing import Any -import urllib -from .. import config +from inse.exceptions import MissingApiKeyError from inse.integrations import elasticsearch from inse.model import ESCluster, ESIndex -from inse.exceptions import MissingApiKeyError + +from .. import config logger = logging.getLogger(__name__) diff --git a/service/src/main/inse/works/service.py b/service/src/main/inse/works/service.py index ead6daad..0a4357c0 100644 --- a/service/src/main/inse/works/service.py +++ b/service/src/main/inse/works/service.py @@ -1,24 +1,20 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- + """ REST API for publication works. """ -from typing import Annotated, Literal, Optional +from typing import Annotated, Literal -from fastapi import APIRouter -from fastapi import Path -from fastapi import Query +from fastapi import APIRouter, Path, Query +from inse.models.openalex.topic_count import TopicCount +from inse.models.openalex.topics_by_time import TopicsByTime +from inse.models.openalex.work import Work +from inse.models.openalex.work_page import WorkPage +from inse.models.openalex.works_list_response import WorksListResponse from inse.tags import Tags from . import logic -from inse.models.openalex.work_page import WorkPage -from inse.models.openalex.work import Work -from inse.models.openalex.works_list_response import WorksListResponse -from inse.models.openalex.topic_count import TopicCount -from inse.models.openalex.topics_by_time import TopicsByTime - router = APIRouter(prefix="/api/works", tags=[Tags.WORKS]) @@ -147,7 +143,7 @@ async def get_work_by_identifier( ), ], title: Annotated[ - Optional[str], + str | None, Query( description="Do we want to fallback to title search if ID and DOI dont work?" ), diff --git a/service/src/main/inse/works/test_openalex_logic.py b/service/src/main/inse/works/test_openalex_logic.py index 48f01cef..0ad3f5a8 100644 --- a/service/src/main/inse/works/test_openalex_logic.py +++ b/service/src/main/inse/works/test_openalex_logic.py @@ -1,11 +1,5 @@ -import json -import httpx -import pytest -from fastapi import HTTPException -from inse.works import logic -from inse.works.search_client import OpenAlexWorksSearchClient # @pytest.fixture diff --git a/service/src/main/inse/works/test_search_client.py b/service/src/main/inse/works/test_search_client.py index 1f3c905e..83405f9f 100644 --- a/service/src/main/inse/works/test_search_client.py +++ b/service/src/main/inse/works/test_search_client.py @@ -1,4 +1,3 @@ -import json import pytest diff --git a/service/src/main/inse/works/test_service.py b/service/src/main/inse/works/test_service.py index e910b8a9..3a51837c 100644 --- a/service/src/main/inse/works/test_service.py +++ b/service/src/main/inse/works/test_service.py @@ -1,15 +1,7 @@ from fastapi.testclient import TestClient -from inse import config -from inse.works import logic -from inse.models.openalex.work import Work -from inse.models.openalex.work_page import WorkPage -from inse.models.openalex.works_list_response import WorksListResponse -from inse.models.openalex.meta import Meta -from inse.models.openalex.work_topic import WorkTopic from inse.main import app - client = TestClient(app)