canonical / hotsos

Software analysis toolkit. Define checks in high-level language and leverage library to perform analysis of common Cloud applications.
Apache License 2.0
31 stars 37 forks source link

flake8 has false positives on py3.12 #931

Closed mustafakemalgilor closed 2 months ago

mustafakemalgilor commented 2 months ago

After recent changes, running flake8 on py3.12 yields some false positives:

pep8: commands[0]> flake8 -v --exclude=fake_data_root /workspace/github/hotsos/setup.py /workspace/github/hotsos/hotsos /workspace/github/hotsos/tests/unit/ /workspace/github/hotsos/tools/validation
flake8.checker            MainProcess     71 INFO     Making checkers
flake8.main.application   MainProcess    229 INFO     Finished running
flake8.main.application   MainProcess    229 INFO     Reporting errors
/workspace/github/hotsos/hotsos/core/config.py:180:53: E713 test for membership should be 'not in'
            raise Exception(f"config option '{key}' not found in any optgrpup")
                                                    ^
/workspace/github/hotsos/hotsos/core/host_helpers/cli.py:64:38: E713 test for membership should be 'not in'
        self.msg = f"command '{cmd}' not found in catalog: '{msg}'"
                                     ^
/workspace/github/hotsos/hotsos/core/host_helpers/systemd.py:227:26: E231 missing whitespace after ':'
        base_expr = rf"(?:snap\.)?{svc_name_expr}(?:\.daemon)?"
                         ^
/workspace/github/hotsos/hotsos/core/host_helpers/systemd.py:227:52: E231 missing whitespace after ':'
        base_expr = rf"(?:snap\.)?{svc_name_expr}(?:\.daemon)?"
                                                   ^
/workspace/github/hotsos/hotsos/core/host_helpers/uptime.py:21:65: E231 missing whitespace after ':'
        expr = rf"\s*[\d:]+\s+up\s+{etime_expr}.+\s+load average:\s+(.+)"
                                                                ^
/workspace/github/hotsos/hotsos/core/host_helpers/uptime.py:86:25: E231 missing whitespace after ':'
        return f"{days}d:{hours}h:{minutes}m"
                        ^
/workspace/github/hotsos/hotsos/core/host_helpers/uptime.py:86:34: E231 missing whitespace after ':'
        return f"{days}d:{hours}h:{minutes}m"
                                 ^
/workspace/github/hotsos/hotsos/core/plugins/juju/common.py:12:24: E231 missing whitespace after ':'
                  rf'(?:^|[^\s])juju-db{SVC_VALID_SUFFIX}']
                       ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/calltrace.py:17:23: E231 missing whitespace after ':'
KERNLOG_PREFIX = rf'(?:\S+\s+\d+\s+[\d:]+\s+\S+\s+\S+:\s+)?{KERNLOG_TS}'
                      ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/calltrace.py:17:54: E231 missing whitespace after ':'
