Skip to content

Commit 97e47fb

Browse files
committed
Bump black to 24.3.0 and format files
1 parent f432be6 commit 97e47fb

38 files changed

+155
-119
lines changed

docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""conf.py."""
2+
23
# -*- coding: utf-8 -*-
34
#
45
# napalm documentation build configuration file, created by

napalm/base/helpers.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Helper functions for the NAPALM base."""
2+
23
import ipaddress
34
import itertools
45
import logging

napalm/base/test/conftest.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test fixtures."""
2+
23
import ast
34
import json
45
import os

napalm/base/test/double.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Base class for Test doubles."""
2+
23
import json
34
import re
45
import os

napalm/base/test/getters.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Testing framework."""
2+
23
import functools
34
from itertools import zip_longest
45
import inspect

napalm/base/utils/jinja_filters.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Some common jinja filters."""
2+
23
from typing import Dict, Any
34

45

napalm/base/utils/string_parsers.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Common methods to normalize a string """
2+
23
import re
34
import struct
45
from typing import Union, List, Iterable, Dict, Optional, Tuple

napalm/base/validate.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
See: https://napalm.readthedocs.io/en/latest/validate.html
55
"""
6+
67
import yaml
78
import copy
89
import re

napalm/eos/eos.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ def get_interfaces_ip(self):
13951395
interface_details.get("linkLocal", {})
13961396
.get("subnet", "::/0")
13971397
.split("/")[-1]
1398-
)
1398+
),
13991399
# when no link-local set, address will be None and maslken 0
14001400
}
14011401
)

napalm/eos/utils/versions.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Some functions to work with EOS version numbers"""
2+
23
import re
34

45

napalm/ios/ios.py

+65-48
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""NAPALM Cisco IOS Handler."""
2+
23
# Copyright 2015 Spotify AB. All rights reserved.
34
#
45
# The contents of this file are licensed under the Apache License, Version 2.0
@@ -2100,46 +2101,54 @@ def get_bgp_neighbors_detail(self, neighbor_address=""):
21002101
"up": neigh["up"] != "never",
21012102
"local_as": napalm.base.helpers.as_number(neigh["local_as"]),
21022103
"remote_as": napalm.base.helpers.as_number(neigh["remote_as"]),
2103-
"router_id": napalm.base.helpers.ip(bgp_neigh["router_id"])
2104-
if bgp_neigh["router_id"]
2105-
else "",
2106-
"local_address": napalm.base.helpers.ip(bgp_neigh["local_address"])
2107-
if bgp_neigh["local_address"]
2108-
else "",
2104+
"router_id": (
2105+
napalm.base.helpers.ip(bgp_neigh["router_id"])
2106+
if bgp_neigh["router_id"]
2107+
else ""
2108+
),
2109+
"local_address": (
2110+
napalm.base.helpers.ip(bgp_neigh["local_address"])
2111+
if bgp_neigh["local_address"]
2112+
else ""
2113+
),
21092114
"local_address_configured": False,
2110-
"local_port": napalm.base.helpers.as_number(bgp_neigh["local_port"])
2111-
if bgp_neigh["local_port"]
2112-
else 0,
2115+
"local_port": (
2116+
napalm.base.helpers.as_number(bgp_neigh["local_port"])
2117+
if bgp_neigh["local_port"]
2118+
else 0
2119+
),
21132120
"routing_table": bgp_neigh["vrf"] if bgp_neigh["vrf"] else "global",
21142121
"remote_address": napalm.base.helpers.ip(bgp_neigh["neighbor"]),
2115-
"remote_port": napalm.base.helpers.as_number(bgp_neigh["remote_port"])
2116-
if bgp_neigh["remote_port"]
2117-
else 0,
2122+
"remote_port": (
2123+
napalm.base.helpers.as_number(bgp_neigh["remote_port"])
2124+
if bgp_neigh["remote_port"]
2125+
else 0
2126+
),
21182127
"multihop": False,
21192128
"multipath": False,
21202129
"remove_private_as": False,
21212130
"import_policy": "",
21222131
"export_policy": "",
2123-
"input_messages": napalm.base.helpers.as_number(
2124-
bgp_neigh["msg_total_in"]
2125-
)
2126-
if bgp_neigh["msg_total_in"]
2127-
else 0,
2128-
"output_messages": napalm.base.helpers.as_number(
2129-
bgp_neigh["msg_total_out"]
2130-
)
2131-
if bgp_neigh["msg_total_out"]
2132-
else 0,
2133-
"input_updates": napalm.base.helpers.as_number(
2134-
bgp_neigh["msg_update_in"]
2135-
)
2136-
if bgp_neigh["msg_update_in"]
2137-
else 0,
2138-
"output_updates": napalm.base.helpers.as_number(
2139-
bgp_neigh["msg_update_out"]
2140-
)
2141-
if bgp_neigh["msg_update_out"]
2142-
else 0,
2132+
"input_messages": (
2133+
napalm.base.helpers.as_number(bgp_neigh["msg_total_in"])
2134+
if bgp_neigh["msg_total_in"]
2135+
else 0
2136+
),
2137+
"output_messages": (
2138+
napalm.base.helpers.as_number(bgp_neigh["msg_total_out"])
2139+
if bgp_neigh["msg_total_out"]
2140+
else 0
2141+
),
2142+
"input_updates": (
2143+
napalm.base.helpers.as_number(bgp_neigh["msg_update_in"])
2144+
if bgp_neigh["msg_update_in"]
2145+
else 0
2146+
),
2147+
"output_updates": (
2148+
napalm.base.helpers.as_number(bgp_neigh["msg_update_out"])
2149+
if bgp_neigh["msg_update_out"]
2150+
else 0
2151+
),
21432152
"messages_queued_out": napalm.base.helpers.as_number(neigh["out_q"]),
21442153
"connection_state": bgp_neigh["bgp_state"],
21452154
"previous_connection_state": "",
@@ -2150,13 +2159,17 @@ def get_bgp_neighbors_detail(self, neighbor_address=""):
21502159
else False
21512160
),
21522161
"local_as_prepend": False,
2153-
"holdtime": napalm.base.helpers.as_number(bgp_neigh["holdtime"])
2154-
if bgp_neigh["holdtime"]
2155-
else 0,
2162+
"holdtime": (
2163+
napalm.base.helpers.as_number(bgp_neigh["holdtime"])
2164+
if bgp_neigh["holdtime"]
2165+
else 0
2166+
),
21562167
"configured_holdtime": 0,
2157-
"keepalive": napalm.base.helpers.as_number(bgp_neigh["keepalive"])
2158-
if bgp_neigh["keepalive"]
2159-
else 0,
2168+
"keepalive": (
2169+
napalm.base.helpers.as_number(bgp_neigh["keepalive"])
2170+
if bgp_neigh["keepalive"]
2171+
else 0
2172+
),
21602173
"configured_keepalive": 0,
21612174
"active_prefix_count": 0,
21622175
"received_prefix_count": 0,
@@ -3209,10 +3222,10 @@ def get_route_to(self, destination="", protocol="", longer=False):
32093222
# was not specified
32103223
if protocol == "" or protocol == route_entry["protocol"]:
32113224
if route_proto == "bgp":
3212-
route_entry[
3213-
"protocol_attributes"
3214-
] = self._get_bgp_route_attr(
3215-
destination, _vrf, nh, ip_version
3225+
route_entry["protocol_attributes"] = (
3226+
self._get_bgp_route_attr(
3227+
destination, _vrf, nh, ip_version
3228+
)
32163229
)
32173230
nh_line_found = (
32183231
False # for next RT entry processing ...
@@ -3305,12 +3318,16 @@ def get_users(self):
33053318
output = self._send_command(command)
33063319
for match in re.finditer(username_regex, output, re.M):
33073320
users[match.groupdict()["username"]] = {
3308-
"level": int(match.groupdict()["priv_level"])
3309-
if match.groupdict()["priv_level"]
3310-
else 1,
3311-
"password": match.groupdict()["pwd_hash"]
3312-
if match.groupdict()["pwd_hash"]
3313-
else "",
3321+
"level": (
3322+
int(match.groupdict()["priv_level"])
3323+
if match.groupdict()["priv_level"]
3324+
else 1
3325+
),
3326+
"password": (
3327+
match.groupdict()["pwd_hash"]
3328+
if match.groupdict()["pwd_hash"]
3329+
else ""
3330+
),
33143331
"sshkeys": [],
33153332
}
33163333
for match in re.finditer(pub_keychain_regex, output, re.M):

napalm/iosxr/iosxr.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ def get_interfaces(self):
318318
"is_enabled": enabled,
319319
"mac_address": mac_address,
320320
"description": description,
321-
"last_flapped": last_flapped / 1e9
322-
if last_flapped != -1.0
323-
else -1.0,
321+
"last_flapped": (
322+
last_flapped / 1e9 if last_flapped != -1.0 else -1.0
323+
),
324324
}
325325
)
326326

