diff --git a/contrib/analysis/sos_collection.py b/contrib/analysis/sos_collection.py index f43178c362..725343d65e 100644 --- a/contrib/analysis/sos_collection.py +++ b/contrib/analysis/sos_collection.py @@ -333,10 +333,10 @@ def sync_process_sos(self, combined_data: dict): else: self.seen_sos_valid[sosreport] = extracted_sos_data else: - combined_data["sosreports"][sosreport][ - "extracted_sos" - ] = self.seen_sos_invalid[sosreport] + combined_data["sosreports"][sosreport]["extracted_sos"] = ( + self.seen_sos_invalid[sosreport] + ) else: - combined_data["sosreports"][sosreport][ - "extracted_sos" - ] = self.seen_sos_valid[sosreport] + combined_data["sosreports"][sosreport]["extracted_sos"] = ( + self.seen_sos_valid[sosreport] + ) diff --git a/lib/pbench/__init__.py b/lib/pbench/__init__.py index f55ba535e9..48901ee5c6 100644 --- a/lib/pbench/__init__.py +++ b/lib/pbench/__init__.py @@ -32,7 +32,7 @@ def __init__(self, cfg_name): try: self.logger_host = self._conf.get("logging", "logger_host") self.logger_port = self._conf.get("logging", "logger_port") - except (NoOptionError) as exc: + except NoOptionError as exc: raise BadConfig(str(exc)) try: diff --git a/lib/pbench/agent/redis_utils.py b/lib/pbench/agent/redis_utils.py index 1a54755ee9..89e96d73a5 100644 --- a/lib/pbench/agent/redis_utils.py +++ b/lib/pbench/agent/redis_utils.py @@ -1,5 +1,6 @@ """Redis Convenience classes """ + import json import logging import time diff --git a/lib/pbench/agent/tool_meister.py b/lib/pbench/agent/tool_meister.py index 572f54ef96..e73a14933b 100644 --- a/lib/pbench/agent/tool_meister.py +++ b/lib/pbench/agent/tool_meister.py @@ -1779,9 +1779,7 @@ def sysinfo(self, data: Dict[str, str]) -> int: self._send_client_status( "success" if failures == 0 - else f"{failures} failures sending sysinfo data" - if not msg - else msg + else f"{failures} failures sending sysinfo data" if not msg else msg ) return failures diff --git a/lib/pbench/agent/tool_meister_start.py b/lib/pbench/agent/tool_meister_start.py index 67bc692cb3..7ca46a510d 100644 --- a/lib/pbench/agent/tool_meister_start.py +++ b/lib/pbench/agent/tool_meister_start.py @@ -1105,9 +1105,11 @@ def start(_prog: str, cli_params: Namespace) -> int: tm = dict( benchmark_run_dir=str(benchmark_run_dir), channel_prefix=cli_tm_channel_prefix, - tds_hostname=params["origin_host"] - if "origin_host" in params - else tool_data_sink.host, + tds_hostname=( + params["origin_host"] + if "origin_host" in params + else tool_data_sink.host + ), tds_port=tool_data_sink.port, controller=full_hostname, tool_group=tool_group.name, diff --git a/lib/pbench/agent/toolmetadata.py b/lib/pbench/agent/toolmetadata.py index b671511ab4..7513fb4ea3 100644 --- a/lib/pbench/agent/toolmetadata.py +++ b/lib/pbench/agent/toolmetadata.py @@ -2,6 +2,7 @@ Classes for working with and manipulating the tool-scripts/meta.json file. """ + import json diff --git a/lib/pbench/cli/agent/commands/results/clear.py b/lib/pbench/cli/agent/commands/results/clear.py index 8952c0630f..77f3be2502 100644 --- a/lib/pbench/cli/agent/commands/results/clear.py +++ b/lib/pbench/cli/agent/commands/results/clear.py @@ -1,6 +1,7 @@ """ pbench-clear-results """ + import shutil import sys diff --git a/lib/pbench/cli/agent/commands/triggers/list.py b/lib/pbench/cli/agent/commands/triggers/list.py index e8f22fe3e7..6cbd1660ec 100644 --- a/lib/pbench/cli/agent/commands/triggers/list.py +++ b/lib/pbench/cli/agent/commands/triggers/list.py @@ -5,6 +5,7 @@ triggers from a specific group. """ + import sys import click diff --git a/lib/pbench/cli/agent/commands/triggers/register.py b/lib/pbench/cli/agent/commands/triggers/register.py index 6e3353c930..17127801a7 100644 --- a/lib/pbench/cli/agent/commands/triggers/register.py +++ b/lib/pbench/cli/agent/commands/triggers/register.py @@ -10,6 +10,7 @@ directory. """ + import logging import sys diff --git a/lib/pbench/common/configtools.py b/lib/pbench/common/configtools.py index 278a2f56f5..95b00975f1 100644 --- a/lib/pbench/common/configtools.py +++ b/lib/pbench/common/configtools.py @@ -1,4 +1,5 @@ """ Configtools """ + from __future__ import print_function # python3 @@ -34,9 +35,11 @@ def file_list(root): rootdir = os.path.dirname(root) flist = [root] dirlist = [ - os.path.abspath("%s/%s" % (rootdir, x)) - if not os.path.isabs(x) - else os.path.abspath(x) + ( + os.path.abspath("%s/%s" % (rootdir, x)) + if not os.path.isabs(x) + else os.path.abspath(x) + ) for x in dirlist ] # insert the directory of the root file at the beginning @@ -221,7 +224,7 @@ def main(conf, args, opts, files): print("[%s]" % sec) items = conf.items(sec) items.sort() - for (n, v) in items: + for n, v in items: print("%s = %s" % (n, v)) print() return 0 diff --git a/lib/pbench/common/selinux.py b/lib/pbench/common/selinux.py index 6d72d87123..e6077b40ee 100644 --- a/lib/pbench/common/selinux.py +++ b/lib/pbench/common/selinux.py @@ -12,6 +12,7 @@ [1] https://github.com/pycontribs/selinux """ + try: import selinux except ImportError: diff --git a/lib/pbench/common/utils.py b/lib/pbench/common/utils.py index 92bba046a7..3806f326db 100644 --- a/lib/pbench/common/utils.py +++ b/lib/pbench/common/utils.py @@ -1,6 +1,7 @@ """ Utility functions common to both agent and server. """ + from collections import deque from functools import partial import hashlib diff --git a/lib/pbench/server/database/__init__.py b/lib/pbench/server/database/__init__.py index 3c17a45f2a..53a45d3f68 100644 --- a/lib/pbench/server/database/__init__.py +++ b/lib/pbench/server/database/__init__.py @@ -3,6 +3,7 @@ For any new database model added in the models directory an import statement of the same is required here. """ + from pbench.server.database.database import Database from pbench.server.database.models.api_keys import APIKey # noqa F401 from pbench.server.database.models.audit import Audit # noqa F401 diff --git a/lib/pbench/server/database/alembic/versions/1a91bc68d6de_update_api_key.py b/lib/pbench/server/database/alembic/versions/1a91bc68d6de_update_api_key.py index 8b05f896cd..2b61030cb8 100644 --- a/lib/pbench/server/database/alembic/versions/1a91bc68d6de_update_api_key.py +++ b/lib/pbench/server/database/alembic/versions/1a91bc68d6de_update_api_key.py @@ -6,6 +6,7 @@ Create Date: 2023-05-03 09:50:29.609672 """ + from alembic import op import sqlalchemy as sa diff --git a/lib/pbench/server/database/alembic/versions/313cfbf6e74b_index_map.py b/lib/pbench/server/database/alembic/versions/313cfbf6e74b_index_map.py index b9fba81e0d..3bf61442b3 100644 --- a/lib/pbench/server/database/alembic/versions/313cfbf6e74b_index_map.py +++ b/lib/pbench/server/database/alembic/versions/313cfbf6e74b_index_map.py @@ -5,6 +5,7 @@ Create Date: 2023-08-10 20:31:22.937542 """ + from alembic import op import sqlalchemy as sa diff --git a/lib/pbench/server/database/alembic/versions/558608818623_warningstate.py b/lib/pbench/server/database/alembic/versions/558608818623_warningstate.py index 12d4b68f1b..e527b7232b 100644 --- a/lib/pbench/server/database/alembic/versions/558608818623_warningstate.py +++ b/lib/pbench/server/database/alembic/versions/558608818623_warningstate.py @@ -7,6 +7,7 @@ Create Date: 2024-04-03 12:07:47.018612 """ + from alembic import op # revision identifiers, used by Alembic. diff --git a/lib/pbench/server/database/alembic/versions/5679217a62bb_sync_message.py b/lib/pbench/server/database/alembic/versions/5679217a62bb_sync_message.py index dae9de2288..b2e6284e98 100644 --- a/lib/pbench/server/database/alembic/versions/5679217a62bb_sync_message.py +++ b/lib/pbench/server/database/alembic/versions/5679217a62bb_sync_message.py @@ -5,6 +5,7 @@ Create Date: 2023-04-18 20:03:26.080554 """ + from alembic import op import sqlalchemy as sa diff --git a/lib/pbench/server/database/alembic/versions/80c8c690f09b_api_key.py b/lib/pbench/server/database/alembic/versions/80c8c690f09b_api_key.py index 237dd74996..540c4b758e 100644 --- a/lib/pbench/server/database/alembic/versions/80c8c690f09b_api_key.py +++ b/lib/pbench/server/database/alembic/versions/80c8c690f09b_api_key.py @@ -6,6 +6,7 @@ Create Date: 2023-04-11 19:20:36.892126 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql diff --git a/lib/pbench/server/database/alembic/versions/9cc638cb865c_operationname.py b/lib/pbench/server/database/alembic/versions/9cc638cb865c_operationname.py index 26a857c2f4..ba7b3cdf73 100644 --- a/lib/pbench/server/database/alembic/versions/9cc638cb865c_operationname.py +++ b/lib/pbench/server/database/alembic/versions/9cc638cb865c_operationname.py @@ -8,6 +8,7 @@ Create Date: 2023-03-03 14:32:16.955897 """ + from alembic import op # revision identifiers, used by Alembic. diff --git a/lib/pbench/server/database/alembic/versions/9df060db17de_tokens_store_expiration.py b/lib/pbench/server/database/alembic/versions/9df060db17de_tokens_store_expiration.py index 66005f11fe..a7303924ee 100644 --- a/lib/pbench/server/database/alembic/versions/9df060db17de_tokens_store_expiration.py +++ b/lib/pbench/server/database/alembic/versions/9df060db17de_tokens_store_expiration.py @@ -5,6 +5,7 @@ Create Date: 2023-02-05 15:58:25.408754 """ + from alembic import op # Revision identifiers, used by Alembic. diff --git a/lib/pbench/server/database/alembic/versions/e6b44fb7c065_rework_database_models_and_class_names.py b/lib/pbench/server/database/alembic/versions/e6b44fb7c065_rework_database_models_and_class_names.py index dc26859846..bd76e06c6a 100644 --- a/lib/pbench/server/database/alembic/versions/e6b44fb7c065_rework_database_models_and_class_names.py +++ b/lib/pbench/server/database/alembic/versions/e6b44fb7c065_rework_database_models_and_class_names.py @@ -4,6 +4,7 @@ Revises: fa12f45a2a5a Create Date: 2023-01-23 20:44:32.238138 """ + from alembic import op # revision identifiers, used by Alembic. diff --git a/lib/pbench/server/database/alembic/versions/f628657bed56_user_table_update_oidc.py b/lib/pbench/server/database/alembic/versions/f628657bed56_user_table_update_oidc.py index d169836bc2..6e76e106d1 100644 --- a/lib/pbench/server/database/alembic/versions/f628657bed56_user_table_update_oidc.py +++ b/lib/pbench/server/database/alembic/versions/f628657bed56_user_table_update_oidc.py @@ -5,6 +5,7 @@ Create Date: 2023-02-26 23:24:16.650879 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql diff --git a/lib/pbench/server/database/alembic/versions/fa12f45a2a5a_initial_database_schema.py b/lib/pbench/server/database/alembic/versions/fa12f45a2a5a_initial_database_schema.py index 02453d4d03..2ce41e6390 100644 --- a/lib/pbench/server/database/alembic/versions/fa12f45a2a5a_initial_database_schema.py +++ b/lib/pbench/server/database/alembic/versions/fa12f45a2a5a_initial_database_schema.py @@ -10,6 +10,7 @@ 6a764f154. That commit was the latest working version of the Pbench Server deployed in Red Hat's staging environment. """ + from alembic import op import sqlalchemy as sa diff --git a/lib/pbench/server/database/alembic/versions/ffcc6daffedb_drop_doc_ids.py b/lib/pbench/server/database/alembic/versions/ffcc6daffedb_drop_doc_ids.py index 3ef5b16108..ef309833a0 100644 --- a/lib/pbench/server/database/alembic/versions/ffcc6daffedb_drop_doc_ids.py +++ b/lib/pbench/server/database/alembic/versions/ffcc6daffedb_drop_doc_ids.py @@ -5,6 +5,7 @@ Create Date: 2024-01-30 19:33:14.976874 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql diff --git a/lib/pbench/server/database/models/__init__.py b/lib/pbench/server/database/models/__init__.py index 60a2e13e7b..9b71f56271 100644 --- a/lib/pbench/server/database/models/__init__.py +++ b/lib/pbench/server/database/models/__init__.py @@ -61,7 +61,6 @@ def decode_sql_error( fallback: Optional[Callable[[Exception], Exception]] = None, **kwargs ) -> Exception: - """Analyze an exception for a SQL constraint violation Analyzes SQLAlchemy IntegrityException instances for NOT NULL and UNIQUE diff --git a/lib/pbench/server/database/models/audit.py b/lib/pbench/server/database/models/audit.py index 0fb49a1dd4..3ece8dcf75 100644 --- a/lib/pbench/server/database/models/audit.py +++ b/lib/pbench/server/database/models/audit.py @@ -292,7 +292,6 @@ def query( dataset: Optional[Dataset] = None, **kwargs, ) -> "list[Audit]": - """Return a list of Audit objects matching the query parameters. The definition allows an exact search based on any column of the table diff --git a/lib/pbench/server/database/models/server_settings.py b/lib/pbench/server/database/models/server_settings.py index 4cfbf95e7d..302e0966e8 100644 --- a/lib/pbench/server/database/models/server_settings.py +++ b/lib/pbench/server/database/models/server_settings.py @@ -7,6 +7,7 @@ The list of available settings are defined by the OPTION_* variables of this module. """ + import re from typing import Optional diff --git a/lib/pbench/server/indexer.py b/lib/pbench/server/indexer.py index 92058ffd63..a3567c16e2 100644 --- a/lib/pbench/server/indexer.py +++ b/lib/pbench/server/indexer.py @@ -3336,9 +3336,9 @@ def __init__( except configparser.NoOptionError: pass else: - self.at_metadata[ - "tar-ball-creation-timestamp" - ] = PbenchTarBall.convert_to_dt(tb_ts_str)[1] + self.at_metadata["tar-ball-creation-timestamp"] = ( + PbenchTarBall.convert_to_dt(tb_ts_str)[1] + ) try: raw_size = self.mdconf.get("run", "raw_size") except configparser.NoOptionError: diff --git a/lib/pbench/test/__init__.py b/lib/pbench/test/__init__.py index e9b7e5923b..a3eaa44bcd 100644 --- a/lib/pbench/test/__init__.py +++ b/lib/pbench/test/__init__.py @@ -1,4 +1,5 @@ """Common test support functions.""" + import json from pathlib import Path from typing import Callable, Dict diff --git a/lib/pbench/test/unit/agent/test_tool_meister_stop.py b/lib/pbench/test/unit/agent/test_tool_meister_stop.py index 03fc72bdba..ea47056cf3 100644 --- a/lib/pbench/test/unit/agent/test_tool_meister_stop.py +++ b/lib/pbench/test/unit/agent/test_tool_meister_stop.py @@ -1,5 +1,6 @@ """Tests for the Tool Meister "stop" module. """ + from pbench.agent.tool_meister_stop import RedisServer diff --git a/lib/pbench/test/unit/agent/test_utils.py b/lib/pbench/test/unit/agent/test_utils.py index 38add42cba..f504342fd6 100644 --- a/lib/pbench/test/unit/agent/test_utils.py +++ b/lib/pbench/test/unit/agent/test_utils.py @@ -1,5 +1,6 @@ """Tests for the utils module. """ + import os import signal import time diff --git a/lib/pbench/test/unit/common/test_config.py b/lib/pbench/test/unit/common/test_config.py index ea292ee40f..a8fc726cf8 100644 --- a/lib/pbench/test/unit/common/test_config.py +++ b/lib/pbench/test/unit/common/test_config.py @@ -1,5 +1,6 @@ """Test PbenchConfig class and objects """ + from configparser import ConfigParser, NoOptionError, NoSectionError from typing import Any, Dict, List diff --git a/lib/pbench/test/unit/common/test_wait_for_uri.py b/lib/pbench/test/unit/common/test_wait_for_uri.py index 9685ed2ca0..040ffe6479 100644 --- a/lib/pbench/test/unit/common/test_wait_for_uri.py +++ b/lib/pbench/test/unit/common/test_wait_for_uri.py @@ -1,4 +1,5 @@ """Test wait_for_uri() module method""" + from contextlib import contextmanager import socket from typing import Tuple diff --git a/lib/pbench/test/unit/server/test_relay.py b/lib/pbench/test/unit/server/test_relay.py index 5545bcbe38..828c32bb76 100644 --- a/lib/pbench/test/unit/server/test_relay.py +++ b/lib/pbench/test/unit/server/test_relay.py @@ -477,17 +477,21 @@ def test_delete_failures( responses.add( responses.DELETE, "https://relay.example.com/uri1", - status=status1[0] - if isinstance(status1[0], int) - else HTTPStatus.ALREADY_REPORTED, + status=( + status1[0] + if isinstance(status1[0], int) + else HTTPStatus.ALREADY_REPORTED + ), body=status1[0] if isinstance(status1[0], Exception) else None, ) responses.add( responses.DELETE, "https://relay.example.com/uri2", - status=status2[0] - if isinstance(status2[0], int) - else HTTPStatus.ALREADY_REPORTED, + status=( + status2[0] + if isinstance(status2[0], int) + else HTTPStatus.ALREADY_REPORTED + ), body=status2[0] if isinstance(status2[0], Exception) else None, ) response = client.post( diff --git a/lib/pbench/test/unit/server/test_shell_cli.py b/lib/pbench/test/unit/server/test_shell_cli.py index dd67ccfe8d..b656a20f15 100644 --- a/lib/pbench/test/unit/server/test_shell_cli.py +++ b/lib/pbench/test/unit/server/test_shell_cli.py @@ -1,4 +1,5 @@ """Test the Gunicorn driver module, `shell`, to ensure it is usable.""" + from configparser import NoOptionError, NoSectionError import logging import os diff --git a/lint-requirements.txt b/lint-requirements.txt index d0e206a824..7470355f23 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1,3 +1,3 @@ -black==22.12.0 +black==24.3.0 flake8==6.0.0 isort==5.12.0