KERNLOG_PREFIX = rf'(?:\S+\s+\d+\s+[\d:]+\s+\S+\s+\S+:\s+)?{KERNLOG_TS}'
                                                     ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/calltrace.py:64:39: E231 missing whitespace after ':'
                s.append(f"{prefix}{k}:")
                                      ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/calltrace.py:137:38: E231 missing whitespace after ':'
            ret = re.search(f'{field}:{self.expr}', line)
                                     ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/calltrace.py:224:71: E231 missing whitespace after ':'
        start = SearchDef(rf'{KERNLOG_PREFIX}.+\s+task bcache-register:(\d+) '
                                                                      ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/calltrace.py:329:34: E231 missing whitespace after ':'
        body = SearchDef(rf"(.+(?:{'|'.join(fields)}).+)")
                                 ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/common.py:13:23: E231 missing whitespace after ':'
KERNLOG_PREFIX = rf'(?:\S+\s+\d+\s+[\d:]+\s+\S+\s+\S+:\s+)?{KERNLOG_TS}'
                      ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/kernlog/common.py:13:54: E231 missing whitespace after ':'
KERNLOG_PREFIX = rf'(?:\S+\s+\d+\s+[\d:]+\s+\S+\s+\S+:\s+)?{KERNLOG_TS}'
                                                     ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/memory.py:49:48: E713 test for membership should be 'not in'
        raise AttributeError(f'attribute {key} not found in '
                                               ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/memory.py:228:54: E231 missing whitespace after ','
                if line.split()[3] == zones_type and \
                        line.startswith(f"Node {node},"):
                                                     ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/net.py:100:38: E713 test for membership should be 'not in'
        raise AttributeError(f"{fld} not found in {self.__class__.__name__}")
                                     ^
/workspace/github/hotsos/hotsos/core/plugins/kernel/net.py:397:38: E713 test for membership should be 'not in'
        raise AttributeError(f"{fld} not found in {self.__class__.__name__}")
                                     ^
/workspace/github/hotsos/hotsos/core/plugins/rabbitmq/report.py:193:58: E231 missing whitespace after ':'
                    _memory_used[node_name] = f"{mib_used:.3f}"
                                                         ^
/workspace/github/hotsos/hotsos/core/plugins/storage/bcache.py:64:38: E713 test for membership should be 'not in'
        raise AttributeError(f"{key} not found in bdev config")
                                     ^
/workspace/github/hotsos/hotsos/core/plugins/storage/bcache.py:87:38: E713 test for membership should be 'not in'
        raise AttributeError(f"{key} not found in cacheset config")
                                     ^
/workspace/github/hotsos/hotsos/core/plugins/storage/ceph.py:454:57: E231 missing whitespace after ':'
            start = SearchDef(rf"^\s+\"({daemon_type})\":\s+{{")
                                                        ^
/workspace/github/hotsos/hotsos/core/plugins/storage/ceph.py:1171:39: E713 test for membership should be 'not in'
        raise AttributeError(f"{name} not found in output of {self.command}")
                                      ^
/workspace/github/hotsos/hotsos/core/plugins/system/system.py:52:48: E231 missing whitespace after ':'
                expr = rf'^node\s+{node}\s+cpus:\s([0-9\s]+)'
                                               ^
/workspace/github/hotsos/hotsos/core/utils.py:38:21: E231 missing whitespace after ':'
    return f'{days}d:{hours}h:{mins}m:{secs}s'
                    ^
/workspace/github/hotsos/hotsos/core/utils.py:38:30: E231 missing whitespace after ':'
    return f'{days}d:{hours}h:{mins}m:{secs}s'
                             ^
/workspace/github/hotsos/hotsos/core/utils.py:38:38: E231 missing whitespace after ':'
    return f'{days}d:{hours}h:{mins}m:{secs}s'
                                     ^
/workspace/github/hotsos/hotsos/plugin_extensions/juju/summary.py:31:50: E231 missing whitespace after ':'
            expr = rf'{ts_expr} {msg} (\S+) (\S+):\d+ '
                                                 ^
/workspace/github/hotsos/hotsos/plugin_extensions/openstack/agent/events.py:48:44: E231 missing whitespace after ':'
                            'key': f"{addr}:{port}"})
                                           ^
/workspace/github/hotsos/hotsos/plugin_extensions/openstack/agent/exceptions.py:160:29: E231 missing whitespace after ':'
            exc_names = f"(?:{'|'.join(project.exceptions)})"
                            ^
/workspace/github/hotsos/hotsos/plugin_extensions/openstack/agent/exceptions.py:169:26: E231 missing whitespace after ':'
            values = f"(?:{'|'.join(warn_exprs)})"
                         ^
/workspace/github/hotsos/hotsos/plugin_extensions/openstack/agent/exceptions.py:177:26: E231 missing whitespace after ':'
            values = f"(?:{'|'.join(err_exprs)})"
                         ^
/workspace/github/hotsos/hotsos/plugin_extensions/openstack/agent/exceptions.py:213:37: E231 missing whitespace after ':'
                prefix_match = rf'(?:{wsgi_prefix}|{keystone_prefix})?'
                                    ^
/workspace/github/hotsos/hotsos/plugin_extensions/openstack/agent/exceptions.py:215:37: E231 missing whitespace after ':'
                prefix_match = rf'(?:{wsgi_prefix or keystone_prefix})?'
                                    ^
/workspace/github/hotsos/hotsos/plugin_extensions/rabbitmq/summary.py:32:49: E231 missing whitespace after ':'
                    vhost_queue_dists[vhost.name][node] = \
                        (f"{vhost_dist['queues']:d} "
                                                ^
/workspace/github/hotsos/hotsos/plugin_extensions/rabbitmq/summary.py:33:49: E231 missing whitespace after ':'
flake8.main.application   MainProcess    230 INFO     Found a total of 600 violations and reported 39
                         f"({vhost_dist['pcent']:.2f}%)")
                                                ^
/workspace/github/hotsos/hotsos/plugin_extensions/rabbitmq/summary.py:36:48: E231 missing whitespace after ':'
                    vhost_queue_dists[vhost.name][node] = \
                        f"{vhost_dist['queues']:d} (N/A)"
                                               ^
pep8: exit 1 (0.26 seconds) /workspace/github/hotsos> flake8 -v --exclude=fake_data_root /workspace/github/hotsos/setup.py /workspace/github/hotsos/hotsos /workspace/github/hotsos/tests/unit/ /workspace/github/hotsos/tools/validation pid=434093
  pep8: FAIL code 1 (0.30=setup[0.03]+cmd[0.26] seconds)
  evaluation failed :( (0.34 seconds)