Skip to content

Commit

Permalink
doc: Enable D417 for ruff on top of numpy and fix asynceapi (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc authored Sep 18, 2024
1 parent 5a4cf40 commit ecef2b7
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 128 deletions.
15 changes: 14 additions & 1 deletion anta/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ def parse(filename: str | Path, file_format: Literal["yaml", "json"] = "yaml") -
file_format
Format of the file, either 'yaml' or 'json'.
Returns
-------
AntaCatalog
An AntaCatalog populated with the file content.
"""
if file_format not in ["yaml", "json"]:
message = f"'{file_format}' is not a valid format for an AntaCatalog file. Only 'yaml' and 'json' are supported."
Expand Down Expand Up @@ -356,8 +360,13 @@ def from_dict(data: RawCatalogInput, filename: str | Path | None = None) -> Anta
----------
data
Python dictionary used to instantiate the AntaCatalog instance.
filename: value to be set as AntaCatalog instance attribute
filename
value to be set as AntaCatalog instance attribute
Returns
-------
AntaCatalog
An AntaCatalog populated with the 'data' dictionary content.
"""
tests: list[AntaTestDefinition] = []
if data is None:
Expand Down Expand Up @@ -392,6 +401,10 @@ def from_list(data: ListAntaTestTuples) -> AntaCatalog:
data
Python list used to instantiate the AntaCatalog instance.
Returns
-------
AntaCatalog
An AntaCatalog populated with the 'data' list content.
"""
tests: list[AntaTestDefinition] = []
try:
Expand Down
10 changes: 5 additions & 5 deletions anta/reporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ def _color_result(self, status: AntaTestStatus) -> str:
Parameters
----------
status: AntaTestStatus enum to color.
status
AntaTestStatus enum to color.
Returns
-------
The colored string.
str
The colored string.
"""
color = RICH_COLOR_THEME.get(str(status), "")
return f"[{color}]{status}" if color != "" else str(status)
Expand All @@ -115,8 +116,7 @@ def report_all(self, manager: ResultManager, title: str = "All tests results") -
Returns
-------
Table
A fully populated rich `Table`
A fully populated rich `Table`.
"""
table = Table(title=title, show_lines=True)
headers = ["Device", "Test Name", "Test Status", "Message(s)", "Test description", "Test category"]
Expand Down
2 changes: 1 addition & 1 deletion anta/reporter/csv_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def convert_to_list(cls, result: TestResult) -> list[str]:
Parameters
----------
results
result
A TestResult to convert into list.
Returns
Expand Down
3 changes: 2 additions & 1 deletion anta/result_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ def filter_by_devices(self, devices: set[str]) -> ResultManager:
Parameters
----------
devices: Set of device names to filter the results.
devices
Set of device names to filter the results.
Returns
-------
Expand Down
2 changes: 2 additions & 0 deletions anta/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ async def setup_inventory(inventory: AntaInventory, tags: set[str] | None, devic
Tags to filter devices from the inventory.
devices
Devices on which to run tests. None means all devices.
established_only
If True use return only devices where a connection is established.
Returns
-------
Expand Down
40 changes: 24 additions & 16 deletions anta/tests/routing/isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,6 @@ def test(self) -> None:
This method performs the main test logic for verifying ISIS Segment Routing tunnels.
It checks the command output, initiates defaults, and performs various checks on the tunnels.
Returns
-------
None
"""
command_output = self.instance_commands[0].json_output
self.result.is_success()
Expand Down Expand Up @@ -647,12 +643,15 @@ def _check_tunnel_type(self, via_input: VerifyISISSegmentRoutingTunnels.Input.En
Parameters
----------
via_input (VerifyISISSegmentRoutingTunnels.Input.Entry.Vias): The input tunnel type to check.
eos_entry (dict[str, Any]): The EOS entry containing the tunnel types.
via_input : VerifyISISSegmentRoutingTunnels.Input.Entry.Vias
The input tunnel type to check.
eos_entry : dict[str, Any]
The EOS entry containing the tunnel types.
Returns
-------
bool: True if the tunnel type matches any of the tunnel types in `eos_entry`, False otherwise.
bool
True if the tunnel type matches any of the tunnel types in `eos_entry`, False otherwise.
"""
if via_input.type is not None:
return any(
Expand All @@ -672,12 +671,15 @@ def _check_tunnel_nexthop(self, via_input: VerifyISISSegmentRoutingTunnels.Input
Parameters
----------
via_input (VerifyISISSegmentRoutingTunnels.Input.Entry.Vias): The input via object.
eos_entry (dict[str, Any]): The EOS entry dictionary.
via_input : VerifyISISSegmentRoutingTunnels.Input.Entry.Vias
The input via object.
eos_entry : dict[str, Any]
The EOS entry dictionary.
Returns
-------
bool: True if the tunnel nexthop matches, False otherwise.
bool
True if the tunnel nexthop matches, False otherwise.
"""
if via_input.nexthop is not None:
return any(
Expand All @@ -697,12 +699,15 @@ def _check_tunnel_interface(self, via_input: VerifyISISSegmentRoutingTunnels.Inp
Parameters
----------
via_input (VerifyISISSegmentRoutingTunnels.Input.Entry.Vias): The input via object.
eos_entry (dict[str, Any]): The EOS entry dictionary.
via_input : VerifyISISSegmentRoutingTunnels.Input.Entry.Vias
The input via object.
eos_entry : dict[str, Any]
The EOS entry dictionary.
Returns
-------
bool: True if the tunnel interface exists, False otherwise.
bool
True if the tunnel interface exists, False otherwise.
"""
if via_input.interface is not None:
return any(
Expand All @@ -722,12 +727,15 @@ def _check_tunnel_id(self, via_input: VerifyISISSegmentRoutingTunnels.Input.Entr
Parameters
----------
via_input (VerifyISISSegmentRoutingTunnels.Input.Entry.Vias): The input vias to check.
eos_entry (dict[str, Any]): The EOS entry to compare against.
via_input : VerifyISISSegmentRoutingTunnels.Input.Entry.Vias
The input vias to check.
eos_entry : dict[str, Any])
The EOS entry to compare against.
Returns
-------
bool: True if the tunnel ID matches any of the tunnel IDs in the EOS entry's vias, False otherwise.
bool
True if the tunnel ID matches any of the tunnel IDs in the EOS entry's vias, False otherwise.
"""
if via_input.tunnel_id is not None:
return any(
Expand Down
13 changes: 9 additions & 4 deletions asynceapi/aio_portcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ async def port_check_url(url: URL, timeout: int = 5) -> bool:
"""
Open the port designated by the URL given the timeout in seconds.
If the port is available then return True; False otherwise.
Parameters
----------
url: The URL that provides the target system
timeout: Time to await for the port to open in seconds
url
The URL that provides the target system.
timeout
Time to await for the port to open in seconds.
Returns
-------
bool
If the port is available then return True; False otherwise.
"""
port = url.port or socket.getservbyname(url.scheme)

Expand Down
Loading

0 comments on commit ecef2b7

Please sign in to comment.