Skip to content

Commit cf137bd

Browse files
committed
format and lint
1 parent 7b06930 commit cf137bd

23 files changed

Lines changed: 60 additions & 50 deletions

File tree

hyperglass/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""hyperglass API."""
2+
23
# Standard Library
34
import logging
45

hyperglass/cli/echo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Helper functions for CLI message printing."""
2+
23
# Standard Library
34
import typing as t
45

hyperglass/cli/main.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def run():
3333
def _version(
3434
version: t.Optional[bool] = typer.Option(
3535
None, "--version", help="hyperglass version", callback=_version
36-
)
36+
),
3737
) -> None:
3838
"""hyperglass"""
3939
pass
@@ -77,7 +77,6 @@ def _build_ui(timeout: int = typer.Option(180, help="Timeout in seconds")) -> No
7777
with echo._console.status(
7878
f"Starting new UI build with a {timeout} second timeout...", spinner="aesthetic"
7979
):
80-
8180
_build_ui(timeout=120)
8281

8382

@@ -140,7 +139,7 @@ def _clear_cache():
140139

141140
@cli.command(name="devices")
142141
def _devices(
143-
search: t.Optional[str] = typer.Argument(None, help="Device ID or Name Search Pattern")
142+
search: t.Optional[str] = typer.Argument(None, help="Device ID or Name Search Pattern"),
144143
):
145144
"""Show all configured devices"""
146145
# Third Party
@@ -189,7 +188,7 @@ def _devices(
189188

190189
@cli.command(name="directives")
191190
def _directives(
192-
search: t.Optional[str] = typer.Argument(None, help="Directive ID or Name Search Pattern")
191+
search: t.Optional[str] = typer.Argument(None, help="Directive ID or Name Search Pattern"),
193192
):
194193
"""Show all configured devices"""
195194
# Third Party
@@ -280,7 +279,7 @@ def _plugins(
280279
def _params(
281280
path: t.Optional[str] = typer.Argument(
282281
None, help="Parameter Object Path, for example 'messages.no_input'"
283-
)
282+
),
284283
):
285284
"""Show configuration parameters"""
286285
# Standard Library
@@ -312,7 +311,7 @@ def _params(
312311
)
313312
raise typer.Exit(0)
314313
except AttributeError:
315-
echo.error(f"{'params.'+path!r} does not exist")
314+
echo.error(f"{'params.' + path!r} does not exist")
316315
raise typer.Exit(1)
317316

318317
panel = Inspect(

hyperglass/exceptions/_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Standard Library
44
import json as _json
5-
from typing import Any, Dict, List, Union, Literal, Optional, Set
5+
from typing import Any, Set, Dict, List, Union, Literal, Optional
66

77
# Third Party
88
from pydantic import ValidationError
@@ -72,7 +72,7 @@ def _parse_pydantic_errors(*errors: Dict[str, Any]) -> str:
7272

7373
for err in errors:
7474
loc = " → ".join(str(loc) for loc in err["loc"])
75-
errs += (f'Field: {loc}\n Error: {err["msg"]}\n',)
75+
errs += (f"Field: {loc}\n Error: {err['msg']}\n",)
7676

7777
return "\n".join(errs)
7878

hyperglass/execution/drivers/_construct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def format(self, command: str) -> str:
9494
for key in [k for k in keys if k != "target" and k != "mask"]:
9595
if key not in attrs:
9696
raise ConfigError(
97-
("Command '{c}' has attribute '{k}', " "which is missing from device '{d}'"),
97+
("Command '{c}' has attribute '{k}', which is missing from device '{d}'"),
9898
level="danger",
9999
c=self.directive.name,
100100
k=key,
@@ -224,4 +224,4 @@ def _bird_bgp_aspath(self, target: str) -> str:
224224
def _bird_bgp_community(self, target: str) -> str:
225225
"""Convert from standard community format to BIRD format."""
226226
parts = target.split(":")
227-
return f'({",".join(parts)})'
227+
return f"({','.join(parts)})"

hyperglass/execution/drivers/ssh.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def opener():
4444
if proxy.credential._method == "encrypted_key":
4545
# If the key is encrypted, use the password field as the
4646
# private key password.
47-
tunnel_kwargs[
48-
"ssh_private_key_password"
49-
] = proxy.credential.password.get_secret_value()
47+
tunnel_kwargs["ssh_private_key_password"] = (
48+
proxy.credential.password.get_secret_value()
49+
)
5050
try:
5151
return open_tunnel(proxy._target, proxy.port, **tunnel_kwargs)
5252

hyperglass/external/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def _build_request(self: "BaseExternal", **kwargs: t.Any) -> t.Dict[str, t.Any]:
212212

213213
if method.upper() not in supported_methods:
214214
raise self._exception(
215-
f'Method must be one of {", ".join(supported_methods)}. ' f"Got: {str(method)}"
215+
f"Method must be one of {', '.join(supported_methods)}. Got: {str(method)}"
216216
)
217217

218218
endpoint = "/".join(
@@ -284,7 +284,7 @@ async def _arequest( # noqa: C901
284284
status = httpx.codes(response.status_code)
285285
error = self._parse_response(response)
286286
raise self._exception(
287-
f'{status.name.replace("_", " ")}: {error}', level="danger"
287+
f"{status.name.replace('_', ' ')}: {error}", level="danger"
288288
) from None
289289

290290
except httpx.HTTPError as http_err:
@@ -340,7 +340,7 @@ def _request( # noqa: C901
340340
status = httpx.codes(response.status_code)
341341
error = self._parse_response(response)
342342
raise self._exception(
343-
f'{status.name.replace("_", " ")}: {error}', level="danger"
343+
f"{status.name.replace('_', ' ')}: {error}", level="danger"
344344
) from None
345345

346346
except httpx.HTTPError as http_err:

hyperglass/external/bgptools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def default_ip_targets(*targets: str) -> t.Tuple[TargetData, t.Tuple[str, ...]]:
3535
default_data = {}
3636
query = ()
3737
for target in targets:
38-
detail: TargetDetail = {k: "None" for k in DEFAULT_KEYS}
38+
detail: TargetDetail = dict.fromkeys(DEFAULT_KEYS, "None")
3939
try:
4040
valid: t.Union[IPv4Address, IPv6Address] = ip_address(target)
4141

@@ -139,7 +139,7 @@ async def network_info(*targets: str) -> TargetData:
139139
cache = use_state("cache")
140140

141141
# Set default data structure.
142-
query_data = {t: {k: "" for k in DEFAULT_KEYS} for t in query_targets}
142+
query_data = {t: dict.fromkeys(DEFAULT_KEYS, "") for t in query_targets}
143143

144144
# Get all cached bgp.tools data.
145145
cached = cache.get_map(CACHE_KEY) or {}

hyperglass/external/tests/test_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test external http client."""
2+
23
# Standard Library
34
import asyncio
45

hyperglass/external/tests/test_bgptools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# Ignore asyncio deprecation warning about loop
1717
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
1818
def test_network_info():
19-
2019
checks = (
2120
("192.0.2.1", {"asn": "None", "rir": "Private Address"}),
2221
("127.0.0.1", {"asn": "None", "rir": "Loopback Address"}),

0 commit comments

Comments
 (0)