Skip to content

Commit

Permalink
doc: Adjust Args to Parameters to comply with numpy (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc authored Jul 4, 2024
1 parent 6c43a92 commit e9aff4a
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 134 deletions.
24 changes: 12 additions & 12 deletions anta/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ def __init__(
) -> None:
"""Instantiate an AntaCatalog instance.
Args:
----
Parameters
----------
tests: A list of AntaTestDefinition instances.
filename: The path from which the catalog is loaded.
Expand Down Expand Up @@ -301,8 +301,8 @@ def tests(self, value: list[AntaTestDefinition]) -> None:
def parse(filename: str | Path) -> AntaCatalog:
"""Create an AntaCatalog instance from a test catalog file.
Args:
----
Parameters
----------
filename: Path to test catalog YAML file
"""
Expand All @@ -325,8 +325,8 @@ def from_dict(data: RawCatalogInput, filename: str | Path | None = None) -> Anta
It is the data structure returned by `yaml.load()` function of a valid
YAML Test Catalog file.
Args:
----
Parameters
----------
data: Python dictionary used to instantiate the AntaCatalog instance
filename: value to be set as AntaCatalog instance attribute
Expand Down Expand Up @@ -359,8 +359,8 @@ def from_list(data: ListAntaTestTuples) -> AntaCatalog:
See ListAntaTestTuples type alias for details.
Args:
----
Parameters
----------
data: Python list used to instantiate the AntaCatalog instance
"""
Expand All @@ -375,8 +375,8 @@ def from_list(data: ListAntaTestTuples) -> AntaCatalog:
def merge(self, catalog: AntaCatalog) -> AntaCatalog:
"""Merge two AntaCatalog instances.
Args:
----
Parameters
----------
catalog: AntaCatalog instance to merge to this instance.
Returns
Expand Down Expand Up @@ -427,8 +427,8 @@ def build_indexes(self, filtered_tests: set[str] | None = None) -> None:
def get_tests_by_tags(self, tags: set[str], *, strict: bool = False) -> set[AntaTestDefinition]:
"""Return all tests that match a given set of tags, according to the specified strictness.
Args:
----
Parameters
----------
tags: The tags to filter tests by. If empty, return all tests without tags.
strict: If True, returns only tests that contain all specified tags (intersection).
If False, returns tests that contain any of the specified tags (union).
Expand Down
8 changes: 4 additions & 4 deletions anta/cli/get/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def get_cv_token(cvp_ip: str, cvp_username: str, cvp_password: str, *, verify_ce
TODO: need to handle requests error
Args:
----
Parameters
----------
cvp_ip: IP address of CloudVision.
cvp_username: Username to connect to CloudVision.
cvp_password: Password to connect to CloudVision.
Expand Down Expand Up @@ -161,8 +161,8 @@ def deep_yaml_parsing(data: dict[str, Any], hosts: list[AntaInventoryHost] | Non
def create_inventory_from_ansible(inventory: Path, output: Path, ansible_group: str = "all") -> None:
"""Create an ANTA inventory from an Ansible inventory YAML file.
Args:
----
Parameters
----------
inventory: Ansible Inventory file to read
output: ANTA inventory file to generate.
ansible_group: Ansible group from where to extract data.
Expand Down
4 changes: 2 additions & 2 deletions anta/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def exit_with_code(ctx: click.Context) -> None:
* 1 if status is `failure`
* 2 if status is `error`.
Args:
----
Parameters
----------
ctx: Click Context
"""
Expand Down
16 changes: 8 additions & 8 deletions anta/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
def deprecated_test(new_tests: list[str] | None = None) -> Callable[[F], F]:
"""Return a decorator to log a message of WARNING severity when a test is deprecated.
Args:
----
Parameters
----------
new_tests: A list of new test classes that should replace the deprecated test.
Returns
Expand All @@ -33,8 +33,8 @@ def deprecated_test(new_tests: list[str] | None = None) -> Callable[[F], F]:
def decorator(function: F) -> F:
"""Actual decorator that logs the message.
Args:
----
Parameters
----------
function: The test function to be decorated.
Returns
Expand Down Expand Up @@ -64,8 +64,8 @@ def skip_on_platforms(platforms: list[str]) -> Callable[[F], F]:
This decorator factory generates a decorator that will check the hardware model of the device
the test is run on. If the model is in the list of platforms specified, the test will be skipped.
Args:
----
Parameters
----------
platforms: List of hardware models on which the test should be skipped.
Returns
Expand All @@ -77,8 +77,8 @@ def skip_on_platforms(platforms: list[str]) -> Callable[[F], F]:
def decorator(function: F) -> F:
"""Actual decorator that either runs the test or skips it based on the device's hardware model.
Args:
----
Parameters
----------
function: The test function to be decorated.
Returns
Expand Down
32 changes: 16 additions & 16 deletions anta/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class AntaDevice(ABC):
def __init__(self, name: str, tags: set[str] | None = None, *, disable_cache: bool = False) -> None:
"""Initialize an AntaDevice.
Args:
----
Parameters
----------
name: Device name.
tags: Tags for this device.
disable_cache: Disable caching for all commands for this device.
Expand Down Expand Up @@ -130,8 +130,8 @@ async def _collect(self, command: AntaCommand, *, collection_id: str | None = No
exception and implement proper logging, the `output` attribute of the
`AntaCommand` object passed as argument would be `None` in this case.
Args:
----
Parameters
----------
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
"""
Expand All @@ -147,8 +147,8 @@ async def collect(self, command: AntaCommand, *, collection_id: str | None = Non
When caching is NOT enabled, either at the device or command level, the method directly collects the output
via the private `_collect` method without interacting with the cache.
Args:
----
Parameters
----------
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
"""
Expand All @@ -170,8 +170,8 @@ async def collect(self, command: AntaCommand, *, collection_id: str | None = Non
async def collect_commands(self, commands: list[AntaCommand], *, collection_id: str | None = None) -> None:
"""Collect multiple commands.
Args:
----
Parameters
----------
commands: The commands to collect.
collection_id: An identifier used to build the eAPI request ID.
"""
Expand All @@ -192,8 +192,8 @@ async def copy(self, sources: list[Path], destination: Path, direction: Literal[
It is not mandatory to implement this for a valid AntaDevice subclass.
Args:
----
Parameters
----------
sources: List of files to copy to or from the device.
destination: Local or remote destination when copying the files. Can be a folder.
direction: Defines if this coroutine copies files to or from the device.
Expand Down Expand Up @@ -237,8 +237,8 @@ def __init__(
) -> None:
"""Instantiate an AsyncEOSDevice.
Args:
----
Parameters
----------
host: Device FQDN or IP.
username: Username to connect to eAPI and SSH.
password: Password to connect to eAPI and SSH.
Expand Down Expand Up @@ -313,8 +313,8 @@ async def _collect(self, command: AntaCommand, *, collection_id: str | None = No
Gain privileged access using the `enable_password` attribute
of the `AntaDevice` instance if populated.
Args:
----
Parameters
----------
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
"""
Expand Down Expand Up @@ -405,8 +405,8 @@ async def refresh(self) -> None:
async def copy(self, sources: list[Path], destination: Path, direction: Literal["to", "from"] = "from") -> None:
"""Copy files to and from the device using asyncssh.scp().
Args:
----
Parameters
----------
sources: List of files to copy to or from the device.
destination: Local or remote destination when copying the files. Can be a folder.
direction: Defines if this coroutine copies files to or from the device.
Expand Down
28 changes: 14 additions & 14 deletions anta/inventory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def __str__(self) -> str:
def _update_disable_cache(kwargs: dict[str, Any], *, inventory_disable_cache: bool) -> dict[str, Any]:
"""Return new dictionary, replacing kwargs with added disable_cache value from inventory_value if disable_cache has not been set by CLI.
Args:
----
Parameters
----------
inventory_disable_cache: The value of disable_cache in the inventory
kwargs: The kwargs to instantiate the device
Expand All @@ -62,8 +62,8 @@ def _parse_hosts(
) -> None:
"""Parse the host section of an AntaInventoryInput and add the devices to the inventory.
Args:
----
Parameters
----------
inventory_input: AntaInventoryInput used to parse the devices
inventory: AntaInventory to add the parsed devices to
**kwargs: Additional keyword arguments to pass to the device constructor
Expand Down Expand Up @@ -91,8 +91,8 @@ def _parse_networks(
) -> None:
"""Parse the network section of an AntaInventoryInput and add the devices to the inventory.
Args:
----
Parameters
----------
inventory_input: AntaInventoryInput used to parse the devices
inventory: AntaInventory to add the parsed devices to
**kwargs: Additional keyword arguments to pass to the device constructor
Expand Down Expand Up @@ -124,8 +124,8 @@ def _parse_ranges(
) -> None:
"""Parse the range section of an AntaInventoryInput and add the devices to the inventory.
Args:
----
Parameters
----------
inventory_input: AntaInventoryInput used to parse the devices
inventory: AntaInventory to add the parsed devices to
**kwargs: Additional keyword arguments to pass to the device constructor
Expand Down Expand Up @@ -175,8 +175,8 @@ def parse(
The inventory devices are AsyncEOSDevice instances.
Args:
----
Parameters
----------
filename: Path to device inventory YAML file.
username: Username to use to connect to devices.
password: Password to use to connect to devices.
Expand Down Expand Up @@ -254,8 +254,8 @@ def devices(self) -> list[AntaDevice]:
def get_inventory(self, *, established_only: bool = False, tags: set[str] | None = None, devices: set[str] | None = None) -> AntaInventory:
"""Return a filtered inventory.
Args:
----
Parameters
----------
established_only: Whether or not to include only established devices.
tags: Tags to filter devices.
devices: Names to filter devices.
Expand Down Expand Up @@ -293,8 +293,8 @@ def __setitem__(self, key: str, value: AntaDevice) -> None:
def add_device(self, device: AntaDevice) -> None:
"""Add a device to final inventory.
Args:
----
Parameters
----------
device: Device object to be added
"""
Expand Down
8 changes: 4 additions & 4 deletions anta/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def setup_logging(level: LogLevel = Log.INFO, file: Path | None = None) -> None:
If a file is provided and logging level is DEBUG, only the logging level INFO and higher will
be logged to stdout while all levels will be logged in the file.
Args:
----
Parameters
----------
level: ANTA logging level
file: Send logs to a file
Expand Down Expand Up @@ -104,8 +104,8 @@ def anta_log_exception(exception: BaseException, message: str | None = None, cal
If `anta.__DEBUG__` is True then the `logger.exception` method is called to get the traceback, otherwise `logger.error` is called.
Args:
----
Parameters
----------
exception: The Exception being logged.
message: An optional message.
calling_logger: A logger to which the exception should be logged. If not present, the logger in this file is used.
Expand Down
16 changes: 8 additions & 8 deletions anta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def render(self, **params: str | int | bool) -> AntaCommand:
Keep the parameters used in the AntaTemplate instance.
Args:
----
Parameters
----------
params: dictionary of variables with string values to render the Python f-string
Returns
Expand Down Expand Up @@ -245,8 +245,8 @@ class AntaTemplateRenderError(RuntimeError):
def __init__(self, template: AntaTemplate, key: str) -> None:
"""Initialize an AntaTemplateRenderError.
Args:
----
Parameters
----------
template: The AntaTemplate instance that failed to render
key: Key that has not been provided to render the template
Expand Down Expand Up @@ -381,8 +381,8 @@ def __init__(
) -> None:
"""AntaTest Constructor.
Args:
----
Parameters
----------
device: AntaDevice instance on which the test will be run
inputs: dictionary of attributes used to instantiate the AntaTest.Input instance
eos_data: Populate outputs of the test commands instead of collecting from devices.
Expand Down Expand Up @@ -556,8 +556,8 @@ async def wrapper(
) -> TestResult:
"""Inner function for the anta_test decorator.
Args:
----
Parameters
----------
self: The test instance.
eos_data: Populate outputs of the test commands instead of collecting from devices.
This list must have the same length and order than the `instance_commands` instance attribute.
Expand Down
Loading

0 comments on commit e9aff4a

Please sign in to comment.