Skip to content

Commit

Permalink
Doc: Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc committed Sep 10, 2024
1 parent a01f4d3 commit c5033b6
Show file tree
Hide file tree
Showing 25 changed files with 197 additions and 208 deletions.
20 changes: 10 additions & 10 deletions anta/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ def __init__(
Parameters
----------
tests: A list of AntaTestDefinition instances.
filename: The path from which the catalog is loaded.
tests: A list of AntaTestDefinition instances.
filename: The path from which the catalog is loaded.
"""
self._tests: list[AntaTestDefinition] = []
Expand Down Expand Up @@ -312,8 +312,8 @@ def parse(filename: str | Path, file_format: Literal["yaml", "json"] = "yaml") -
Parameters
----------
filename: Path to test catalog YAML or JSON fil
file_format: Format of the file, either 'yaml' or 'json'
filename: Path to test catalog YAML or JSON fil
file_format: Format of the file, either 'yaml' or 'json'
"""
if file_format not in ["yaml", "json"]:
Expand Down Expand Up @@ -341,8 +341,8 @@ def from_dict(data: RawCatalogInput, filename: str | Path | None = None) -> Anta
Parameters
----------
data: Python dictionary used to instantiate the AntaCatalog instance
filename: value to be set as AntaCatalog instance attribute
data: Python dictionary used to instantiate the AntaCatalog instance
filename: value to be set as AntaCatalog instance attribute
"""
tests: list[AntaTestDefinition] = []
Expand Down Expand Up @@ -375,7 +375,7 @@ def from_list(data: ListAntaTestTuples) -> AntaCatalog:
Parameters
----------
data: Python list used to instantiate the AntaCatalog instance
data: Python list used to instantiate the AntaCatalog instance
"""
tests: list[AntaTestDefinition] = []
Expand All @@ -391,7 +391,7 @@ def merge(self, catalog: AntaCatalog) -> AntaCatalog:
Parameters
----------
catalog: AntaCatalog instance to merge to this instance.
catalog: AntaCatalog instance to merge to this instance.
Returns
-------
Expand Down Expand Up @@ -443,8 +443,8 @@ def get_tests_by_tags(self, tags: set[str], *, strict: bool = False) -> set[Anta
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).
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).
Returns
Expand Down
60 changes: 30 additions & 30 deletions anta/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def __init__(self, name: str, tags: set[str] | None = None, *, disable_cache: bo
Parameters
----------
name: Device name.
tags: Tags for this device.
disable_cache: Disable caching for all commands for this device.
name: Device name.
tags: Tags for this device.
disable_cache: Disable caching for all commands for this device.
"""
self.name: str = name
Expand Down Expand Up @@ -132,8 +132,8 @@ async def _collect(self, command: AntaCommand, *, collection_id: str | None = No
Parameters
----------
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
"""

async def collect(self, command: AntaCommand, *, collection_id: str | None = None) -> None:
Expand All @@ -149,8 +149,8 @@ async def collect(self, command: AntaCommand, *, collection_id: str | None = Non
Parameters
----------
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
"""
# Need to ignore pylint no-member as Cache is a proxy class and pylint is not smart enough
# https://github.com/pylint-dev/pylint/issues/7258
Expand All @@ -172,8 +172,8 @@ async def collect_commands(self, commands: list[AntaCommand], *, collection_id:
Parameters
----------
commands: The commands to collect.
collection_id: An identifier used to build the eAPI request ID.
commands: The commands to collect.
collection_id: An identifier used to build the eAPI request ID.
"""
await asyncio.gather(*(self.collect(command=command, collection_id=collection_id) for command in commands))

Expand All @@ -194,9 +194,9 @@ async def copy(self, sources: list[Path], destination: Path, direction: Literal[
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.
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.
"""
_ = (sources, destination, direction)
Expand Down Expand Up @@ -239,19 +239,19 @@ def __init__(
Parameters
----------
host: Device FQDN or IP.
username: Username to connect to eAPI and SSH.
password: Password to connect to eAPI and SSH.
name: Device name.
enable: Collect commands using privileged mode.
enable_password: Password used to gain privileged access on EOS.
port: eAPI port. Defaults to 80 is proto is 'http' or 443 if proto is 'https'.
ssh_port: SSH port.
tags: Tags for this device.
timeout: Timeout value in seconds for outgoing API calls.
insecure: Disable SSH Host Key validation.
proto: eAPI protocol. Value can be 'http' or 'https'.
disable_cache: Disable caching for all commands for this device.
host: Device FQDN or IP.
username: Username to connect to eAPI and SSH.
password: Password to connect to eAPI and SSH.
name: Device name.
enable: Collect commands using privileged mode.
enable_password: Password used to gain privileged access on EOS.
port: eAPI port. Defaults to 80 is proto is 'http' or 443 if proto is 'https'.
ssh_port: SSH port.
tags: Tags for this device.
timeout: Timeout value in seconds for outgoing API calls.
insecure: Disable SSH Host Key validation.
proto: eAPI protocol. Value can be 'http' or 'https'.
disable_cache: Disable caching for all commands for this device.
"""
if host is None:
Expand Down Expand Up @@ -315,8 +315,8 @@ async def _collect(self, command: AntaCommand, *, collection_id: str | None = No
Parameters
----------
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
command: The command to collect.
collection_id: An identifier used to build the eAPI request ID.
"""
commands: list[dict[str, str | int]] = []
if self.enable and self._enable_password is not None:
Expand Down Expand Up @@ -407,9 +407,9 @@ async def copy(self, sources: list[Path], destination: Path, direction: Literal[
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.
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.
"""
async with asyncssh.connect(
Expand Down
56 changes: 28 additions & 28 deletions anta/inventory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def _update_disable_cache(kwargs: dict[str, Any], *, inventory_disable_cache: bo
Parameters
----------
inventory_disable_cache: The value of disable_cache in the inventory
kwargs: The kwargs to instantiate the device
inventory_disable_cache: The value of disable_cache in the inventory
kwargs: The kwargs to instantiate the device
"""
updated_kwargs = kwargs.copy()
Expand All @@ -64,9 +64,9 @@ def _parse_hosts(
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
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
"""
if inventory_input.hosts is None:
Expand All @@ -93,13 +93,13 @@ def _parse_networks(
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
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
Raises
------
InventoryIncorrectSchemaError: Inventory file is not following AntaInventory Schema.
InventoryIncorrectSchemaError: Inventory file is not following AntaInventory Schema.
"""
if inventory_input.networks is None:
Expand All @@ -126,13 +126,13 @@ def _parse_ranges(
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
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
Raises
------
InventoryIncorrectSchemaError: Inventory file is not following AntaInventory Schema.
InventoryIncorrectSchemaError: Inventory file is not following AntaInventory Schema.
"""
if inventory_input.ranges is None:
Expand Down Expand Up @@ -177,19 +177,19 @@ def parse(
Parameters
----------
filename: Path to device inventory YAML file.
username: Username to use to connect to devices.
password: Password to use to connect to devices.
enable_password: Enable password to use if required.
timeout: Timeout value in seconds for outgoing API calls.
enable: Whether or not the commands need to be run in enable mode towards the devices.
insecure: Disable SSH Host Key validation.
disable_cache: Disable cache globally.
filename: Path to device inventory YAML file.
username: Username to use to connect to devices.
password: Password to use to connect to devices.
enable_password: Enable password to use if required.
timeout: Timeout value in seconds for outgoing API calls.
enable: Whether or not the commands need to be run in enable mode towards the devices.
insecure: Disable SSH Host Key validation.
disable_cache: Disable cache globally.
Raises
------
InventoryRootKeyError: Root key of inventory is missing.
InventoryIncorrectSchemaError: Inventory file is not following AntaInventory Schema.
InventoryRootKeyError: Root key of inventory is missing.
InventoryIncorrectSchemaError: Inventory file is not following AntaInventory Schema.
"""
inventory = AntaInventory()
Expand Down Expand Up @@ -256,13 +256,13 @@ def get_inventory(self, *, established_only: bool = False, tags: set[str] | None
Parameters
----------
established_only: Whether or not to include only established devices.
tags: Tags to filter devices.
devices: Names to filter devices.
established_only: Whether or not to include only established devices.
tags: Tags to filter devices.
devices: Names to filter devices.
Returns
-------
An inventory with filtered AntaDevice objects.
An inventory with filtered AntaDevice objects.
"""

def _filter_devices(device: AntaDevice) -> bool:
Expand Down Expand Up @@ -295,7 +295,7 @@ def add_device(self, device: AntaDevice) -> None:
Parameters
----------
device: Device object to be added
device: Device object to be added
"""
self[device.name] = device
Expand Down
22 changes: 11 additions & 11 deletions anta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def render(self, **params: str | int | bool) -> AntaCommand:
Parameters
----------
params: dictionary of variables with string values to render the Python f-string
params: dictionary of variables with string values to render the Python f-string
Returns
-------
Expand Down Expand Up @@ -247,8 +247,8 @@ def __init__(self, template: AntaTemplate, key: str) -> None:
Parameters
----------
template: The AntaTemplate instance that failed to render
key: Key that has not been provided to render the template
template: The AntaTemplate instance that failed to render
key: Key that has not been provided to render the template
"""
self.template = template
Expand Down Expand Up @@ -383,10 +383,10 @@ def __init__(
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.
This list must have the same length and order than the `instance_commands` instance attribute.
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.
This list must have the same length and order than the `instance_commands` instance attribute.
"""
self.logger: logging.Logger = logging.getLogger(f"{self.module}.{self.__class__.__name__}")
self.device: AntaDevice = device
Expand Down Expand Up @@ -558,10 +558,10 @@ async def wrapper(
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.
kwargs: Any keyword argument to pass to the test.
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.
kwargs: Any keyword argument to pass to the test.
Returns
-------
Expand Down
Loading

0 comments on commit c5033b6

Please sign in to comment.