From cd2f940e27e68e15a82b12dc359fef3a0022b38e Mon Sep 17 00:00:00 2001 From: Nora-Olivia-Ammann <103038637+Nora-Olivia-Ammann@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:12:07 +0100 Subject: [PATCH] refactor(validate-data): make abstract methods explicit (#1276) Co-authored-by: Johannes Nussbaum <39048939+jnussbaum@users.noreply.github.com> --- .../validate_data/models/data_deserialised.py | 5 ++--- .../commands/validate_data/models/data_rdf.py | 9 +++++---- .../validate_data/models/input_problems.py | 17 +++++++++-------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/dsp_tools/commands/validate_data/models/data_deserialised.py b/src/dsp_tools/commands/validate_data/models/data_deserialised.py index 1a4f197bcb..928f8168cc 100644 --- a/src/dsp_tools/commands/validate_data/models/data_deserialised.py +++ b/src/dsp_tools/commands/validate_data/models/data_deserialised.py @@ -1,6 +1,5 @@ from __future__ import annotations -from abc import ABC from dataclasses import dataclass from lxml import etree @@ -32,7 +31,7 @@ class DataDeserialised: @dataclass -class AbstractResource(ABC): +class AbstractResource: res_id: str label: str @@ -119,7 +118,7 @@ class UriValueDeserialised(ValueDeserialised): ... @dataclass -class AbstractFileValueDeserialised(ABC): +class AbstractFileValueDeserialised: res_id: str value: str | None diff --git a/src/dsp_tools/commands/validate_data/models/data_rdf.py b/src/dsp_tools/commands/validate_data/models/data_rdf.py index 35582440f5..6ffd90571b 100644 --- a/src/dsp_tools/commands/validate_data/models/data_rdf.py +++ b/src/dsp_tools/commands/validate_data/models/data_rdf.py @@ -1,6 +1,7 @@ from __future__ import annotations from abc import ABC +from abc import abstractmethod from dataclasses import dataclass from uuid import uuid4 @@ -28,8 +29,8 @@ def make_graph(self) -> Graph: class RDFTriples(ABC): - def make_graph(self) -> Graph: - raise NotImplementedError + @abstractmethod + def make_graph(self) -> Graph: ... @dataclass @@ -219,8 +220,8 @@ class AbstractFileValueRDF(RDFTriples): res_iri: URIRef value: Literal - def make_graph(self) -> Graph: - raise NotImplementedError + @abstractmethod + def make_graph(self) -> Graph: ... @dataclass diff --git a/src/dsp_tools/commands/validate_data/models/input_problems.py b/src/dsp_tools/commands/validate_data/models/input_problems.py index 9acc27b6f1..a5c63148b7 100644 --- a/src/dsp_tools/commands/validate_data/models/input_problems.py +++ b/src/dsp_tools/commands/validate_data/models/input_problems.py @@ -2,6 +2,7 @@ import warnings from abc import ABC +from abc import abstractmethod from collections import defaultdict from dataclasses import dataclass from datetime import datetime @@ -146,14 +147,14 @@ class InputProblem(ABC): prop_name: str @property - def problem(self) -> str: - raise NotImplementedError + @abstractmethod + def problem(self) -> str: ... - def get_msg(self) -> str: - raise NotImplementedError + @abstractmethod + def get_msg(self) -> str: ... - def to_dict(self) -> dict[str, str]: - raise NotImplementedError + @abstractmethod + def to_dict(self) -> dict[str, str]: ... def _base_dict(self) -> dict[str, str]: return { @@ -163,8 +164,8 @@ def _base_dict(self) -> dict[str, str]: "Problem": self.problem, } - def sort_value(self) -> str: - raise NotImplementedError + @abstractmethod + def sort_value(self) -> str: ... #######################