Skip to content
Snippets Groups Projects
Verified Commit 40bd8735 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Reformat all docstrings from Sphinx to Google style

parent 96171bb2
No related branches found
No related tags found
1 merge request!316Replace Sphinx with MkDocs
......@@ -30,9 +30,10 @@ def prepare_state(subscription_id: UUIDstr) -> State:
@step("Verify IPAM resources for loopback interface")
def verify_ipam_loopback(subscription: Router) -> None:
"""Validate the :term:`IPAM` resources for the loopback interface.
"""Validate the IPAM resources for the loopback interface.
Raises an :class:`orchestrator.utils.errors.ProcessFailureError` if :term:`IPAM` is configured incorrectly.
Raises:
ProcessFailureError: If IPAM is configured incorrectly.
"""
host_record = infoblox.find_host_by_fqdn(f"lo0.{subscription.router.router_fqdn}")
if not host_record or str(subscription.subscription_id) not in host_record.comment:
......@@ -171,7 +172,7 @@ def verify_base_config(subscription: dict[str, Any]) -> LSOState:
def validate_router() -> StepList:
"""Validate an existing, active Router subscription.
* Verify that the loopback interface is correctly configured in :term:`IPAM`.
* Verify that the loopback interface is correctly configured in IPAM.
* Verify that the router is correctly configured in Netbox.
* Verify that the router is correctly configured in LibreNMS.
* Redeploy base config to verify the configuration is intact.
......
......@@ -33,7 +33,7 @@ def create_subscription(partner: str) -> State:
def generate_initial_input_form() -> FormGenerator:
"""Generate a form that is filled in using information passed through the :term:`API` endpoint."""
"""Generate a form that is filled in using information passed through the API endpoint."""
class ImportSite(FormPage, BaseSiteValidatorModel):
model_config = ConfigDict(title="Import Site")
......
......@@ -32,7 +32,7 @@ def create_subscription(partner: str) -> State:
def initial_input_form_generator() -> FormGenerator:
"""Generate a form that is filled in using information passed through the :term:`API` endpoint."""
"""Generate a form that is filled in using information passed through the API endpoint."""
class ImportSuperPopSwitch(FormPage):
model_config = ConfigDict(title="Import a Super PoP switch")
......
"""A modification workflow for migrating an ImportedSuperPopSwitch to a SuperPopSwitch subscription."""
"""A modification workflow for migrating an ImportedSuperPoPSwitch to a SuperPopSwitch subscription."""
from orchestrator.targets import Target
from orchestrator.types import State, UUIDstr
......
......@@ -42,7 +42,7 @@ def remove_device_from_netbox(subscription: Switch) -> None:
@step("Remove switch from IPAM")
def remove_device_from_ipam(subscription: Switch) -> None:
"""Remove the switch from :term:`IPAM`."""
"""Remove the switch from IPAM."""
delete_host_by_fqdn(subscription.switch.fqdn)
......
......@@ -96,6 +96,9 @@ select = [
"YTT"
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
......
......@@ -161,8 +161,11 @@ def db_uri():
def run_migrations(db_uri: str) -> None:
"""Configure the alembic migration and run the migration on the database.
:param str db_uri: The database uri configuration to run the migration on.
:return: None
Args:
db_uri: The database uri configuration to run the migration on.
Returns:
None
"""
path = Path(__file__).resolve().parent
app_settings.DATABASE_URI = db_uri
......@@ -183,7 +186,8 @@ def run_migrations(db_uri: str) -> None:
def _database(db_uri):
"""Create database and run migrations and cleanup after wards.
:param db_uri: The database uri configuration to run the migration on.
Args:
db_uri: The database uri configuration to run the migration on.
"""
db.update(Database(db_uri))
url = make_url(db_uri)
......@@ -236,7 +240,8 @@ def _db_session(_database):
- Each test runs in isolation with a pristine database state.
- Avoids the overhead of recreating the database schema or re-seeding data between tests.
:param _database: A fixture reference that initializes the database.
Args:
_database: A fixture reference that initializes the database.
"""
with contextlib.closing(db.wrapped_database.engine.connect()) as test_connection:
# Create a new session factory for this context.
......
......@@ -24,7 +24,8 @@ def create_subscription_for_mapping(
values: a dictionary of keys from the sub_map and their corresponding test values
kwargs: The rest of the arguments
Returns: The conforming subscription.
Returns:
The conforming subscription.
"""
def build_instance(name, value_mapping):
......
......@@ -157,10 +157,8 @@ class WorkflowInstanceForTests(LazyWorkflowInstance):
This can be as simple as merely importing a workflow function. However, if it concerns a workflow generating
function, that function will be called with or without arguments as specified.
Returns
-------
Returns:
A workflow function.
"""
self.workflow.name = self.name
return self.workflow
......
......@@ -116,7 +116,7 @@ def test_edge_port_creation_with_invalid_input(
test_client,
):
product_id = get_product_id_by_name(ProductName.EDGE_PORT)
# If the number of members is greater than 1 then :term:`LACP` must be enabled.
# If the number of members is greater than 1 then LACP must be enabled.
input_form_wizard_data[0]["enable_lacp"] = False
initial_data = [{"product": product_id}, *input_form_wizard_data]
......
......@@ -58,5 +58,5 @@ def test_validate_edge_port_success(
subscription = EdgePort.from_subscription(subscription_id)
assert subscription.status == "active"
assert mock_execute_playbook.call_count == 1
# One time for getting the :term:`LAG` and two times for getting the interfaces
# One time for getting the LAG and two times for getting the interfaces
assert mock_get_interface_by_name_and_device.call_count == 3
"""Utilities that can be used alongside :term:`GSO`."""
"""Utilities that can be used alongside GSO."""
......@@ -23,7 +23,7 @@ def convert_to_table(data: List[dict[str, Any]], fields: List[str]) -> pd.DataFr
@click.group()
def cli() -> None:
"""Instantiate a new :term:`CLI`."""
"""Instantiate a new CLI."""
@cli.group()
......@@ -116,7 +116,7 @@ def list() -> None: # noqa: A001
help="Interface speed to list interfaces (default 1000=1G)",
)
def interfaces(fqdn: str, speed: str) -> None:
"""List all interfaces that belong to a given :term:`FQDN`."""
"""List all interfaces that belong to a given FQDN."""
click.echo(f"Listing all interfaces for: device with fqdn={fqdn}, speed={speed}")
interface_list = NetboxClient().get_interfaces_by_device(fqdn, speed)
display_fields = [
......@@ -227,7 +227,7 @@ def deallocate_interface(fqdn: str, iface: str) -> None:
@click.option("--lag", help="LAG name to attach physical interface to")
@click.option("--iface", help="Interface name to attach to LAG")
def attach_interface_to_lag(fqdn: str, lag: str, iface: str) -> None:
"""Attach an interface to a :term:`LAG`."""
"""Attach an interface to a LAG."""
click.echo(f"Attaching LAG to physical interface: device={fqdn}, LAG name={lag}, interface name={iface}")
attached_iface = NetboxClient().attach_interface_to_lag(fqdn, lag, iface)
click.echo(attached_iface)
......@@ -238,7 +238,7 @@ def attach_interface_to_lag(fqdn: str, lag: str, iface: str) -> None:
@click.option("--lag", help="LAG name to detach from physical interface")
@click.option("--iface", help="Interface name to detach LAG from")
def detach_interface_from_lag(fqdn: str, lag: str, iface: str) -> None:
"""Detach an interface from a :term:`LAG`."""
"""Detach an interface from a LAG."""
click.echo(f"Detaching LAG from physical interface: device={fqdn}, LAG name={lag}, interface name={iface}")
NetboxClient().detach_interfaces_from_lag(fqdn, lag)
click.echo(f"Detached LAG from physical interface: device={fqdn}, LAG name={lag}, interface name={iface}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment