Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
HomayoonAlimohammadi committed Dec 6, 2024
1 parent e8ebda2 commit 26a6630
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/manifests_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def filter_containers(self, containers: list) -> Generator:

metrics_port_config = "metricsport"
container.args = [
(f"--{metrics_port_config}={port}" if arg.startswith(f"--{metrics_port_config}=") else arg)
(
f"--{metrics_port_config}={port}"
if arg.startswith(f"--{metrics_port_config}=")
else arg
)
for arg in container.args
]
yield container
Expand Down
14 changes: 10 additions & 4 deletions src/manifests_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@

METRICS_PORT_CONFIG = "metrics-port"


class InvalidMetricsPortError(Exception):
pass


def _validate_metrics_port(metrics_ports: Dict[str, int]) -> None:
"""
Validate the metrics port.
Raises:
InvalidMetricsPortError: If the metrics port is invalid (duplicate or not in range).
"""
Expand All @@ -42,10 +44,14 @@ def _validate_metrics_port(metrics_ports: Dict[str, int]) -> None:
if value == -1:
continue

if range_min <= value <= range_max:
raise InvalidMetricsPortError(f"Invalid value for {conf}: {value}. Must be between {range_min} and {range_max}")
if range_min <= value <= range_max:
raise InvalidMetricsPortError(
f"Invalid value for {conf}: {value}. Must be between {range_min} and {range_max}"
)
if value in unique_ports:
raise InvalidMetricsPortError(f"Value for {conf}: {value} conflicts with {unique_ports[value]}")
raise InvalidMetricsPortError(
f"Value for {conf}: {value} conflicts with {unique_ports[value]}"
)
unique_ports[value] = conf


Expand Down

0 comments on commit 26a6630

Please sign in to comment.