From 22e36009d05ed75da8ffa0b94d53b0fcfee45a02 Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Fri, 26 Jul 2024 12:20:46 +0200 Subject: [PATCH] chore: repalce abc abstract by raise NotImplementedError in ImportMixin --- .../core/gn_commons/models/abstract_mixin.py | 3 +-- backend/geonature/core/gn_synthese/module.py | 3 +-- .../geonature/core/imports/import_mixin.py | 22 ++++++------------- .../backend/gn_module_occhab/module.py | 3 +-- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/backend/geonature/core/gn_commons/models/abstract_mixin.py b/backend/geonature/core/gn_commons/models/abstract_mixin.py index 3c068587d7..4c595b4771 100644 --- a/backend/geonature/core/gn_commons/models/abstract_mixin.py +++ b/backend/geonature/core/gn_commons/models/abstract_mixin.py @@ -1,9 +1,8 @@ from .base import TModules -import abc import typing -class AbstractMixin(abc.ABC): +class AbstractMixin: _module: TModules = None def __init__(self, module: TModules) -> None: diff --git a/backend/geonature/core/gn_synthese/module.py b/backend/geonature/core/gn_synthese/module.py index 9d50f6f1be..4dcf1b4ddc 100644 --- a/backend/geonature/core/gn_synthese/module.py +++ b/backend/geonature/core/gn_synthese/module.py @@ -1,10 +1,9 @@ from geonature.core.gn_commons.models import TModules from geonature.core.gn_synthese.imports import SyntheseImportMixin -from geonature.utils.metaclass_utils import metaclass_resolver -class SyntheseModule(metaclass_resolver(TModules, SyntheseImportMixin)): +class SyntheseModule(TModules, SyntheseImportMixin): __mapper_args__ = {"polymorphic_identity": "synthese"} def generate_input_url_for_dataset(self, dataset): diff --git a/backend/geonature/core/imports/import_mixin.py b/backend/geonature/core/imports/import_mixin.py index 55ab215ff3..3690135fae 100644 --- a/backend/geonature/core/imports/import_mixin.py +++ b/backend/geonature/core/imports/import_mixin.py @@ -3,7 +3,6 @@ from bokeh.embed.standalone import StandaloneEmbedJson -from abc import abstractmethod import typing @@ -19,37 +18,30 @@ class ImportInputUrl(typing.TypedDict): class ImportMixin(AbstractMixin): @staticmethod - @abstractmethod def statistics_labels() -> typing.List[ImportStatisticsLabels]: - pass + raise NotImplementedError # The output of this method is NEVER used @staticmethod - @abstractmethod def preprocess_transient_data(imprt: TImports, df) -> set: - return None + raise NotImplementedError @staticmethod - @abstractmethod def check_transient_data(task, logger, imprt: TImports) -> None: - pass + raise NotImplementedError @staticmethod - @abstractmethod def import_data_to_destination(imprt: TImports) -> None: - pass + raise NotImplementedError @staticmethod - @abstractmethod def remove_data_from_destination(imprt: TImports) -> None: - pass + raise NotImplementedError @staticmethod - @abstractmethod def report_plot(imprt: TImports) -> StandaloneEmbedJson: - pass + raise NotImplementedError @staticmethod - @abstractmethod def compute_bounding_box(imprt: TImports) -> None: - pass + raise NotImplementedError diff --git a/contrib/gn_module_occhab/backend/gn_module_occhab/module.py b/contrib/gn_module_occhab/backend/gn_module_occhab/module.py index 1b99c070db..225ec60bbe 100644 --- a/contrib/gn_module_occhab/backend/gn_module_occhab/module.py +++ b/contrib/gn_module_occhab/backend/gn_module_occhab/module.py @@ -1,10 +1,9 @@ from geonature.core.gn_commons.models import TModules -from geonature.utils.metaclass_utils import metaclass_resolver from .imports import OcchabImportMixin -class OcchabModule(metaclass_resolver(TModules, OcchabImportMixin)): +class OcchabModule(TModules, OcchabImportMixin): __mapper_args__ = {"polymorphic_identity": "occhab"} def generate_input_url_for_dataset(self, dataset):