Skip to content

Commit

Permalink
fix(bc): correct typing in constraints service
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Mar 28, 2024
1 parent ae23954 commit b204bd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions antarest/study/business/binding_constraint_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -740,7 +740,7 @@ def update_constraint_term(

if not isinstance(constraint, ConstraintOutputBase) and not isinstance(constraint, ConstraintOutputBase):
raise BindingConstraintNotFoundError(study.id)

constraint_terms = constraint.terms # existing constraint terms
if constraint_terms is None:
raise NoConstraintError(study.id)
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion antarest/study/business/table_mode_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down

0 comments on commit b204bd9

Please sign in to comment.