From d114e839b0a1420f2a226d661dd3128d91ec5096 Mon Sep 17 00:00:00 2001 From: Ponnuvel Palaniyappan Date: Sun, 21 Jul 2024 12:46:42 +0100 Subject: [PATCH] [pylint] Re-enable unnecessary-{negation,dunder-call,comprehension,lambda} Signed-off-by: Ponnuvel Palaniyappan --- pylintrc | 4 ---- sos/collector/__init__.py | 2 +- sos/collector/clusters/ocp.py | 4 ++-- sos/collector/clusters/pacemaker.py | 2 +- sos/options.py | 4 ++-- sos/report/plugins/__init__.py | 16 +++------------- sos/report/reporting.py | 1 - 7 files changed, 9 insertions(+), 24 deletions(-) diff --git a/pylintrc b/pylintrc index 0ac1449004..110f0ecc21 100644 --- a/pylintrc +++ b/pylintrc @@ -45,10 +45,6 @@ disable= C0201, # consider-iterating-dictionary W1201, # logging-not-lazy W0707, # raise-missing-from - C0117, # unnecessary-negation W0212, # protected-access - C2801, # unnecessary-dunder-call - R1721, # unnecessary-comprehension - W0108, # unnecessary-lambda W0223, # abstract-method W1509, # subprocess-popen-preexec-fn diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py index 7632349d33..4db31f3a5c 100644 --- a/sos/collector/__init__.py +++ b/sos/collector/__init__.py @@ -769,7 +769,7 @@ def write_host_group(self): 'name': self.opts.save_group, 'primary': self.opts.primary, 'cluster_type': self.cluster.cluster_type[0], - 'nodes': [n for n in self.node_list] + 'nodes': list(self.node_list) } if os.getuid() != 0: group_path = os.path.join(Path.home(), '.config/sos/groups.d') diff --git a/sos/collector/clusters/ocp.py b/sos/collector/clusters/ocp.py index 320cb0d756..265c1e4dc9 100644 --- a/sos/collector/clusters/ocp.py +++ b/sos/collector/clusters/ocp.py @@ -264,7 +264,7 @@ def get_nodes(self): self.log_warn("NOTE: By default, only master nodes are listed." "\nTo collect from all/more nodes, override the " "role option with '-c ocp.role=role1:role2'") - roles = [r for r in self.get_option('role').split(':')] + roles = list(self.get_option('role').split(':')) self.node_dict = self._build_dict(res['output'].splitlines()) for node_name, node in self.node_dict.items(): if roles: @@ -368,7 +368,7 @@ def set_primary_options(self, node): elif node.file_exists(_kubeconfig): # if the file exists, then the openshift sos plugin will use it # if the with-api option is turned on - if not _kubeconfig == master_kube: + if _kubeconfig != master_kube: node.plugopts.append( f"openshift.kubeconfig={_kubeconfig}" ) diff --git a/sos/collector/clusters/pacemaker.py b/sos/collector/clusters/pacemaker.py index 6c3ee30213..824ae930d2 100644 --- a/sos/collector/clusters/pacemaker.py +++ b/sos/collector/clusters/pacemaker.py @@ -63,7 +63,7 @@ def get_nodes_from_crm(self): _ver = self.exec_primary_cmd('crm_mon --version') if _ver['status'] == 0: cver = _ver['output'].split()[1].split('-')[0] - if not sos_parse_version(cver) > sos_parse_version('2.0.3'): + if sos_parse_version(cver) <= sos_parse_version('2.0.3'): xmlopt = '--as-xml' else: return diff --git a/sos/options.py b/sos/options.py index 3fa7001134..f573649955 100644 --- a/sos/options.py +++ b/sos/options.py @@ -160,7 +160,7 @@ def _convert_to_type(self, key, val, conf): if isinstance(self.arg_defaults[key], type(val)): return val if isinstance(self.arg_defaults[key], list): - return [v for v in val.split(',')] + return list(val.split(',')) if isinstance(self.arg_defaults[key], bool): val = str_to_bool(val) if val is None: @@ -336,7 +336,7 @@ class SosListOption(Action): """Allow to specify comma delimited list of plugins""" def __call__(self, parser, namespace, values, option_string=None): - items = [opt for opt in values.split(',')] + items = list(values.split(',')) if getattr(namespace, self.dest): items += getattr(namespace, self.dest) setattr(namespace, self.dest, items) diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py index 6b070b45eb..fc23a900ab 100644 --- a/sos/report/plugins/__init__.py +++ b/sos/report/plugins/__init__.py @@ -1821,7 +1821,7 @@ def time_filter(path): continue if since or maxage: - files = list(filter(lambda f: time_filter(f), files)) + files = list(filter(time_filter, files)) files.sort(key=getmtime, reverse=True) current_size = 0 @@ -2013,7 +2013,7 @@ def _add_cmd_output(self, **kwargs): if "snap_cmd" in kwargs: kwargs.pop("snap_cmd") soscmd = SoSCommand(**kwargs) - self._log_debug("packed command: " + soscmd.__str__()) + self._log_debug(f"packed command: {str(soscmd)}") for _skip_cmd in self.skip_commands: # This probably seems weird to be doing filename matching on the # commands, however we want to remain consistent with our regex @@ -3156,7 +3156,7 @@ def _collect_container_copy_specs(self): def _collect_cmds(self): self.collect_cmds.sort(key=lambda x: x.priority) for soscmd in self.collect_cmds: - self._log_debug("unpacked command: " + soscmd.__str__()) + self._log_debug(f"unpacked command: {str(soscmd)}") user = "" if getattr(soscmd, "runas", None) is not None: user = f", as the {soscmd.runas} user" @@ -3558,52 +3558,42 @@ class PluginDistroTag(): Use IndependentPlugin for plugins that are distribution agnostic """ - pass class RedHatPlugin(PluginDistroTag): """Tagging class for Red Hat's Linux distributions""" - pass class UbuntuPlugin(PluginDistroTag): """Tagging class for Ubuntu Linux""" - pass class DebianPlugin(PluginDistroTag): """Tagging class for Debian Linux""" - pass class SuSEPlugin(PluginDistroTag): """Tagging class for SuSE Linux distributions""" - pass class OpenEulerPlugin(PluginDistroTag): """Tagging class for openEuler linux distributions""" - pass class CosPlugin(PluginDistroTag): """Tagging class for Container-Optimized OS""" - pass class IndependentPlugin(PluginDistroTag): """Tagging class for plugins that can run on any platform""" - pass class ExperimentalPlugin(PluginDistroTag): """Tagging class that indicates that this plugin is experimental""" - pass class AzurePlugin(PluginDistroTag): """Tagging class for Azure Linux""" - pass def import_plugin(name, superclasses=None): diff --git a/sos/report/reporting.py b/sos/report/reporting.py index c7178237bd..d87f8d35bd 100644 --- a/sos/report/reporting.py +++ b/sos/report/reporting.py @@ -33,7 +33,6 @@ def can_add(self, node): class Leaf(Node): """Marker class that can be added to a Section node""" - pass class Report(Node):