From e5e5411ea5f589fb10e52dfcd9eb433953fb7189 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Tue, 26 Nov 2024 11:25:44 +0000 Subject: [PATCH] flake8 --- spalloc_client/job.py | 4 ++-- spalloc_client/scripts/job.py | 4 ++-- spalloc_client/scripts/ps.py | 2 +- spalloc_client/scripts/support.py | 2 +- spalloc_client/spalloc_config.py | 12 +++++++----- tests/test_config.py | 2 +- tests/test_job.py | 1 - 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/spalloc_client/job.py b/spalloc_client/job.py index 164101529..ae6d5695a 100644 --- a/spalloc_client/job.py +++ b/spalloc_client/job.py @@ -249,8 +249,8 @@ def __init__(self, *args: int, **kwargs: Union[float, str, None]): hostname = cast(str, kwargs.get("hostname", config.hostname)) owner = kwargs.get("owner", config.owner) port = cast(int, kwargs.get("port", config.port)) - self._reconnect_delay = cast(float, kwargs.get("reconnect_delay", - config.reconnect_delay)) + self._reconnect_delay = cast( + float, kwargs.get("reconnect_delay", config.reconnect_delay)) self._timeout = cast(float, kwargs.get("timeout", config.timeout)) if hostname is None: raise ValueError("A hostname must be specified.") diff --git a/spalloc_client/scripts/job.py b/spalloc_client/scripts/job.py index 8022c17e4..cdb8edfe6 100644 --- a/spalloc_client/scripts/job.py +++ b/spalloc_client/scripts/job.py @@ -95,8 +95,8 @@ def _state_name(mapping: JsonObject) -> str: return state.name # pylint: disable=no-member -def show_job_info(t: Terminal, client: ProtocolClient, timeout: Optional[float], - job_id: int) -> None: +def show_job_info(t: Terminal, client: ProtocolClient, + timeout: Optional[float], job_id: int) -> None: """ Print a human-readable overview of a Job's attributes. Parameters diff --git a/spalloc_client/scripts/ps.py b/spalloc_client/scripts/ps.py index 3cb094af6..f29391730 100644 --- a/spalloc_client/scripts/ps.py +++ b/spalloc_client/scripts/ps.py @@ -27,7 +27,7 @@ import argparse from collections.abc import Sized import sys -from typing import cast, Dict, Union +from typing import cast, Union from spinn_utilities.overrides import overrides from spinn_utilities.typing.json import JsonObjectArray diff --git a/spalloc_client/scripts/support.py b/spalloc_client/scripts/support.py index 49e3a2a56..c93008db2 100644 --- a/spalloc_client/scripts/support.py +++ b/spalloc_client/scripts/support.py @@ -14,7 +14,7 @@ from argparse import ArgumentParser, Namespace import sys -from typing import Any, Dict, Optional +from typing import Any, Optional from spinn_utilities.abstract_base import AbstractBase, abstractmethod from spalloc_client import ( ProtocolClient, ProtocolError, ProtocolTimeoutError, diff --git a/spalloc_client/spalloc_config.py b/spalloc_client/spalloc_config.py index 2179b64df..51718ab25 100644 --- a/spalloc_client/spalloc_config.py +++ b/spalloc_client/spalloc_config.py @@ -81,7 +81,7 @@ """ import configparser import os.path -from typing import Any, Dict, List, Optional, Union +from typing import List, Optional import appdirs @@ -154,13 +154,14 @@ class SpallocConfig(object): "_tags", "_timeout") def __init__(self, filenames: Optional[List[str]] = None): - """ Attempt to read local configuration files to determine spalloc client - settings. + """ Attempt to read local configuration files + to determine spalloc client settings. Parameters ---------- filenames : [str, ...] - Filenames to attempt to read. Later config file have higher priority. + Filenames to attempt to read. + Later config file have higher priority. """ if filenames is None: # pragma: no cover @@ -181,7 +182,7 @@ def __init__(self, filenames: Optional[List[str]] = None): # File did not exist, keep trying pass - self._hostname = _read_any_str(parser, "hostname") + self._hostname = _read_any_str(parser, "hostname") self._owner = _read_any_str(parser, "owner") self._port = parser.getint(SECTION, "port") self._keepalive = _read_none_or_float(parser, "keepalive") @@ -250,6 +251,7 @@ def tags(self) -> Optional[List[str]]: def timeout(self) -> Optional[float]: return self._timeout + if __name__ == "__main__": # pragma: no cover print("Default search path (lowest-priority first):") print("\n".join(SEARCH_PATH)) diff --git a/tests/test_config.py b/tests/test_config.py index ce9e9dae8..fa44e6b25 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -16,7 +16,7 @@ import shutil import os.path import pytest -from spalloc_client.spalloc_config import SpallocConfig, TIMEOUT +from spalloc_client.spalloc_config import SpallocConfig @pytest.yield_fixture diff --git a/tests/test_job.py b/tests/test_job.py index 752f9b909..974bd375d 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -76,7 +76,6 @@ def test_args_from_config(self, basic_config_file, client, basic_job_kwargs.pop("port") basic_job_kwargs.pop("reconnect_delay") assert len(client.create_job.mock_calls) == 1 - a = client.create_job args = client.create_job.mock_calls[0][1] kwargs = client.create_job.mock_calls[0][2] assert args == tuple()