@@ -587,23 +587,23 @@ def generate_vrf_query(vrf_name):
587587
),
588588
0,
589589
)
590-
this_neighbor["address_family"][this_afi][
591-
"accepted_prefixes"
592-
] = napalm.base.helpers.convert(
593-
int,
594-
napalm.base.helpers.find_txt(
595-
neighbor, "AFData/Entry/PrefixesAccepted"
596-
),
597-
0,
590+
this_neighbor["address_family"][this_afi]["accepted_prefixes"] = (
591+
napalm.base.helpers.convert(
592+
int,
593+
napalm.base.helpers.find_txt(
594+
neighbor, "AFData/Entry/PrefixesAccepted"
595+
),
596+
0,
597+
)
598598
)
599-
this_neighbor["address_family"][this_afi][
600-
"sent_prefixes"
601-
] = napalm.base.helpers.convert(
602-
int,
603-
napalm.base.helpers.find_txt(
604-
neighbor, "AFData/Entry/PrefixesAdvertised"
605-
),
606-
0,
599+
this_neighbor["address_family"][this_afi]["sent_prefixes"] = (
600+
napalm.base.helpers.convert(
601+
int,
602+
napalm.base.helpers.find_txt(
603+
neighbor, "AFData/Entry/PrefixesAdvertised"
604+
),
605+
0,
606+
)
607607
)
608608
except AttributeError:
609609
this_neighbor["address_family"][this_afi]["received_prefixes"] = -1
@@ -947,11 +947,11 @@ def cli(self, commands, encoding="text"):
947947
try:
948948
cli_output[str(command)] = str(self.device._execute_show(command))
949949
except TimeoutError:
950-
cli_output[
951-
str(command)
952-
] = 'Execution of command \
950+
cli_output[str(command)] = (
951+
'Execution of command \
953952
"{command}" took too long! Please adjust your params!'.format(
954-
command=command
953+
command=command
954+
)
955955
)
956956
logger.error(str(cli_output))
957957
raise CommandTimeoutException(str(cli_output))
@@ -2288,9 +2288,9 @@ def traceroute(
22882288
last_probe_host_name = tag_value
22892289
continue
22902290
if tag_name == "DeltaTime":
2291-
last_hop_dict["probes"][last_probe_index][
2292-
"rtt"
2293-
] = napalm.base.helpers.convert(float, tag_value, 0.0)
2291+
last_hop_dict["probes"][last_probe_index]["rtt"] = (
2292+
napalm.base.helpers.convert(float, tag_value, 0.0)
2293+
)
22942294
continue
22952295

22962296
if last_hop_index:

napalm/iosxr_netconf/iosxr_netconf.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -801,30 +801,30 @@ def get_vrf_neighbors(rpc_reply_etree, xpath):
801801
),
802802
0,
803803
)
804-
this_neighbor["address_family"][this_afi][
805-
"accepted_prefixes"
806-
] = napalm.base.helpers.convert(
807-
int,
808-
self._find_txt(
809-
neighbor,
810-
"./bgp:af-data/bgp:prefixes-accepted",
811-
default="",
812-
namespaces=C.NS,
813-
),
814-
0,
804+
this_neighbor["address_family"][this_afi]["accepted_prefixes"] = (
805+
napalm.base.helpers.convert(
806+
int,
807+
self._find_txt(
808+
neighbor,
809+
"./bgp:af-data/bgp:prefixes-accepted",
810+
default="",
811+
namespaces=C.NS,
812+
),
813+
0,
814+
)
815815
)
816-
this_neighbor["address_family"][this_afi][
817-
"sent_prefixes"
818-
] = napalm.base.helpers.convert(
819-
int,
820-
self._find_txt(
821-
neighbor,
822-
"./bgp:af-data/\
816+
this_neighbor["address_family"][this_afi]["sent_prefixes"] = (
817+
napalm.base.helpers.convert(
818+
int,
819+
self._find_txt(
820+
neighbor,
821+
"./bgp:af-data/\
823822
bgp:prefixes-advertised",
824-
default="",
825-
namespaces=C.NS,
826-
),
827-
0,
823+
default="",
824+
namespaces=C.NS,
825+
),
826+
0,
827+
)
828828
)
829829
except AttributeError:
830830
this_neighbor["address_family"][this_afi]["received_prefixes"] = -1

napalm/junos/junos.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ def get_bgp_neighbors_detail(self, neighbor_address=""):
14841484
"RemovePrivateAS": "remove_private_as",
14851485
"Multipath": "multipath",
14861486
"Multihop": "multihop",
1487-
"AddressFamily": "local_address_configured"
1487+
"AddressFamily": "local_address_configured",
14881488
# 'AuthKey' : 'authentication_key_set'
14891489
# but other vendors do not specify if auth key is set
14901490
# other options:
@@ -1728,7 +1728,7 @@ def get_interfaces_ip(self):
17281728

17291729
_FAMILY_VMAP_ = {
17301730
"inet": "ipv4",
1731-
"inet6": "ipv6"
1731+
"inet6": "ipv6",
17321732
# can add more mappings
17331733
}
17341734
_FAMILY_MAX_PREFIXLEN = {"inet": 32, "inet6": 128}

napalm/junos/utils/junos_views.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Load tables/views
33
"""
4+
45
import yaml
56
import re
67
from jnpr.junos.factory import FactoryLoader

napalm/nxapi_plumbing/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Re-implemented by ktbyers to support XML-RPC in addition to JSON-RPC
55
"""
6+
67
from napalm.nxapi_plumbing.device import Device
78
from napalm.nxapi_plumbing.api_client import RPCClient, XMLClient
89
from napalm.nxapi_plumbing.errors import (

napalm/nxapi_plumbing/api_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Reimplemented by ktbyers to support XML-RPC in addition to JSON-RPC
55
"""
6+
67
from __future__ import print_function, unicode_literals
78

89
from builtins import super

0 commit comments

Comments
 (0)