diff --git a/mypy.ini b/mypy.ini index 2feb3af6..60c79cb8 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2,4 +2,4 @@ mypy_path = src packages= antares strict = true - +enable_error_code = explicit-override \ No newline at end of file diff --git a/src/antares/craft/service/api_services/area_api.py b/src/antares/craft/service/api_services/area_api.py index 1d473f55..372fff58 100644 --- a/src/antares/craft/service/api_services/area_api.py +++ b/src/antares/craft/service/api_services/area_api.py @@ -48,6 +48,7 @@ ) from antares.craft.tools.contents_tool import AreaUiResponse from antares.craft.tools.matrix_tool import prepare_args_replace_matrix +from typing_extensions import override class AreaApiService(BaseAreaService): @@ -70,6 +71,7 @@ def __init__( self.renewable_service: BaseRenewableService = renewable_service self.hydro_service: BaseHydroService = hydro_service + @override def create_area( self, area_name: str, properties: Optional[AreaProperties] = None, ui: Optional[AreaUi] = None ) -> Area: @@ -144,6 +146,7 @@ def create_area( hydro=hydro, ) + @override def create_thermal_cluster( self, area_id: str, thermal_name: str, properties: Optional[ThermalClusterProperties] = None ) -> ThermalCluster: @@ -179,6 +182,7 @@ def create_thermal_cluster( return ThermalCluster(self.thermal_service, area_id, name, properties) + @override def create_thermal_cluster_with_matrices( self, area_id: str, @@ -279,6 +283,7 @@ def _replace_matrix_request(self, json_payload: Union[dict[str, Any], list[dict[ response = self._wrapper.post(url, json=json_payload) response.raise_for_status() + @override def create_renewable_cluster( self, area_id: str, @@ -323,6 +328,7 @@ def create_renewable_cluster( return RenewableCluster(self.renewable_service, area_id, name, properties) + @override def create_st_storage( self, area_id: str, st_storage_name: str, properties: Optional[STStorageProperties] = None ) -> STStorage: @@ -357,6 +363,7 @@ def create_st_storage( return STStorage(self.storage_service, area_id, name, properties) + @override def create_load(self, area_id: str, series: pd.DataFrame) -> None: try: series_path = f"input/load/series/load_{area_id}" @@ -368,6 +375,7 @@ def create_load(self, area_id: str, series: pd.DataFrame) -> None: except APIError as e: raise MatrixUploadError(area_id, "load", e.message) from e + @override def create_wind(self, area_id: str, series: pd.DataFrame) -> None: try: series_path = f"input/wind/series/wind_{area_id}" @@ -375,6 +383,7 @@ def create_wind(self, area_id: str, series: pd.DataFrame) -> None: except APIError as e: raise MatrixUploadError(area_id, "wind", e.message) from e + @override def create_reserves(self, area_id: str, series: pd.DataFrame) -> None: try: series_path = f"input/reserves/{area_id}" @@ -382,6 +391,7 @@ def create_reserves(self, area_id: str, series: pd.DataFrame) -> None: except APIError as e: raise MatrixUploadError(area_id, "reserves", e.message) from e + @override def create_solar(self, area_id: str, series: pd.DataFrame) -> None: try: series_path = f"input/solar/series/solar_{area_id}" @@ -389,6 +399,7 @@ def create_solar(self, area_id: str, series: pd.DataFrame) -> None: except APIError as e: raise MatrixUploadError(area_id, "solar", e.message) from e + @override def create_misc_gen(self, area_id: str, series: pd.DataFrame) -> None: try: series_path = f"input/misc-gen/miscgen-{area_id}" @@ -396,6 +407,7 @@ def create_misc_gen(self, area_id: str, series: pd.DataFrame) -> None: except APIError as e: raise MatrixUploadError(area_id, "misc-gen", e.message) from e + @override def create_hydro( self, area_id: str, @@ -421,6 +433,7 @@ def create_hydro( return Hydro(self.hydro_service, area_id, properties) + @override def read_hydro( self, area_id: str, @@ -450,6 +463,7 @@ def _create_hydro_series(self, area_id: str, matrices: dict[HydroMatrixName, pd. self._replace_matrix_request(json_payload) + @override def update_area_properties(self, area_id: str, properties: AreaProperties) -> AreaProperties: url = f"{self._base_url}/studies/{self.study_id}/areas/{area_id}/properties/form" try: @@ -464,6 +478,7 @@ def update_area_properties(self, area_id: str, properties: AreaProperties) -> Ar return area_properties + @override def update_area_ui(self, area_id: str, ui: AreaUi) -> AreaUi: base_url = f"{self._base_url}/studies/{self.study_id}/areas" try: @@ -495,6 +510,7 @@ def update_area_ui(self, area_id: str, ui: AreaUi) -> AreaUi: return area_ui + @override def delete_area(self, area_id: str) -> None: url = f"{self._base_url}/studies/{self.study_id}/areas/{area_id}" try: @@ -502,6 +518,7 @@ def delete_area(self, area_id: str) -> None: except APIError as e: raise AreaDeletionError(area_id, e.message) from e + @override def delete_thermal_clusters(self, area_id: str, clusters: list[ThermalCluster]) -> None: url = f"{self._base_url}/studies/{self.study_id}/areas/{area_id}/clusters/thermal" body = [cluster.id for cluster in clusters] @@ -510,6 +527,7 @@ def delete_thermal_clusters(self, area_id: str, clusters: list[ThermalCluster]) except APIError as e: raise ThermalDeletionError(area_id, body, e.message) from e + @override def delete_renewable_clusters(self, area_id: str, clusters: list[RenewableCluster]) -> None: url = f"{self._base_url}/studies/{self.study_id}/areas/{area_id}/clusters/renewable" body = [cluster.id for cluster in clusters] @@ -518,6 +536,7 @@ def delete_renewable_clusters(self, area_id: str, clusters: list[RenewableCluste except APIError as e: raise RenewableDeletionError(area_id, body, e.message) from e + @override def delete_st_storages(self, area_id: str, storages: list[STStorage]) -> None: url = f"{self._base_url}/studies/{self.study_id}/areas/{area_id}/storages" body = [storage.id for storage in storages] @@ -526,30 +545,35 @@ def delete_st_storages(self, area_id: str, storages: list[STStorage]) -> None: except APIError as e: raise STStorageDeletionError(area_id, body, e.message) from e + @override def get_load_matrix(self, area_id: str) -> pd.DataFrame: try: return get_matrix(self._base_url, self.study_id, self._wrapper, f"input/load/series/load_{area_id}") except APIError as e: raise MatrixDownloadError(area_id, "load", e.message) + @override def get_solar_matrix(self, area_id: str) -> pd.DataFrame: try: return get_matrix(self._base_url, self.study_id, self._wrapper, f"input/solar/series/solar_{area_id}") except APIError as e: raise MatrixDownloadError(area_id, "solar", e.message) + @override def get_wind_matrix(self, area_id: str) -> pd.DataFrame: try: return get_matrix(self._base_url, self.study_id, self._wrapper, f"input/wind/series/wind_{area_id}") except APIError as e: raise MatrixDownloadError(area_id, "wind", e.message) + @override def get_reserves_matrix(self, area_id: str) -> pd.DataFrame: try: return get_matrix(self._base_url, self.study_id, self._wrapper, f"input/reserves/{area_id}") except APIError as e: raise MatrixDownloadError(area_id, "reserves", e.message) + @override def get_misc_gen_matrix(self, area_id: str) -> pd.DataFrame: try: return get_matrix(self._base_url, self.study_id, self._wrapper, f"input/misc-gen/miscgen-{area_id}") @@ -565,6 +589,7 @@ def craft_ui(self, url_str: str, area_id: str) -> AreaUi: return current_ui + @override def read_areas(self) -> list[Area]: area_list = [] diff --git a/src/antares/craft/service/api_services/binding_constraint_api.py b/src/antares/craft/service/api_services/binding_constraint_api.py index f08ef836..a0fd83bc 100644 --- a/src/antares/craft/service/api_services/binding_constraint_api.py +++ b/src/antares/craft/service/api_services/binding_constraint_api.py @@ -11,7 +11,7 @@ # This file is part of the Antares project. from pathlib import PurePosixPath -from typing import List, Optional +from typing import Optional import pandas as pd @@ -35,6 +35,7 @@ ) from antares.craft.service.api_services.utils import get_matrix from antares.craft.service.base_services import BaseBindingConstraintService +from typing_extensions import override class BindingConstraintApiService(BaseBindingConstraintService): @@ -45,11 +46,12 @@ def __init__(self, config: APIconf, study_id: str) -> None: self._wrapper = RequestWrapper(self.api_config.set_up_api_conf()) self._base_url = f"{self.api_config.get_host()}/api/v1" + @override def create_binding_constraint( self, name: str, properties: Optional[BindingConstraintProperties] = None, - terms: Optional[List[ConstraintTerm]] = None, + terms: Optional[list[ConstraintTerm]] = None, less_term_matrix: Optional[pd.DataFrame] = None, equal_term_matrix: Optional[pd.DataFrame] = None, greater_term_matrix: Optional[pd.DataFrame] = None, @@ -89,7 +91,7 @@ def create_binding_constraint( for key in ["terms", "id", "name"]: del created_properties[key] bc_properties = BindingConstraintProperties.model_validate(created_properties) - bc_terms: List[ConstraintTerm] = [] + bc_terms: list[ConstraintTerm] = [] if terms: json_terms = [term.model_dump() for term in terms] @@ -108,6 +110,7 @@ def create_binding_constraint( return constraint + @override def delete_binding_constraint_term(self, constraint_id: str, term_id: str) -> None: url = f"{self._base_url}/studies/{self.study_id}/bindingconstraints/{constraint_id}/term/{term_id}" try: @@ -115,6 +118,7 @@ def delete_binding_constraint_term(self, constraint_id: str, term_id: str) -> No except APIError as e: raise ConstraintTermDeletionError(constraint_id, term_id, e.message) from e + @override def update_binding_constraint_properties( self, binding_constraint: BindingConstraint, properties: BindingConstraintProperties ) -> BindingConstraintProperties: @@ -135,6 +139,7 @@ def update_binding_constraint_properties( return new_properties + @override def get_constraint_matrix(self, constraint: BindingConstraint, matrix_name: ConstraintMatrixName) -> pd.DataFrame: try: path = PurePosixPath("input") / "bindingconstraints" / f"{constraint.id}_{matrix_name.value}" @@ -142,6 +147,7 @@ def get_constraint_matrix(self, constraint: BindingConstraint, matrix_name: Cons except APIError as e: raise ConstraintMatrixDownloadError(constraint.id, matrix_name.value, e.message) from e + @override def update_constraint_matrix( self, constraint: BindingConstraint, matrix_name: ConstraintMatrixName, matrix: pd.DataFrame ) -> None: @@ -157,7 +163,8 @@ def update_constraint_matrix( except APIError as e: raise ConstraintMatrixUpdateError(constraint.id, matrix_name.value, e.message) from e - def add_constraint_terms(self, constraint: BindingConstraint, terms: List[ConstraintTerm]) -> List[ConstraintTerm]: + @override + def add_constraint_terms(self, constraint: BindingConstraint, terms: list[ConstraintTerm]) -> list[ConstraintTerm]: url = f"{self._base_url}/studies/{self.study_id}/bindingconstraints/{constraint.id}" try: json_terms = [term.model_dump() for term in terms] @@ -172,6 +179,7 @@ def add_constraint_terms(self, constraint: BindingConstraint, terms: List[Constr return new_terms + @override def read_binding_constraints(self) -> list[BindingConstraint]: url = f"{self._base_url}/studies/{self.study_id}/bindingconstraints" try: diff --git a/src/antares/craft/service/api_services/hydro_api.py b/src/antares/craft/service/api_services/hydro_api.py index 316058ef..6b0f2306 100644 --- a/src/antares/craft/service/api_services/hydro_api.py +++ b/src/antares/craft/service/api_services/hydro_api.py @@ -17,6 +17,7 @@ from antares.craft.exceptions.exceptions import APIError, MatrixDownloadError from antares.craft.service.api_services.utils import get_matrix from antares.craft.service.base_services import BaseHydroService +from typing_extensions import override class HydroApiService(BaseHydroService): @@ -27,6 +28,7 @@ def __init__(self, config: APIconf, study_id: str): self._wrapper = RequestWrapper(self.api_config.set_up_api_conf()) self._base_url = f"{self.api_config.get_host()}/api/v1" + @override def get_maxpower(self, area_id: str) -> pd.DataFrame: try: return get_matrix( @@ -35,6 +37,7 @@ def get_maxpower(self, area_id: str) -> pd.DataFrame: except APIError as e: raise MatrixDownloadError(area_id, "maxpower", e.message) from e + @override def get_reservoir(self, area_id: str) -> pd.DataFrame: try: return get_matrix( @@ -43,6 +46,7 @@ def get_reservoir(self, area_id: str) -> pd.DataFrame: except APIError as e: raise MatrixDownloadError(area_id, "reservoir", e.message) from e + @override def get_inflow_pattern(self, area_id: str) -> pd.DataFrame: try: return get_matrix( @@ -51,6 +55,7 @@ def get_inflow_pattern(self, area_id: str) -> pd.DataFrame: except APIError as e: raise MatrixDownloadError(area_id, "inflow_pattern", e.message) from e + @override def get_credit_modulations(self, area_id: str) -> pd.DataFrame: try: return get_matrix( @@ -59,6 +64,7 @@ def get_credit_modulations(self, area_id: str) -> pd.DataFrame: except APIError as e: raise MatrixDownloadError(area_id, "credit_modulations", e.message) from e + @override def get_water_values(self, area_id: str) -> pd.DataFrame: try: return get_matrix( diff --git a/src/antares/craft/service/api_services/link_api.py b/src/antares/craft/service/api_services/link_api.py index 1b349492..4070e64d 100644 --- a/src/antares/craft/service/api_services/link_api.py +++ b/src/antares/craft/service/api_services/link_api.py @@ -29,6 +29,7 @@ from antares.craft.model.link import Link, LinkProperties, LinkUi from antares.craft.service.api_services.utils import get_matrix, upload_series from antares.craft.service.base_services import BaseLinkService +from typing_extensions import override class LinkApiService(BaseLinkService): @@ -39,6 +40,7 @@ def __init__(self, config: APIconf, study_id: str): self._base_url = f"{self.config.get_host()}/api/v1" self._wrapper = RequestWrapper(self.config.set_up_api_conf()) + @override def create_link( self, area_from: str, @@ -100,6 +102,7 @@ def create_link( return Link(area_from, area_to, self, created_properties, ui) + @override def delete_link(self, link: Link) -> None: area_from_id = link.area_from_id area_to_id = link.area_to_id @@ -109,6 +112,7 @@ def delete_link(self, link: Link) -> None: except APIError as e: raise LinkDeletionError(link.id, e.message) from e + @override def update_link_properties(self, link: Link, properties: LinkProperties) -> LinkProperties: # todo: change this code when AntaresWeb will have a real endpoint area1_id = link.area_from_id @@ -142,6 +146,7 @@ def update_link_properties(self, link: Link, properties: LinkProperties) -> Link return link_properties + @override def update_link_ui(self, link: Link, ui: LinkUi) -> LinkUi: # todo: change this code when AntaresWeb will have a real endpoint area1_id = link.area_from_id @@ -168,6 +173,7 @@ def update_link_ui(self, link: Link, ui: LinkUi) -> LinkUi: return link_ui + @override def get_parameters(self, area_from: str, area_to: str) -> pd.DataFrame: try: parameters_path = f"input/links/{area_from}/{area_to}_parameters" @@ -177,6 +183,7 @@ def get_parameters(self, area_from: str, area_to: str) -> pd.DataFrame: return matrix + @override def create_parameters(self, series: pd.DataFrame, area_from: str, area_to: str) -> None: try: series_path = f"input/links/{area_from}/{area_to}_parameters" @@ -184,6 +191,7 @@ def create_parameters(self, series: pd.DataFrame, area_from: str, area_to: str) except APIError as e: raise LinkUploadError(area_from, area_to, "parameters", e.message) from e + @override def get_capacity_direct(self, area_from: str, area_to: str) -> pd.DataFrame: try: series_path = f"input/links/{area_from}/capacities/{area_to}_direct" @@ -192,6 +200,7 @@ def get_capacity_direct(self, area_from: str, area_to: str) -> pd.DataFrame: raise LinkDownloadError(area_from, area_to, "directcapacity", e.message) from e return matrix + @override def create_capacity_direct(self, series: pd.DataFrame, area_from: str, area_to: str) -> None: try: series_path = f"input/links/{area_from}/capacities/{area_to}_direct" @@ -199,6 +208,7 @@ def create_capacity_direct(self, series: pd.DataFrame, area_from: str, area_to: except APIError as e: raise LinkUploadError(area_from, area_to, "directcapacity", e.message) from e + @override def get_capacity_indirect(self, area_from: str, area_to: str) -> pd.DataFrame: try: series_path = f"input/links/{area_from}/capacities/{area_to}_indirect" @@ -207,6 +217,7 @@ def get_capacity_indirect(self, area_from: str, area_to: str) -> pd.DataFrame: raise LinkDownloadError(area_from, area_to, "indirectcapacity", e.message) from e return matrix + @override def create_capacity_indirect(self, series: pd.DataFrame, area_from: str, area_to: str) -> None: try: series_path = f"input/links/{area_from}/capacities/{area_to}_indirect" @@ -214,6 +225,7 @@ def create_capacity_indirect(self, series: pd.DataFrame, area_from: str, area_to except APIError as e: raise LinkUploadError(area_from, area_to, "indirectcapacity", e.message) from e + @override def read_links(self) -> list[Link]: try: url = f"{self._base_url}/studies/{self.study_id}/links" diff --git a/src/antares/craft/service/api_services/output_api.py b/src/antares/craft/service/api_services/output_api.py index 18a7e88d..f244d436 100644 --- a/src/antares/craft/service/api_services/output_api.py +++ b/src/antares/craft/service/api_services/output_api.py @@ -19,6 +19,7 @@ from antares.craft.model.output import AggregationEntry from antares.craft.service.api_services.utils import get_matrix from antares.craft.service.base_services import BaseOutputService +from typing_extensions import override class OutputApiService(BaseOutputService): @@ -29,10 +30,12 @@ def __init__(self, config: APIconf, study_id: str): self._base_url = f"{self.config.get_host()}/api/v1" self._wrapper = RequestWrapper(self.config.set_up_api_conf()) + @override def get_matrix(self, output_id: str, file_path: str) -> pd.DataFrame: full_path = f"output/{output_id}/economy/{file_path}" return get_matrix(self._base_url, self.study_id, self._wrapper, full_path) + @override def aggregate_values( self, output_id: str, aggregation_entry: AggregationEntry, object_type: str, mc_type: str ) -> pd.DataFrame: diff --git a/src/antares/craft/service/api_services/renewable_api.py b/src/antares/craft/service/api_services/renewable_api.py index 4ebfa8e0..ad6b3f0f 100644 --- a/src/antares/craft/service/api_services/renewable_api.py +++ b/src/antares/craft/service/api_services/renewable_api.py @@ -26,6 +26,7 @@ from antares.craft.model.renewable import RenewableCluster, RenewableClusterProperties from antares.craft.service.api_services.utils import get_matrix, upload_series from antares.craft.service.base_services import BaseRenewableService +from typing_extensions import override class RenewableApiService(BaseRenewableService): @@ -36,6 +37,7 @@ def __init__(self, config: APIconf, study_id: str): self._base_url = f"{self.config.get_host()}/api/v1" self._wrapper = RequestWrapper(self.config.set_up_api_conf()) + @override def update_renewable_properties( self, renewable_cluster: RenewableCluster, properties: RenewableClusterProperties ) -> RenewableClusterProperties: @@ -56,6 +58,7 @@ def update_renewable_properties( return new_properties + @override def update_renewable_matrix(self, renewable_cluster: RenewableCluster, matrix: pd.DataFrame) -> None: try: path = ( @@ -71,6 +74,7 @@ def update_renewable_matrix(self, renewable_cluster: RenewableCluster, matrix: p except APIError as e: raise RenewableMatrixUpdateError(renewable_cluster.area_id, renewable_cluster.id, e.message) from e + @override def get_renewable_matrix(self, cluster_id: str, area_id: str) -> pd.DataFrame: try: path = PurePosixPath("input") / "renewables" / "series" / f"{area_id}" / f"{cluster_id}" / "series" @@ -78,6 +82,7 @@ def get_renewable_matrix(self, cluster_id: str, area_id: str) -> pd.DataFrame: except APIError as e: raise RenewableMatrixDownloadError(area_id, cluster_id, e.message) from e + @override def read_renewables( self, area_id: str, diff --git a/src/antares/craft/service/api_services/run_api.py b/src/antares/craft/service/api_services/run_api.py index b4c3d3b9..b76967a8 100644 --- a/src/antares/craft/service/api_services/run_api.py +++ b/src/antares/craft/service/api_services/run_api.py @@ -26,6 +26,7 @@ from antares.craft.model.simulation import AntaresSimulationParameters, Job, JobStatus from antares.craft.service.api_services.utils import wait_task_completion from antares.craft.service.base_services import BaseRunService +from typing_extensions import override class RunApiService(BaseRunService): @@ -36,6 +37,7 @@ def __init__(self, config: APIconf, study_id: str): self._base_url = f"{self.config.get_host()}/api/v1" self._wrapper = RequestWrapper(self.config.set_up_api_conf()) + @override def run_antares_simulation(self, parameters: Optional[AntaresSimulationParameters] = None) -> Job: url = f"{self._base_url}/launcher/run/{self.study_id}" try: @@ -58,6 +60,7 @@ def _get_job_from_id(self, job_id: str, parameters: AntaresSimulationParameters) output_id = job_info.get("output_id") return Job(job_id=job_id, status=status, parameters=parameters, output_id=output_id) + @override def wait_job_completion(self, job: Job, time_out: int) -> None: start_time = time.time() repeat_interval = 5 diff --git a/src/antares/craft/service/api_services/services/settings.py b/src/antares/craft/service/api_services/services/settings.py index b1d36e61..5146649e 100644 --- a/src/antares/craft/service/api_services/services/settings.py +++ b/src/antares/craft/service/api_services/services/settings.py @@ -25,6 +25,7 @@ ThematicTrimmingParametersAPI, ) from antares.craft.service.base_services import BaseStudySettingsService +from typing_extensions import override class StudySettingsAPIService(BaseStudySettingsService): @@ -35,12 +36,14 @@ def __init__(self, config: APIconf, study_id: str): self._base_url = f"{self.config.get_host()}/api/v1" self._wrapper = RequestWrapper(self.config.set_up_api_conf()) + @override def edit_study_settings(self, settings: StudySettingsUpdate) -> None: try: edit_study_settings(self._base_url, self.study_id, self._wrapper, settings) except APIError as e: raise StudySettingsUpdateError(self.study_id, e.message) from e + @override def read_study_settings(self) -> StudySettings: try: return read_study_settings_api(self._base_url, self.study_id, self._wrapper) diff --git a/src/antares/craft/service/api_services/st_storage_api.py b/src/antares/craft/service/api_services/st_storage_api.py index c558c57f..97ec3791 100644 --- a/src/antares/craft/service/api_services/st_storage_api.py +++ b/src/antares/craft/service/api_services/st_storage_api.py @@ -23,6 +23,7 @@ ) from antares.craft.model.st_storage import STStorage, STStorageMatrixName, STStorageProperties from antares.craft.service.base_services import BaseShortTermStorageService +from typing_extensions import override class ShortTermStorageApiService(BaseShortTermStorageService): @@ -33,6 +34,7 @@ def __init__(self, config: APIconf, study_id: str): self._base_url = f"{self.config.get_host()}/api/v1" self._wrapper = RequestWrapper(self.config.set_up_api_conf()) + @override def update_st_storage_properties( self, st_storage: STStorage, properties: STStorageProperties ) -> STStorageProperties: @@ -53,6 +55,7 @@ def update_st_storage_properties( return new_properties + @override def upload_storage_matrix(self, storage: STStorage, ts_name: STStorageMatrixName, matrix: pd.DataFrame) -> None: url = f"{self._base_url}/studies/{self.study_id}/areas/{storage.area_id}/storages/{storage.id}/series/{ts_name.value}" try: @@ -65,6 +68,7 @@ def upload_storage_matrix(self, storage: STStorage, ts_name: STStorageMatrixName except APIError as e: raise STStorageMatrixUploadError(storage.area_id, storage.id, ts_name.value, e.message) from e + @override def get_storage_matrix(self, storage: STStorage, ts_name: STStorageMatrixName) -> pd.DataFrame: url = f"{self._base_url}/studies/{self.study_id}/areas/{storage.area_id}/storages/{storage.id}/series/{ts_name.value}" try: @@ -75,6 +79,7 @@ def get_storage_matrix(self, storage: STStorage, ts_name: STStorageMatrixName) - raise STStorageMatrixDownloadError(storage.area_id, storage.id, ts_name.value, e.message) from e return dataframe + @override def read_st_storages(self, area_id: str) -> List[STStorage]: url = f"{self._base_url}/studies/{self.study_id}/areas/{area_id}/storages" json_storage = self._wrapper.get(url).json() diff --git a/src/antares/craft/service/api_services/study_api.py b/src/antares/craft/service/api_services/study_api.py index f75cf11f..3c56f1d4 100644 --- a/src/antares/craft/service/api_services/study_api.py +++ b/src/antares/craft/service/api_services/study_api.py @@ -32,6 +32,7 @@ from antares.craft.model.output import Output from antares.craft.service.api_services.utils import wait_task_completion from antares.craft.service.base_services import BaseOutputService, BaseStudyService +from typing_extensions import override if TYPE_CHECKING: from antares.craft.model.study import Study @@ -47,10 +48,12 @@ def __init__(self, config: APIconf, study_id: str, output_service: BaseOutputSer self._output_service: BaseOutputService = output_service @property + @override def study_id(self) -> str: return self._study_id @property + @override def config(self) -> APIconf: return self._config @@ -58,6 +61,7 @@ def config(self) -> APIconf: def output_service(self) -> BaseOutputService: return self._output_service + @override def delete_binding_constraint(self, constraint: BindingConstraint) -> None: url = f"{self._base_url}/studies/{self.study_id}/bindingconstraints/{constraint.id}" try: @@ -65,6 +69,7 @@ def delete_binding_constraint(self, constraint: BindingConstraint) -> None: except APIError as e: raise BindingConstraintDeletionError(constraint.id, e.message) from e + @override def delete(self, children: bool) -> None: url = f"{self._base_url}/studies/{self.study_id}?children={children}" try: @@ -72,6 +77,7 @@ def delete(self, children: bool) -> None: except APIError as e: raise StudyDeletionError(self.study_id, e.message) from e + @override def create_variant(self, variant_name: str) -> "Study": url = f"{self._base_url}/studies/{self.study_id}/variants?name={variant_name}" try: @@ -81,6 +87,7 @@ def create_variant(self, variant_name: str) -> "Study": except APIError as e: raise StudyVariantCreationError(self.study_id, e.message) from e + @override def read_outputs(self) -> list[Output]: url = f"{self._base_url}/studies/{self.study_id}/outputs" try: @@ -93,6 +100,7 @@ def read_outputs(self) -> list[Output]: except APIError as e: raise OutputsRetrievalError(self.study_id, e.message) + @override def delete_outputs(self) -> None: outputs_url = f"{self._base_url}/studies/{self.study_id}/outputs" try: @@ -106,6 +114,7 @@ def delete_outputs(self) -> None: except APIError as e: raise OutputsRetrievalError(self.study_id, e.message) + @override def delete_output(self, output_name: str) -> None: url = f"{self._base_url}/studies/{self.study_id}/outputs/{output_name}" try: @@ -113,6 +122,7 @@ def delete_output(self, output_name: str) -> None: except APIError as e: raise OutputDeletionError(self.study_id, output_name, e.message) from e + @override def move_study(self, new_parent_path: Path) -> PurePath: url = f"{self._base_url}/studies/{self.study_id}/move?folder_dest={new_parent_path}" try: @@ -123,6 +133,7 @@ def move_study(self, new_parent_path: Path) -> PurePath: except APIError as e: raise StudyMoveError(self.study_id, new_parent_path.as_posix(), e.message) from e + @override def generate_thermal_timeseries(self) -> None: url = f"{self._base_url}/studies/{self.study_id}/timeseries/generate" try: diff --git a/src/antares/craft/service/api_services/thermal_api.py b/src/antares/craft/service/api_services/thermal_api.py index 9f925972..17d6f837 100644 --- a/src/antares/craft/service/api_services/thermal_api.py +++ b/src/antares/craft/service/api_services/thermal_api.py @@ -26,6 +26,7 @@ from antares.craft.model.thermal import ThermalCluster, ThermalClusterMatrixName, ThermalClusterProperties from antares.craft.service.api_services.utils import get_matrix, upload_series from antares.craft.service.base_services import BaseThermalService +from typing_extensions import override class ThermalApiService(BaseThermalService): @@ -36,6 +37,7 @@ def __init__(self, config: APIconf, study_id: str): self._base_url = f"{self.config.get_host()}/api/v1" self._wrapper = RequestWrapper(self.config.set_up_api_conf()) + @override def update_thermal_properties( self, thermal_cluster: ThermalCluster, properties: ThermalClusterProperties ) -> ThermalClusterProperties: @@ -56,6 +58,7 @@ def update_thermal_properties( return new_properties + @override def update_thermal_matrix(self, thermal_cluster: ThermalCluster, matrix: pd.DataFrame) -> None: path = ( PurePosixPath("input") @@ -70,6 +73,7 @@ def update_thermal_matrix(self, thermal_cluster: ThermalCluster, matrix: pd.Data except APIError as e: raise ThermalMatrixUpdateError(thermal_cluster.area_id, thermal_cluster.name, e.message) from e + @override def get_thermal_matrix(self, thermal_cluster: ThermalCluster, ts_name: ThermalClusterMatrixName) -> pd.DataFrame: try: keyword = "series" if "SERIES" in ts_name.name else "prepro" @@ -87,6 +91,7 @@ def get_thermal_matrix(self, thermal_cluster: ThermalCluster, ts_name: ThermalCl thermal_cluster.area_id, thermal_cluster.name, ts_name.value, e.message ) from e + @override def read_thermal_clusters( self, area_id: str, diff --git a/src/antares/craft/service/local_services/area_local.py b/src/antares/craft/service/local_services/area_local.py index 962ebc5a..745f9758 100644 --- a/src/antares/craft/service/local_services/area_local.py +++ b/src/antares/craft/service/local_services/area_local.py @@ -43,6 +43,7 @@ from antares.craft.tools.matrix_tool import read_timeseries from antares.craft.tools.prepro_folder import PreproFolder from antares.craft.tools.time_series_tool import TimeSeriesFileType +from typing_extensions import override def _sets_ini_content() -> ConfigParser: @@ -81,6 +82,7 @@ def __init__( self.renewable_service: BaseRenewableService = renewable_service self.hydro_service: BaseHydroService = hydro_service + @override def create_thermal_cluster( self, area_id: str, @@ -116,6 +118,7 @@ def create_thermal_cluster( self.thermal_service, area_id, thermal_name, local_thermal_properties.yield_thermal_cluster_properties() ) + @override def create_thermal_cluster_with_matrices( self, area_id: str, @@ -129,6 +132,7 @@ def create_thermal_cluster_with_matrices( ) -> ThermalCluster: raise NotImplementedError + @override def create_renewable_cluster( self, area_id: str, @@ -148,6 +152,7 @@ def create_renewable_cluster( self.renewable_service, area_id, renewable_name, local_properties.yield_renewable_cluster_properties() ) + @override def create_load(self, area_id: str, series: pd.DataFrame) -> None: self._write_timeseries(series, TimeSeriesFileType.LOAD, area_id) PreproFolder.LOAD.save(self.config.study_path, area_id) @@ -156,6 +161,7 @@ def _write_timeseries(self, series: pd.DataFrame, ts_file_type: TimeSeriesFileTy file_path = self.config.study_path.joinpath(ts_file_type.value.format(area_id=area_id)) series.to_csv(file_path, sep="\t", header=False, index=False, encoding="utf-8") + @override def create_st_storage( self, area_id: str, st_storage_name: str, properties: Optional[STStorageProperties] = None ) -> STStorage: @@ -174,20 +180,25 @@ def create_st_storage( local_st_storage_properties.yield_st_storage_properties(), ) + @override def create_wind(self, area_id: str, series: pd.DataFrame) -> None: self._write_timeseries(series, TimeSeriesFileType.WIND, area_id) PreproFolder.WIND.save(self.config.study_path, area_id) + @override def create_reserves(self, area_id: str, series: pd.DataFrame) -> None: self._write_timeseries(series, TimeSeriesFileType.RESERVES, area_id) + @override def create_solar(self, area_id: str, series: pd.DataFrame) -> None: self._write_timeseries(series, TimeSeriesFileType.SOLAR, area_id) PreproFolder.SOLAR.save(self.config.study_path, area_id) + @override def create_misc_gen(self, area_id: str, series: pd.DataFrame) -> None: self._write_timeseries(series, TimeSeriesFileType.MISC_GEN, area_id) + @override def create_hydro( self, area_id: str, @@ -206,12 +217,14 @@ def create_hydro( return Hydro(self.hydro_service, area_id, local_hydro_properties.yield_hydro_properties()) + @override def read_hydro( self, area_id: str, ) -> Hydro: raise NotImplementedError + @override def create_area( self, area_name: str, properties: Optional[AreaProperties] = None, ui: Optional[AreaUi] = None ) -> Area: @@ -331,39 +344,51 @@ def _line_exists_in_file(file_content: str, line_to_add: str) -> bool: created_area.create_hydro() return created_area + @override def delete_area(self, area_id: str) -> None: raise NotImplementedError + @override def update_area_properties(self, area_id: str, properties: AreaProperties) -> AreaProperties: raise NotImplementedError + @override def update_area_ui(self, area_id: str, ui: AreaUi) -> AreaUi: raise NotImplementedError + @override def delete_thermal_clusters(self, area_id: str, thermal_clusters: List[ThermalCluster]) -> None: raise NotImplementedError + @override def delete_renewable_clusters(self, area_id: str, renewable_clusters: List[RenewableCluster]) -> None: raise NotImplementedError + @override def delete_st_storages(self, area_id: str, storages: List[STStorage]) -> None: raise NotImplementedError + @override def get_load_matrix(self, area_id: str) -> pd.DataFrame: return read_timeseries(TimeSeriesFileType.LOAD, self.config.study_path, area_id=area_id) + @override def get_solar_matrix(self, area_id: str) -> pd.DataFrame: return read_timeseries(TimeSeriesFileType.SOLAR, self.config.study_path, area_id=area_id) + @override def get_wind_matrix(self, area_id: str) -> pd.DataFrame: return read_timeseries(TimeSeriesFileType.WIND, self.config.study_path, area_id=area_id) + @override def get_reserves_matrix(self, area_id: str) -> pd.DataFrame: return read_timeseries(TimeSeriesFileType.RESERVES, self.config.study_path, area_id=area_id) + @override def get_misc_gen_matrix(self, area_id: str) -> pd.DataFrame: return read_timeseries(TimeSeriesFileType.MISC_GEN, self.config.study_path, area_id=area_id) + @override def read_areas(self) -> List[Area]: local_path = self.config.local_path areas_path = local_path / self.study_name / "input" / "areas" diff --git a/src/antares/craft/service/local_services/binding_constraint_local.py b/src/antares/craft/service/local_services/binding_constraint_local.py index f6b09755..fc73c965 100644 --- a/src/antares/craft/service/local_services/binding_constraint_local.py +++ b/src/antares/craft/service/local_services/binding_constraint_local.py @@ -30,6 +30,7 @@ from antares.craft.tools.matrix_tool import df_read, df_save from antares.craft.tools.time_series_tool import TimeSeriesFileType from pydantic import Field +from typing_extensions import override class BindingConstraintPropertiesLocal(DefaultBindingConstraintProperties): @@ -79,6 +80,7 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.study_name = study_name self.ini_file = IniFile(self.config.study_path, InitializationFilesTypes.BINDING_CONSTRAINTS_INI) + @override def create_binding_constraint( self, name: str, @@ -188,6 +190,7 @@ def _write_binding_constraint_ini( self.ini_file.ini_dict_binding_constraints = current_ini_content self.ini_file.write_ini_file() + @override def add_constraint_terms(self, constraint: BindingConstraint, terms: list[ConstraintTerm]) -> list[ConstraintTerm]: """ Add terms to a binding constraint and update the INI file. @@ -223,24 +226,29 @@ def add_constraint_terms(self, constraint: BindingConstraint, terms: list[Constr return terms_values + @override def delete_binding_constraint_term(self, constraint_id: str, term_id: str) -> None: raise NotImplementedError + @override def update_binding_constraint_properties( self, binding_constraint: BindingConstraint, properties: BindingConstraintProperties ) -> BindingConstraintProperties: raise NotImplementedError + @override def get_constraint_matrix(self, constraint: BindingConstraint, matrix_name: ConstraintMatrixName) -> pd.DataFrame: file_path = self.config.study_path.joinpath( "input", "bindingconstraints", f"{constraint.id}_{matrix_name.value}.txt" ) return df_read(file_path) + @override def update_constraint_matrix( self, constraint: BindingConstraint, matrix_name: ConstraintMatrixName, matrix: pd.DataFrame ) -> None: raise NotImplementedError + @override def read_binding_constraints(self) -> list[BindingConstraint]: raise NotImplementedError diff --git a/src/antares/craft/service/local_services/hydro_local.py b/src/antares/craft/service/local_services/hydro_local.py index 036bff2e..a55d8d67 100644 --- a/src/antares/craft/service/local_services/hydro_local.py +++ b/src/antares/craft/service/local_services/hydro_local.py @@ -14,6 +14,7 @@ from antares.craft.config.local_configuration import LocalConfiguration from antares.craft.service.base_services import BaseHydroService +from typing_extensions import override class HydroLocalService(BaseHydroService): @@ -21,17 +22,22 @@ def __init__(self, config: LocalConfiguration, study_name: str): self.config = config self.study_name = study_name + @override def get_maxpower(self, area_id: str) -> pd.DataFrame: raise NotImplementedError() + @override def get_reservoir(self, area_id: str) -> pd.DataFrame: raise NotImplementedError() + @override def get_inflow_pattern(self, area_id: str) -> pd.DataFrame: raise NotImplementedError() + @override def get_credit_modulations(self, area_id: str) -> pd.DataFrame: raise NotImplementedError() + @override def get_water_values(self, area_id: str) -> pd.DataFrame: raise NotImplementedError() diff --git a/src/antares/craft/service/local_services/link_local.py b/src/antares/craft/service/local_services/link_local.py index 2627e9c6..b1786327 100644 --- a/src/antares/craft/service/local_services/link_local.py +++ b/src/antares/craft/service/local_services/link_local.py @@ -26,6 +26,7 @@ from antares.craft.tools.ini_tool import IniFile, InitializationFilesTypes from antares.craft.tools.matrix_tool import read_timeseries from antares.craft.tools.time_series_tool import TimeSeriesFileType +from typing_extensions import override class LinkLocalService(BaseLinkService): @@ -34,6 +35,7 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.config = config self.study_name = study_name + @override def create_link( self, area_from: str, @@ -96,12 +98,15 @@ def create_link( ui=local_ui.yield_link_ui(), ) + @override def delete_link(self, link: Link) -> None: raise NotImplementedError + @override def update_link_properties(self, link: Link, properties: LinkProperties) -> LinkProperties: raise NotImplementedError + @override def update_link_ui(self, link: Link, ui: LinkUi) -> LinkUi: raise NotImplementedError @@ -126,15 +131,19 @@ def sort_link_properties_dict(ini_dict: Dict[str, str]) -> Dict[str, str]: ] return dict(sorted(ini_dict.items(), key=lambda item: dict_order.index(item[0]))) + @override def create_parameters(self, series: pd.DataFrame, area_from: str, area_to: str) -> None: raise NotImplementedError + @override def create_capacity_direct(self, series: pd.DataFrame, area_from: str, area_to: str) -> None: raise NotImplementedError + @override def create_capacity_indirect(self, series: pd.DataFrame, area_from: str, area_to: str) -> None: raise NotImplementedError + @override def get_capacity_direct( self, area_from: str, @@ -147,6 +156,7 @@ def get_capacity_direct( second_area_id=area_to, ) + @override def get_capacity_indirect( self, area_from: str, @@ -159,6 +169,7 @@ def get_capacity_indirect( second_area_id=area_to, ) + @override def get_parameters( self, area_from: str, @@ -168,6 +179,7 @@ def get_parameters( TimeSeriesFileType.LINKS_PARAMETERS, self.config.study_path, area_id=area_from, second_area_id=area_to ) + @override def read_links(self) -> list[Link]: link_path = self.config.study_path / "input" / "links" diff --git a/src/antares/craft/service/local_services/output_local.py b/src/antares/craft/service/local_services/output_local.py index 70d541ea..a2fb0f06 100644 --- a/src/antares/craft/service/local_services/output_local.py +++ b/src/antares/craft/service/local_services/output_local.py @@ -16,6 +16,7 @@ from antares.craft.config.local_configuration import LocalConfiguration from antares.craft.model.output import AggregationEntry from antares.craft.service.base_services import BaseOutputService +from typing_extensions import override class OutputLocalService(BaseOutputService): @@ -24,9 +25,11 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.config = config self.study_name = study_name + @override def get_matrix(self, output_id: str, file_path: str) -> pd.DataFrame: raise NotImplementedError + @override def aggregate_values( self, output_id: str, aggregation_entry: AggregationEntry, object_type: str, mc_type: str ) -> pd.DataFrame: diff --git a/src/antares/craft/service/local_services/renewable_local.py b/src/antares/craft/service/local_services/renewable_local.py index 3babf13f..1a4074ee 100644 --- a/src/antares/craft/service/local_services/renewable_local.py +++ b/src/antares/craft/service/local_services/renewable_local.py @@ -21,6 +21,7 @@ from antares.craft.tools.ini_tool import IniFile, InitializationFilesTypes from antares.craft.tools.matrix_tool import read_timeseries from antares.craft.tools.time_series_tool import TimeSeriesFileType +from typing_extensions import override class RenewableLocalService(BaseRenewableService): @@ -29,11 +30,13 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.config = config self.study_name = study_name + @override def update_renewable_properties( self, renewable_cluster: RenewableCluster, properties: RenewableClusterProperties ) -> RenewableClusterProperties: raise NotImplementedError + @override def get_renewable_matrix(self, cluster_id: str, area_id: str) -> pd.DataFrame: return read_timeseries( TimeSeriesFileType.RENEWABLE_DATA_SERIES, self.config.study_path, area_id=area_id, cluster_id=cluster_id @@ -58,6 +61,7 @@ def _extract_renewable_properties(self, renewable_data: dict[str, Any]) -> Renew return RenewableClusterPropertiesLocal(**parsed_data).yield_renewable_cluster_properties() + @override def read_renewables(self, area_id: str) -> list[RenewableCluster]: renewable_dict = IniFile( self.config.study_path, InitializationFilesTypes.RENEWABLES_LIST_INI, area_id=area_id @@ -76,5 +80,6 @@ def read_renewables(self, area_id: str) -> list[RenewableCluster]: for renewable_data in renewable_dict.values() ] + @override def update_renewable_matrix(self, renewable_cluster: RenewableCluster, matrix: pd.DataFrame) -> None: raise NotImplementedError diff --git a/src/antares/craft/service/local_services/run_local.py b/src/antares/craft/service/local_services/run_local.py index a7ceab9b..2bb658cf 100644 --- a/src/antares/craft/service/local_services/run_local.py +++ b/src/antares/craft/service/local_services/run_local.py @@ -14,6 +14,7 @@ from antares.craft.config.local_configuration import LocalConfiguration from antares.craft.model.simulation import AntaresSimulationParameters, Job from antares.craft.service.base_services import BaseRunService +from typing_extensions import override class RunLocalService(BaseRunService): @@ -22,8 +23,10 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.config = config self.study_name = study_name + @override def run_antares_simulation(self, parameters: Optional[AntaresSimulationParameters] = None) -> Job: raise NotImplementedError + @override def wait_job_completion(self, job: Job, time_out: int) -> None: raise NotImplementedError diff --git a/src/antares/craft/service/local_services/services/settings.py b/src/antares/craft/service/local_services/services/settings.py index 94f7a582..6d78a24f 100644 --- a/src/antares/craft/service/local_services/services/settings.py +++ b/src/antares/craft/service/local_services/services/settings.py @@ -33,6 +33,7 @@ SeedParametersLocal, ) from antares.craft.tools.ini_tool import IniFile, InitializationFilesTypes +from typing_extensions import override class StudySettingsLocalService(BaseStudySettingsService): @@ -41,9 +42,11 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.config = config self.study_name = study_name + @override def edit_study_settings(self, settings: StudySettingsUpdate) -> None: edit_study_settings(self.config.study_path, settings, creation=False) + @override def read_study_settings(self) -> StudySettings: return read_study_settings(self.config.study_path) diff --git a/src/antares/craft/service/local_services/st_storage_local.py b/src/antares/craft/service/local_services/st_storage_local.py index cd3e0d6e..88768704 100644 --- a/src/antares/craft/service/local_services/st_storage_local.py +++ b/src/antares/craft/service/local_services/st_storage_local.py @@ -17,6 +17,7 @@ from antares.craft.config.local_configuration import LocalConfiguration from antares.craft.model.st_storage import STStorage, STStorageMatrixName, STStorageProperties from antares.craft.service.base_services import BaseShortTermStorageService +from typing_extensions import override class ShortTermStorageLocalService(BaseShortTermStorageService): @@ -25,16 +26,20 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.config = config self.study_name = study_name + @override def update_st_storage_properties( self, st_storage: STStorage, properties: STStorageProperties ) -> STStorageProperties: raise NotImplementedError + @override def read_st_storages(self, area_id: str) -> List[STStorage]: raise NotImplementedError + @override def upload_storage_matrix(self, storage: STStorage, ts_name: STStorageMatrixName, matrix: pd.DataFrame) -> None: raise NotImplementedError + @override def get_storage_matrix(self, storage: STStorage, ts_name: STStorageMatrixName) -> pd.DataFrame: raise NotImplementedError diff --git a/src/antares/craft/service/local_services/study_local.py b/src/antares/craft/service/local_services/study_local.py index 6c73ce90..3b0e8b49 100644 --- a/src/antares/craft/service/local_services/study_local.py +++ b/src/antares/craft/service/local_services/study_local.py @@ -16,6 +16,7 @@ from antares.craft.model.binding_constraint import BindingConstraint from antares.craft.model.output import Output from antares.craft.service.base_services import BaseOutputService, BaseStudyService +from typing_extensions import override if TYPE_CHECKING: from antares.craft.model.study import Study @@ -31,10 +32,12 @@ def __init__( self._output_service: BaseOutputService = output_service @property + @override def study_id(self) -> str: return self._study_name @property + @override def config(self) -> LocalConfiguration: return self._config @@ -42,26 +45,34 @@ def config(self) -> LocalConfiguration: def output_service(self) -> BaseOutputService: return self._output_service + @override def delete_binding_constraint(self, constraint: BindingConstraint) -> None: raise NotImplementedError + @override def delete(self, children: bool) -> None: raise NotImplementedError + @override def create_variant(self, variant_name: str) -> "Study": raise NotImplementedError + @override def read_outputs(self) -> list[Output]: raise NotImplementedError + @override def delete_outputs(self) -> None: raise NotImplementedError + @override def delete_output(self, output_name: str) -> None: raise NotImplementedError + @override def move_study(self, new_parent_path: Path) -> PurePath: raise NotImplementedError + @override def generate_thermal_timeseries(self) -> None: raise NotImplementedError diff --git a/src/antares/craft/service/local_services/thermal_local.py b/src/antares/craft/service/local_services/thermal_local.py index 50e83f55..d8ded906 100644 --- a/src/antares/craft/service/local_services/thermal_local.py +++ b/src/antares/craft/service/local_services/thermal_local.py @@ -25,6 +25,7 @@ from antares.craft.tools.ini_tool import IniFile, InitializationFilesTypes from antares.craft.tools.matrix_tool import read_timeseries from antares.craft.tools.time_series_tool import TimeSeriesFileType +from typing_extensions import override class ThermalLocalService(BaseThermalService): @@ -33,11 +34,13 @@ def __init__(self, config: LocalConfiguration, study_name: str, **kwargs: Any) - self.config = config self.study_name = study_name + @override def update_thermal_properties( self, thermal_cluster: ThermalCluster, properties: ThermalClusterProperties ) -> ThermalClusterProperties: raise NotImplementedError + @override def get_thermal_matrix(self, thermal_cluster: ThermalCluster, ts_name: ThermalClusterMatrixName) -> pd.DataFrame: if ts_name.value == "series": time_serie_type = TimeSeriesFileType.THERMAL_SERIES @@ -72,6 +75,7 @@ def _extract_thermal_properties(self, thermal_data: dict[str, Any]) -> ThermalCl return ThermalClusterPropertiesLocal(**parsed_data).yield_thermal_cluster_properties() + @override def read_thermal_clusters(self, area_id: str) -> list[ThermalCluster]: thermal_dict = IniFile( self.config.study_path, InitializationFilesTypes.THERMAL_LIST_INI, area_id=area_id @@ -89,5 +93,6 @@ def read_thermal_clusters(self, area_id: str) -> list[ThermalCluster]: for thermal_data in thermal_dict.values() ] + @override def update_thermal_matrix(self, thermal_cluster: ThermalCluster, matrix: pd.DataFrame) -> None: raise NotImplementedError diff --git a/src/antares/craft/tools/contents_tool.py b/src/antares/craft/tools/contents_tool.py index 376f16f6..b98d143e 100644 --- a/src/antares/craft/tools/contents_tool.py +++ b/src/antares/craft/tools/contents_tool.py @@ -17,6 +17,7 @@ from antares.craft.tools.custom_raw_config_parser import CustomRawConfigParser from pydantic import BaseModel +from typing_extensions import override # Invalid chars was taken from Antares Simulator (C++). _sub_invalid_chars = re.compile(r"[^a-zA-Z0-9_(),& -]+").sub @@ -32,6 +33,7 @@ def transform_name_to_id(name: str) -> str: class EnumIgnoreCase(Enum): @classmethod + @override def _missing_(cls, value: object) -> Optional["EnumIgnoreCase"]: if isinstance(value, str): for member in cls: diff --git a/src/antares/craft/tools/custom_raw_config_parser.py b/src/antares/craft/tools/custom_raw_config_parser.py index 96016488..1f3c702d 100644 --- a/src/antares/craft/tools/custom_raw_config_parser.py +++ b/src/antares/craft/tools/custom_raw_config_parser.py @@ -13,6 +13,8 @@ from configparser import Interpolation, RawConfigParser from typing import TYPE_CHECKING, Any, ItemsView, Optional +from typing_extensions import override + if TYPE_CHECKING: from _typeshed import SupportsWrite @@ -31,6 +33,7 @@ def __init__(self, special_keys: Optional[list[str]] = None, **kwargs: Any) -> N self._interpolation: Interpolation # Parent version uses optionstr.lower() and we want to preserve upper- and lower-case + @override def optionxform(self, optionstr: str) -> str: return optionstr