diff --git a/pylintrc b/pylintrc index 5a730e3f0b..21121058c3 100644 --- a/pylintrc +++ b/pylintrc @@ -39,7 +39,6 @@ disable= ###################### VV things we should fix VV W0719, # broad-exception-raised W1203, # logging-fstring-interpolation - W1406, # redundant-u-string-prefix W1514, # unspecified-encoding W0107, # unnecessary-pass W0718, # broad-exception-caught @@ -47,25 +46,20 @@ disable= W0221, # arguments-differ W3101, # missing-timeout C0201, # consider-iterating-dictionary - R1719, # simplifiable-if-expression W1201, # logging-not-lazy W0707, # raise-missing-from W0237, # arguments-renamed C0117, # unnecessary-negation W0212, # protected-access - R1728, # consider-using-generator W0231, # super-init-not-called C0123, # unidiomatic-typecheck C0207, # use-maxsplit-arg C2801, # unnecessary-dunder-call - E0203, # access-member-before-definition E0611, # no-name-in-module E0702, # raising-bad-type E1101, # no-member E1135, # unsupported-membership-test - R1703, # simplifiable-if-statement R1721, # unnecessary-comprehension W0108, # unnecessary-lambda - W0222, # signature-differs W0223, # abstract-method W1509, # subprocess-popen-preexec-fn diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py index 4a901954cd..e26f3efd3f 100644 --- a/sos/collector/__init__.py +++ b/sos/collector/__init__.py @@ -562,7 +562,7 @@ def _parse_options(self): """ self.commons = { 'cmdlineopts': self.opts, - 'need_sudo': True if self.opts.ssh_user != 'root' else False, + 'need_sudo': self.opts.ssh_user != 'root', 'tmpdir': self.tmpdir, 'hostlen': max(len(self.opts.primary), len(self.hostname)), 'policy': self.policy diff --git a/sos/collector/transports/control_persist.py b/sos/collector/transports/control_persist.py index b192007da6..9a814831e1 100644 --- a/sos/collector/transports/control_persist.py +++ b/sos/collector/transports/control_persist.py @@ -112,11 +112,11 @@ def _connect(self, password=''): # pylint: disable=too-many-branches res = pexpect.spawn(cmd, encoding='utf-8') connect_expects = [ - u'Connected', - u'password:', - u'.*Permission denied.*', - u'.* port .*: No route to host', - u'.*Could not resolve hostname.*', + 'Connected', + 'password:', + '.*Permission denied.*', + '.* port .*: No route to host', + '.*Could not resolve hostname.*', pexpect.TIMEOUT ] @@ -127,8 +127,8 @@ def _connect(self, password=''): # pylint: disable=too-many-branches elif index == 1: if password: pass_expects = [ - u'Connected', - u'Permission denied, please try again.', + 'Connected', + 'Permission denied, please try again.', pexpect.TIMEOUT ] res.sendline(password) diff --git a/sos/component.py b/sos/component.py index 467f940ed0..6f42046022 100644 --- a/sos/component.py +++ b/sos/component.py @@ -353,8 +353,7 @@ def setup_archive(self, name=''): if self.opts.encrypt: self._get_encryption_method() enc_opts = { - 'encrypt': True if (self.opts.encrypt_pass or - self.opts.encrypt_key) else False, + 'encrypt': self.opts.encrypt_pass or self.opts.encrypt_key, 'key': self.opts.encrypt_key, 'password': self.opts.encrypt_pass } diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index 8739bb6df8..7faaacb665 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -490,7 +490,7 @@ def _fmt_vendor_urls(self): :returns: Formatted string of URLS :rtype: ``str`` """ - width = max([len(v[0]) for v in self.vendor_urls]) + width = max(len(v[0]) for v in self.vendor_urls) return "\n".join( f"\t{url[0]:<{width}} : {url[1]}" for url in self.vendor_urls ) diff --git a/sos/policies/distros/__init__.py b/sos/policies/distros/__init__.py index f4abe23baf..424176aa1a 100644 --- a/sos/policies/distros/__init__.py +++ b/sos/policies/distros/__init__.py @@ -702,9 +702,9 @@ def upload_sftp(self, user=None, password=None): ret = pexpect.spawn(sftp_cmd, encoding='utf-8') sftp_expects = [ - u'sftp>', - u'password:', - u'Connection refused', + 'sftp>', + 'password:', + 'Connection refused', pexpect.TIMEOUT, pexpect.EOF ] @@ -716,8 +716,8 @@ def upload_sftp(self, user=None, password=None): elif idx == 1: ret.sendline(password) pass_expects = [ - u'sftp>', - u'Permission denied', + 'sftp>', + 'Permission denied', pexpect.TIMEOUT, pexpect.EOF ] @@ -746,10 +746,10 @@ def upload_sftp(self, user=None, password=None): ret.sendline(put_cmd) put_expects = [ - u'100%', + '100%', pexpect.TIMEOUT, pexpect.EOF, - u'No such file or directory' + 'No such file or directory' ] put_success = ret.expect(put_expects, timeout=180) diff --git a/sos/policies/distros/suse.py b/sos/policies/distros/suse.py index 8c7900e55a..d3f1ed8a7c 100644 --- a/sos/policies/distros/suse.py +++ b/sos/policies/distros/suse.py @@ -82,7 +82,7 @@ def __init__(self, sysroot=None, init=None, probe_runtime=True, remote_exec=remote_exec) @classmethod - def check(cls, remote): + def check(cls, remote=''): """This method checks to see if we are running on SuSE. """ diff --git a/sos/report/__init__.py b/sos/report/__init__.py index 148391e702..9ef1cb32cf 100644 --- a/sos/report/__init__.py +++ b/sos/report/__init__.py @@ -1581,7 +1581,7 @@ def final_work(self): # that still will be moved to the sos report final directory path tmpdir_path = Path(self.tmpdir) self.estimated_plugsizes['sos_logs_reports'] = sum( - [f.lstat().st_size for f in tmpdir_path.glob('**/*')]) + f.lstat().st_size for f in tmpdir_path.glob('**/*')) _sum = get_human_readable(sum(self.estimated_plugsizes.values())) self.ui_log.info("Estimated disk space requirement for whole " diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py index dbb3346b0a..e736498339 100644 --- a/sos/report/plugins/__init__.py +++ b/sos/report/plugins/__init__.py @@ -3370,7 +3370,7 @@ def setup(self): self.add_copy_spec(list(self.files)) def setup_verify(self): - if not hasattr(self, "verify_packages") or not self.verify_packages: + if not hasattr(self, "verify_packages"): if hasattr(self, "packages") and self.packages: # Limit automatic verification to only the named packages self.verify_packages = [p + "$" for p in self.packages] diff --git a/sos/report/reporting.py b/sos/report/reporting.py index 39da983b70..c7178237bd 100644 --- a/sos/report/reporting.py +++ b/sos/report/reporting.py @@ -186,9 +186,9 @@ def unicode(self): if len(self.FOOTER) > 0: line_buf.append(self.FOOTER) - output = u'\n'.join(map(lambda i: (i if isinstance(i, str) - else i.decode('utf8', 'ignore')), - line_buf)) + output = '\n'.join(map(lambda i: (i if isinstance(i, str) + else i.decode('utf8', 'ignore')), + line_buf)) return output def process_subsection(self, section, key, header, format_, footer): diff --git a/tests/unittests/plugin_tests.py b/tests/unittests/plugin_tests.py index e7b13078bd..ee7e343a00 100644 --- a/tests/unittests/plugin_tests.py +++ b/tests/unittests/plugin_tests.py @@ -130,14 +130,14 @@ class MockOptions: class PluginToolTests(unittest.TestCase): def test_regex_findall(self): - test_s = u"\n".join( + test_s = "\n".join( ['this is only a test', 'there are only two lines']) test_fo = StringIO(test_s) matches = regex_findall(r".*lines$", test_fo) self.assertEqual(matches, ['there are only two lines']) def test_regex_findall_miss(self): - test_s = u"\n".join( + test_s = "\n".join( ['this is only a test', 'there are only two lines']) test_fo = StringIO(test_s) matches = regex_findall(r".*not_there$", test_fo) diff --git a/tests/unittests/report_tests.py b/tests/unittests/report_tests.py index f9ea2daab0..1f4c400ba5 100644 --- a/tests/unittests/report_tests.py +++ b/tests/unittests/report_tests.py @@ -71,7 +71,7 @@ def setUp(self): self.section = Section(name="plugin") self.div = '\n' + PlainTextReport.PLUGDIVIDER self.pluglist = "Loaded Plugins:\n{pluglist}" - self.defaultheader = u''.join([ + self.defaultheader = ''.join([ self.pluglist.format(pluglist=" plugin"), self.div, "\nplugin\n" @@ -92,7 +92,7 @@ def test_two_sections(self): section2 = Section(name="second") self.report.add(section1, section2) - self.assertEqual(u''.join([ + self.assertEqual(''.join([ self.pluglist.format(pluglist=" first second"), self.div, "\nfirst", @@ -108,7 +108,7 @@ def test_command(self): self.section.add(cmd) self.report.add(self.section) - self.assertEqual(u''.join([ + self.assertEqual(''.join([ self.defaultheader, "- commands executed:\n * ls -al /foo/bar/baz" ]), @@ -119,7 +119,7 @@ def test_copied_file(self): self.section.add(cf) self.report.add(self.section) - self.assertEqual(u''.join([ + self.assertEqual(''.join([ self.defaultheader, "- files copied:\n * /etc/hosts" ]), @@ -131,7 +131,7 @@ def test_created_file(self): self.section.add(crf) self.report.add(self.section) - self.assertEqual(u''.join([ + self.assertEqual(''.join([ self.defaultheader, "- files created:\n * sample.txt" ]), @@ -142,7 +142,7 @@ def test_alert(self): self.section.add(alrt) self.report.add(self.section) - self.assertEqual(u''.join([ + self.assertEqual(''.join([ self.defaultheader, "- alerts:\n ! this is an alert" ]), diff --git a/tests/unittests/utilities_tests.py b/tests/unittests/utilities_tests.py index d082b8db2a..ac97afe373 100644 --- a/tests/unittests/utilities_tests.py +++ b/tests/unittests/utilities_tests.py @@ -20,7 +20,7 @@ class GrepTest(unittest.TestCase): def test_file_obj(self): - test_s = u"\n".join( + test_s = "\n".join( ['this is only a test', 'there are only two lines']) test_fo = StringIO(test_s) matches = grep(".*test$", test_fo)