Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente committed Jun 28, 2024
1 parent 2cd1a35 commit 2fbe998
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion diode-napalm-agent/diode_napalm/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def run_driver(info: Napalm, config: DiscoveryConfig):
raise Exception(
f"Hostname {info.hostname}: Not able to discover device driver"
)
elif not info.driver in supported_drivers:
elif info.driver not in supported_drivers:
raise Exception(
f"Hostname {info.hostname}: specified driver '{info.driver}' was not found in the current supported drivers list: "
f"{supported_drivers}.\nHINT: If '{info.driver}' is a community napalm driver, try to perform the following command:"
Expand Down
2 changes: 1 addition & 1 deletion diode-napalm-agent/diode_napalm/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self):
if not hasattr(self, "diode_client"): # Prevent reinitialization
self.diode_client = None

def init_client(self, target: str, api_key: Optional[str] = None):
def init_client(self, target: str, api_key: str | None = None):
"""
Initialize the Diode client with the specified target, API key, and TLS verification.
Expand Down
5 changes: 3 additions & 2 deletions diode-napalm-agent/diode_napalm/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Copyright 2024 NetBox Labs Inc
"""Discover the correct NAPALM Driver."""

import importlib_metadata
import logging

import importlib_metadata
from napalm import get_network_driver

# Set up logging
Expand All @@ -20,11 +20,12 @@ def napalm_driver_list():
appending their names (with the 'napalm-' prefix removed and hyphens replaced
with underscores) to a list of known drivers.
Returns:
Returns
-------
List[str]: A list of strings representing the names of available NAPALM drivers.
The list includes some predefined driver names and dynamically
discovered driver names from the installed packages.
"""
napalm_packages = ["ios", "eos", "junos", "nxos"]
prefix = "napalm-"
Expand Down
12 changes: 6 additions & 6 deletions diode-napalm-agent/diode_napalm/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from pathlib import Path
from typing import Any, Dict, List, Optional
from typing import Any

import yaml
from pydantic import BaseModel, Field, ValidationError
Expand All @@ -19,27 +19,27 @@ class ParseException(Exception):
class Napalm(BaseModel):
"""Model for NAPALM configuration."""

driver: Optional[str] = Field(default=None, description="Driver name, optional")
driver: str | None = Field(default=None, description="Driver name, optional")
hostname: str
username: str
password: str
timeout: int = 60
optional_args: Optional[Dict[str, Any]] = Field(
optional_args: dict[str, Any] | None = Field(
default=None, description="Optional arguments"
)


class DiscoveryConfig(BaseModel):
"""Model for discovery configuration."""

netbox: Dict[str, str]
netbox: dict[str, str]


class Policy(BaseModel):
"""Model for a policy configuration."""

config: DiscoveryConfig
data: List[Napalm]
data: list[Napalm]


class DiodeConfig(BaseModel):
Expand All @@ -53,7 +53,7 @@ class Diode(BaseModel):
"""Model for Diode containing configuration and policies."""

config: DiodeConfig
policies: Dict[str, Policy]
policies: dict[str, Policy]


class Config(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion diode-napalm-agent/diode_napalm/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Translate from NAPALM output format to Diode SDK entities."""

import ipaddress
from typing import Iterable
from collections.abc import Iterable

from netboxlabs.diode.sdk.ingester import (
Device,
Expand Down

0 comments on commit 2fbe998

Please sign in to comment.