diff --git a/antarest/study/business/binding_constraint_management.py b/antarest/study/business/binding_constraint_management.py index 181fbb5c07..bd1bb18388 100644 --- a/antarest/study/business/binding_constraint_management.py +++ b/antarest/study/business/binding_constraint_management.py @@ -391,7 +391,7 @@ def parse_constraint(key: str, value: str, char: str, new_config: ConstraintOutp return False @staticmethod - def constraint_model_adapter(constraint: ConstraintInput, version: int) -> ConstraintOutput: + def constraint_model_adapter(constraint: Mapping[str, Any], version: int) -> ConstraintOutput: """ Adapts a constraint configuration to the appropriate version-specific format. @@ -479,7 +479,7 @@ def get_binding_constraint( # If a specific constraint ID is provided, we return that constraint if filters.bc_id: - return filtered_constraints.get(filters.bc_id) + return filtered_constraints.get(filters.bc_id) # type: ignore # Else we return all the matching constraints, based on the given filters return list(filtered_constraints.values()) @@ -677,7 +677,7 @@ def update_binding_constraint( } if study_version >= 870: - updated_constraint["group"] = data.group or existing_constraint.group + updated_constraint["group"] = data.group or existing_constraint.group # type: ignore args = { **updated_constraint, @@ -836,7 +836,7 @@ def remove_constraint_term( binding_constraint_id: str, term_id: str, ) -> None: - return self.update_constraint_term(study, binding_constraint_id, term_id) + return self.update_constraint_term(study, binding_constraint_id, term_id) # type: ignore def _replace_matrices_according_to_frequency_and_version( diff --git a/antarest/study/business/table_mode_management.py b/antarest/study/business/table_mode_management.py index 45472d63b5..8a83c21047 100644 --- a/antarest/study/business/table_mode_management.py +++ b/antarest/study/business/table_mode_management.py @@ -492,7 +492,7 @@ def set_table_data( enabled=col_values.get("enabled", current_binding_dto.enabled), time_step=col_values.get("type", current_binding_dto.time_step), operator=col_values.get("operator", current_binding_dto.operator), - coeffs=BindingConstraintManager.constraints_to_coeffs(current_binding_dto), + coeffs=BindingConstraintManager.terms_to_coeffs(current_binding_dto.terms), command_context=command_context, ) ) diff --git a/tests/integration/study_data_blueprint/test_binding_constraints.py b/tests/integration/study_data_blueprint/test_binding_constraints.py index 5d6e596e68..fe1db63ed4 100644 --- a/tests/integration/study_data_blueprint/test_binding_constraints.py +++ b/tests/integration/study_data_blueprint/test_binding_constraints.py @@ -222,7 +222,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st expected = [ { "comments": "", - "terms": [], + "terms": [], "enabled": True, "filterSynthesis": "", "filterYearByYear": "", @@ -233,7 +233,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st }, { "comments": "", - "terms": [], + "terms": [], "enabled": True, "filterSynthesis": "", "filterYearByYear": "", @@ -244,7 +244,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st }, { "comments": "New API", - "terms": [], + "terms": [], "enabled": True, "filterSynthesis": "", "filterYearByYear": "", @@ -301,7 +301,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st ) assert res.status_code == 200, res.json() binding_constraint = res.json() - constraint_terms = binding_constraint["terms"] + constraint_terms = binding_constraint["terms"] expected = [ { "data": {"area1": area1_id, "area2": area2_id}, @@ -336,7 +336,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st ) assert res.status_code == 200, res.json() binding_constraint = res.json() - constraint_terms = binding_constraint["terms"] + constraint_terms = binding_constraint["terms"] expected = [ { "data": {"area1": area1_id, "area2": area2_id}, @@ -426,7 +426,7 @@ def test_lifecycle__nominal(self, client: TestClient, user_access_token: str, st # Check that the matrix is a daily/weekly matrix res = client.get( f"/v1/studies/{study_id}/raw", - params={"path": f"input/bindingconstraints/{bc_id}", "depth": 1, "formatted": True}, #type: ignore + params={"path": f"input/bindingconstraints/{bc_id}", "depth": 1, "formatted": True}, # type: ignore headers=user_headers, ) assert res.status_code == 200, res.json() @@ -657,7 +657,7 @@ def test_for_version_870(self, client: TestClient, admin_access_token: str, stud for term in ["lt", "gt", "eq"]: res = client.get( f"/v1/studies/{study_id}/raw", - params={"path": f"input/bindingconstraints/{bc_id_w_matrix}_{term}", "depth": 1, "formatted": True}, #type: ignore + params={"path": f"input/bindingconstraints/{bc_id_w_matrix}_{term}", "depth": 1, "formatted": True}, # type: ignore headers=admin_headers, ) assert res.status_code == 200 @@ -729,7 +729,7 @@ def test_for_version_870(self, client: TestClient, admin_access_token: str, stud "path": f"input/bindingconstraints/{bc_id_w_matrix}_{term_alias}", "depth": 1, "formatted": True, - }, # type: ignore + }, # type: ignore headers=admin_headers, ) assert res.status_code == 200