From e5008111ad2365e926bb914c38876c1f878475ce Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Tue, 21 Dec 2021 10:10:42 +0100 Subject: [PATCH] Update pre-commit hooks configuration Update pre-commit hooks configuration: - use pre-commit 2.16.0 - use python pylint 2.12.2 Change-Id: Ic91148ba5cec708341b02fead011947f01b375b5 --- .pre-commit-config.yaml | 5 ++--- linters-requirements.txt | 4 ++-- tobiko/common/_exception.py | 1 - tobiko/shell/sh/_systemctl.py | 1 - tobiko/tests/faults/neutron/test_agents.py | 1 - tobiko/tripleo/pacemaker.py | 10 +++++++--- tobiko/tripleo/processes.py | 4 +++- tox.ini | 2 -- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee059ff51..87a9b3722 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,13 +51,12 @@ repos: - repo: local hooks: - id: pylint - files: ^tobiko/ name: pylint - entry: .tox/pep8/bin/pylint --max-line-length=80 -E -e W,E -d unused-import,broad-except,fixme + entry: pylint --max-line-length=88 -E -e W,E -d unused-import,broad-except,fixme,unspecified-encoding,redundant-u-string-prefix + files: ^tobiko/ language: system types: [python] - # - repo: https://github.com/adrienverge/yamllint.git # rev: v1.23.0 # hooks: diff --git a/linters-requirements.txt b/linters-requirements.txt index f61e1e68c..88136bbac 100644 --- a/linters-requirements.txt +++ b/linters-requirements.txt @@ -1,4 +1,4 @@ # pep8 and flake8 requirements -pre-commit # MIT -pylint >= 2.8.3, < 2.9.0 # GPLv2 +pre-commit >= 2.16.0 # MIT +pylint===2.12.2 # GPL2 diff --git a/tobiko/common/_exception.py b/tobiko/common/_exception.py index 74ebfcb49..90fe14afd 100644 --- a/tobiko/common/_exception.py +++ b/tobiko/common/_exception.py @@ -55,7 +55,6 @@ class TobikoException(Exception): message = "unknown reason" def __init__(self, message=None, **properties): - # pylint: disable=exception-message-attribute message = message or self.message if properties: message = message.format(**properties) diff --git a/tobiko/shell/sh/_systemctl.py b/tobiko/shell/sh/_systemctl.py index 32748b1b8..5f0263980 100644 --- a/tobiko/shell/sh/_systemctl.py +++ b/tobiko/shell/sh/_systemctl.py @@ -227,7 +227,6 @@ def wait_for_systemd_units_state( if bad_units: raise UnexpectedSystemctlUnitState(matcher=match_unit, units=bad_units) - # pylint: disable=dict-values-not-iterating return tobiko.Selection(all_units.values()) diff --git a/tobiko/tests/faults/neutron/test_agents.py b/tobiko/tests/faults/neutron/test_agents.py index 5271f9613..e021e6ebe 100644 --- a/tobiko/tests/faults/neutron/test_agents.py +++ b/tobiko/tests/faults/neutron/test_agents.py @@ -228,7 +228,6 @@ class BaseAgentTest(testtools.TestCase): self.assertGreater(min_pids_per_host, 0) self.assertGreater(max_pids_per_host, 0) self.assertGreaterEqual(max_pids_per_host, min_pids_per_host) - # pylint: disable=range-builtin-not-iterating pids_count_range = range(min_pids_per_host, max_pids_per_host + 1) pids_per_host = {} for host in hosts: diff --git a/tobiko/tripleo/pacemaker.py b/tobiko/tripleo/pacemaker.py index 0e9b3ef66..e621ff007 100644 --- a/tobiko/tripleo/pacemaker.py +++ b/tobiko/tripleo/pacemaker.py @@ -2,6 +2,7 @@ from __future__ import absolute_import import io import time +import typing from oslo_log import log import pandas @@ -26,7 +27,7 @@ def get_random_controller_ssh_client(): return controller_node.ssh_client -def get_pcs_resources_table(timeout=720, interval=2): +def get_pcs_resources_table(timeout=720, interval=2) -> pandas.DataFrame: """ get pcs status from a controller and parse it to have it's resources states in check @@ -39,7 +40,7 @@ def get_pcs_resources_table(timeout=720, interval=2): :return: dataframe of pcs resources stats table """ - failures = [] + failures: typing.List[str] = [] start = time.time() ssh_client = get_random_controller_ssh_client() @@ -54,7 +55,8 @@ def get_pcs_resources_table(timeout=720, interval=2): # remove the first column when it only includes '*' characters output = output.replace('*', '').strip() stream = io.StringIO(output) - table = pandas.read_csv(stream, delim_whitespace=True, header=None) + table: pandas.DataFrame = pandas.read_csv( + stream, delim_whitespace=True, header=None) table.columns = ['resource', 'resource_type', 'resource_state', 'overcloud_node'] except ValueError: @@ -233,6 +235,7 @@ def get_overcloud_nodes_running_pcs_resource(resource=None, resource/type/state: exact str of a resource name as seen in pcs status :return: list of overcloud nodes """ + # pylint: disable=no-member pcs_df = get_pcs_resources_table() if resource: pcs_df_query_resource = pcs_df.query('resource=="{}"'.format( @@ -279,6 +282,7 @@ def get_overcloud_resource(resource_type=None, 'resource'].unique().tolist() if resource_type and not resource_state: + # pylint: disable=no-member pcs_df_query_resource_type = pcs_df.query( 'resource_type=="{}"'.format(resource_type)) return pcs_df_query_resource_type['resource'].unique().tolist() diff --git a/tobiko/tripleo/processes.py b/tobiko/tripleo/processes.py index 45a96112c..234d72fe2 100644 --- a/tobiko/tripleo/processes.py +++ b/tobiko/tripleo/processes.py @@ -54,10 +54,12 @@ root | 11| 2| 0.0| 0|00:00:05|migration/0 |[migration/0] "ps|sed 's/\"/''/g'", ssh_client=ssh_client).stdout stream = io.StringIO(output) - table = pandas.read_csv(stream, sep='DELIM', header=None, skiprows=1) + table: pandas.DataFrame = pandas.read_csv( + stream, sep='DELIM', header=None, skiprows=1) table.replace(to_replace=' ', value="", regex=True, inplace=True) table.columns = ['USER', 'PID', 'PPID', 'CPU', 'VSZ', 'TIME', 'PROCESS', 'PROCESS_ARGS'] + # pylint: disable=unsupported-assignment-operation table['overcloud_node'] = hostname LOG.debug("Successfully got overcloud nodes processes status table") diff --git a/tox.ini b/tox.ini index 0e240b00d..035c9e142 100644 --- a/tox.ini +++ b/tox.ini @@ -77,8 +77,6 @@ commands = pre-commit run -a flake8 setenv = {[testenv]setenv} - #fressi: There is a conflict between the last global constrains file and pylint - # requirements TOX_CONSTRAINTS = -c{toxinidir}/upper-constraints.txt [testenv:mypy]