Skip to content

Commit

Permalink
fix(bc): sonar blocker fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPascoli committed Jan 30, 2025
1 parent 3776096 commit 4d67159
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions antarest/study/business/model/link_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,19 @@ class FilterOption(EnumIgnoreCase):

def validate_filters(filter_value: t.List[FilterOption] | str, enum_cls: t.Type[FilterOption]) -> t.List[FilterOption]:
if isinstance(filter_value, str):
if not filter_value.strip():
filter_value = filter_value.strip()
if not filter_value:
return []

filter_accepted_values = [e for e in enum_cls]
valid_values = {str(e.value) for e in enum_cls}

options = filter_value.replace(" ", "").split(",")

invalid_options = [opt for opt in options if opt not in filter_accepted_values]
invalid_options = [opt for opt in options if opt not in valid_values]
if invalid_options:
raise LinkValidationError(
f"Invalid value(s) in filters: {', '.join(invalid_options)}. "
f"Allowed values are: {', '.join(filter_accepted_values)}."
f"Allowed values are: {', '.join(valid_values)}."
)
options_enum: t.List[FilterOption] = list(dict.fromkeys(enum_cls(opt) for opt in options))
return options_enum
Expand Down
12 changes: 6 additions & 6 deletions antarest/study/storage/variantstudy/variant_study_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def append_commands(
study_version=str(command.study_version),
# params.user cannot be None, since previous checks were successful
user_id=params.user.id, # type: ignore
updated_at=datetime.now(timezone.utc),
updated_at=datetime.utcnow(),
)
for i, command in enumerate(validated_commands)
]
Expand Down Expand Up @@ -279,7 +279,7 @@ def replace_commands(
version=command.version,
study_version=str(command.study_version),
user_id=params.user.id, # type: ignore
updated_at=datetime.now(timezone.utc),
updated_at=datetime.utcnow(),
)
for i, command in enumerate(validated_commands)
]
Expand Down Expand Up @@ -634,8 +634,8 @@ def create_variant_study(self, uuid: str, name: str, params: RequestParameters)
parent_id=uuid,
path=study_path,
public_mode=study.public_mode,
created_at=datetime.now(timezone.utc),
updated_at=datetime.now(timezone.utc),
created_at=datetime.utcnow(),
updated_at=datetime.utcnow(),
version=study.version,
folder=(re.sub(study.id, new_id, study.folder) if study.folder is not None else None),
groups=study.groups, # Create inherit_group boolean
Expand Down Expand Up @@ -935,8 +935,8 @@ def copy(
parent_id=src_meta.parent_id,
path=study_path,
public_mode=PublicMode.NONE if groups else PublicMode.READ,
created_at=datetime.now(timezone.utc),
updated_at=datetime.now(timezone.utc),
created_at=datetime.utcnow(),
updated_at=datetime.utcnow(),
version=src_meta.version,
groups=groups,
snapshot=None,
Expand Down

0 comments on commit 4d67159

Please sign in to comment.