diff options
24 files changed, 32 insertions, 33 deletions
diff --git a/.pylintrc b/.pylintrc index a92b4c7c270..3935170435f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -31,7 +31,7 @@ variable-rgx=[a-z_][a-z0-9_]{1,50}$ # R0801 - duplicate-code - See PM-1380 # E0611 - no-name-in-module -disable=bad-continuation,fixme,import-error,line-too-long,no-member,locally-disabled,no-else-return,redefined-variable-type,too-few-public-methods,unused-import,useless-object-inheritance,deprecated-module,unnecessary-pass,duplicate-code,no-else-raise,deprecated-method,exec-used,no-name-in-module +disable=bad-continuation,fixme,import-error,line-too-long,no-member,locally-disabled,no-else-return,redefined-variable-type,too-few-public-methods,unused-import,useless-object-inheritance,deprecated-module,unnecessary-pass,duplicate-code,no-else-raise,deprecated-method,exec-used,no-name-in-module,raise-missing-from, unnecessary-comprehension,super-with-arguments,consider-using-sys-exit,import-outside-toplevel,no-else-continue,no-else-break [IMPORTS] known-third-party=boto3,botocore,psutil,yaml,xmlrunner diff --git a/buildscripts/blackduck_hub.py b/buildscripts/blackduck_hub.py index 6c9a33f6882..76d768920a0 100644 --- a/buildscripts/blackduck_hub.py +++ b/buildscripts/blackduck_hub.py @@ -927,7 +927,7 @@ Black Duck manually. After the update to the third-party library is committed, version information for this component at {BLACKDUCK_PROJECT_URL}. Click on the down arrow on the far right of the component, choose edit and specify the new version.""" else: - component_explanation = f"""This commponent was automatically detected by Black Duck. Black Duck should automatically detect + component_explanation = """This commponent was automatically detected by Black Duck. Black Duck should automatically detect the new version after the library is updated and the daily scanner task runs again.""" mgr.write_report( diff --git a/buildscripts/clang_format.py b/buildscripts/clang_format.py index 2b25cccbc43..a93e8ecef8b 100755 --- a/buildscripts/clang_format.py +++ b/buildscripts/clang_format.py @@ -192,10 +192,8 @@ class ClangFormat(object): self.path = os.path.join(ospath, program) if os.path.exists(self.path) and self._validate_version(): break - else: - self.path = None - continue - break + self.path = None + continue else: continue break diff --git a/buildscripts/errorcodes.py b/buildscripts/errorcodes.py index 1b1a347cbc7..fbe69696660 100755 --- a/buildscripts/errorcodes.py +++ b/buildscripts/errorcodes.py @@ -59,7 +59,7 @@ def parse_source_files(callback, src_root): with open(source_file, 'r', encoding='utf-8') as fh: text = fh.read() - if not any([zz in text for zz in quick]): + if not any(zz in text for zz in quick): continue matchiters = [p.finditer(text) for p in patterns] diff --git a/buildscripts/evergreen_gen_multiversion_tests.py b/buildscripts/evergreen_gen_multiversion_tests.py index f639aa55787..5a413ae1e3a 100755 --- a/buildscripts/evergreen_gen_multiversion_tests.py +++ b/buildscripts/evergreen_gen_multiversion_tests.py @@ -93,7 +93,6 @@ def get_backports_required_last_lts_hash(task_path_suffix: str): """Parse the last-lts shell binary to get the commit hash.""" last_lts_shell_exec = os.path.join(task_path_suffix, LAST_LTS_MONGO_BINARY) shell_version = check_output([last_lts_shell_exec, "--version"]).decode('utf-8') - last_lts_commit_hash = "" for line in shell_version.splitlines(): if "gitVersion" in line: version_line = line.split(':')[1] diff --git a/buildscripts/evergreen_task_tags.py b/buildscripts/evergreen_task_tags.py index ea5373b3814..3dbf2bf07b4 100755 --- a/buildscripts/evergreen_task_tags.py +++ b/buildscripts/evergreen_task_tags.py @@ -101,8 +101,8 @@ def is_task_tagged(task, tags, filters): :param filters: List of tags that should not belong to the task. :return: True if task matches the query. """ - if all([tag in task.tags for tag in tags]): - if not filters or not any([tag in task.tags for tag in filters]): + if all(tag in task.tags for tag in tags): + if not filters or not any(tag in task.tags for tag in filters): return True return False diff --git a/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py b/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py index 1ed5ba9694c..97f9f9a721d 100644 --- a/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py +++ b/buildscripts/idl/check_versioned_api_commands_have_idl_definitions.py @@ -42,7 +42,7 @@ from pymongo import MongoClient # Permit imports from "buildscripts". sys.path.append(os.path.normpath(os.path.join(os.path.abspath(__file__), '../../..'))) -# pylint: disable=wrong-import-position +# pylint: disable=wrong-import-position,wrong-import-order from buildscripts.resmokelib import configure_resmoke from buildscripts.resmokelib.logging import loggers from buildscripts.resmokelib.testing.fixtures import interface diff --git a/buildscripts/idl/idl/binder.py b/buildscripts/idl/idl/binder.py index 3a6ea97531c..582c63128cb 100644 --- a/buildscripts/idl/idl/binder.py +++ b/buildscripts/idl/idl/binder.py @@ -1055,7 +1055,7 @@ def _validate_enum_int(ctxt, idl_enum): min_value = min(int_values_set) max_value = max(int_values_set) - valid_int = {x for x in range(min_value, max_value + 1)} + valid_int = set(range(min_value, max_value + 1)) if valid_int != int_values_set: ctxt.add_enum_non_continuous_range_error(idl_enum, idl_enum.name) diff --git a/buildscripts/idl/idl/errors.py b/buildscripts/idl/idl/errors.py index 890025789c6..3e0e6a2fbbc 100644 --- a/buildscripts/idl/idl/errors.py +++ b/buildscripts/idl/idl/errors.py @@ -682,13 +682,13 @@ class ParserContext(object): " struct '%s' is marked as immutable.") % (field_name, struct_name, struct_name)) def add_useless_variant_error(self, location): - # type: (common.SourceLocation,) -> None + # type: (common.SourceLocation) -> None """Add an error about a variant with 0 or 1 variant types.""" self._add_error(location, ERROR_ID_USELESS_VARIANT, ("Cannot declare a variant with only 0 or 1 variant types")) def add_variant_comparison_error(self, location): - # type: (common.SourceLocation,) -> None + # type: (common.SourceLocation) -> None """Add an error about a struct with generate_comparison_operators and a variant field.""" self._add_error(location, ERROR_ID_VARIANT_COMPARISON, ("generate_comparison_operators is not supported with variant types")) diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py index 9d8a7c6de05..b3b2d08fdf0 100644 --- a/buildscripts/idl/idl/generator.py +++ b/buildscripts/idl/idl/generator.py @@ -1745,7 +1745,7 @@ class _CppSourceFileWriter(_CppFileWriterBase): self._writer.write_line( '%s object(localNS);' % (common.title_case(struct.cpp_name))) else: - assert "Missing case" + assert False, "Missing case" else: self._writer.write_line('%s object;' % common.title_case(struct.cpp_name)) diff --git a/buildscripts/idl/tests/test_parser.py b/buildscripts/idl/tests/test_parser.py index 1866216d508..794b79342cf 100644 --- a/buildscripts/idl/tests/test_parser.py +++ b/buildscripts/idl/tests/test_parser.py @@ -1446,7 +1446,7 @@ class TestParser(testcase.IDLTestcase): # type: () -> None """Negative unstable-field test cases.""" self.assert_parse_fail( - textwrap.dedent(f""" + textwrap.dedent(""" commands: foo: description: foo @@ -1464,7 +1464,7 @@ class TestParser(testcase.IDLTestcase): # type: () -> None """Positive same command_name with different api_version test cases.""" self.assert_parse( - textwrap.dedent(f""" + textwrap.dedent(""" commands: foo: description: foo @@ -1692,7 +1692,7 @@ class TestParser(testcase.IDLTestcase): # The 'command_name' and 'command_alias' fields cannot have same value. self.assert_parse_fail( - textwrap.dedent(f""" + textwrap.dedent(""" commands: foo: description: foo diff --git a/buildscripts/idl/tests/testcase.py b/buildscripts/idl/tests/testcase.py index 0a4cf59e050..f1ad1153a77 100644 --- a/buildscripts/idl/tests/testcase.py +++ b/buildscripts/idl/tests/testcase.py @@ -64,6 +64,7 @@ class NothingImportResolver(idl.parser.ImportResolverBase): class IDLTestcase(unittest.TestCase): """IDL Test case base class.""" + # pylint: disable=inconsistent-return-statements def _parse(self, doc_str, resolver): # type: (str, idl.parser.ImportResolverBase) -> idl.syntax.IDLParsedSpec """Parse a document and throw a unittest failure if it fails to parse as a valid YAML document.""" diff --git a/buildscripts/libdeps/libdeps/analyzer.py b/buildscripts/libdeps/libdeps/analyzer.py index 3844eed85ab..f32f0e7a4b9 100644 --- a/buildscripts/libdeps/libdeps/analyzer.py +++ b/buildscripts/libdeps/libdeps/analyzer.py @@ -399,10 +399,9 @@ class ExcludeDependencies(Analyzer): valid_depender_nodes = [] for depender_node in set(self.graph[self.nodes[0]]): - if all([ + if all( bool(excludes_node not in set(self.graph.rgraph[depender_node])) - for excludes_node in self.nodes[1:] - ]): + for excludes_node in self.nodes[1:]): valid_depender_nodes.append(depender_node) return valid_depender_nodes @@ -590,7 +589,7 @@ class GaJsonPrinter(GaPrinter): def print(self): """Print the result data.""" - import json + import json # pylint: disable=import-outside-toplevel results = self.libdeps_graph_analysis.get_results() print(json.dumps(self.serialize(results))) diff --git a/buildscripts/libdeps/libdeps/graph.py b/buildscripts/libdeps/libdeps/graph.py index 03b2a29f4f9..3f3f444a2ff 100644 --- a/buildscripts/libdeps/libdeps/graph.py +++ b/buildscripts/libdeps/libdeps/graph.py @@ -31,6 +31,8 @@ from enum import Enum, auto import networkx +# pylint: disable=invalid-name + class CountTypes(Enum): """Enums for the different types of counts to perform on a graph.""" diff --git a/buildscripts/linter/pylint.py b/buildscripts/linter/pylint.py index 7f5c921f032..cce21f3765c 100644 --- a/buildscripts/linter/pylint.py +++ b/buildscripts/linter/pylint.py @@ -13,7 +13,7 @@ class PyLintLinter(base.LinterBase): def __init__(self): # type: () -> None """Create a pylint linter.""" - super(PyLintLinter, self).__init__("pylint", "2.3.1") + super(PyLintLinter, self).__init__("pylint", "2.7.2") def get_lint_version_cmd_args(self): # type: () -> List[str] diff --git a/buildscripts/packager.py b/buildscripts/packager.py index 18348a13b7f..2e756aeeb88 100755 --- a/buildscripts/packager.py +++ b/buildscripts/packager.py @@ -806,7 +806,7 @@ def make_rpm(distro, build_os, arch, spec, srcdir): # pylint: disable=too-many- "-D", f"dist .{distro.release_dist(build_os)}", "-D", - f"_use_internal_dependency_generator 0", + "_use_internal_dependency_generator 0", "-D", f"dynamic_version {spec.pversion(distro)}", "-D", diff --git a/buildscripts/resmokelib/hang_analyzer/dumper.py b/buildscripts/resmokelib/hang_analyzer/dumper.py index 385dfa88279..fb9dbef9969 100644 --- a/buildscripts/resmokelib/hang_analyzer/dumper.py +++ b/buildscripts/resmokelib/hang_analyzer/dumper.py @@ -110,7 +110,7 @@ class WindowsDumper(Dumper): cdb = spawn.find_executable(debugger) if cdb is not None: return cdb - from win32com.shell import shell, shellcon + from win32com.shell import shell, shellcon # pylint: disable=import-outside-toplevel # Cygwin via sshd does not expose the normal environment variables # Use the shell api to get the variable instead diff --git a/buildscripts/resmokelib/hang_analyzer/extractor.py b/buildscripts/resmokelib/hang_analyzer/extractor.py index e30cfdcefb7..b790bffbc50 100644 --- a/buildscripts/resmokelib/hang_analyzer/extractor.py +++ b/buildscripts/resmokelib/hang_analyzer/extractor.py @@ -31,7 +31,7 @@ def extract_debug_symbols(root_logger): def _extract_tar(path, root_logger): - import shutil + import shutil # pylint: disable=import-outside-toplevel # The file name is always .tgz but it's "secretly" a zip file on Windows :( compressed_format = 'zip' if sys.platform == "win32" else 'gztar' shutil.unpack_archive(path, format=compressed_format) diff --git a/buildscripts/resmokelib/powercycle/lib/remote_operations.py b/buildscripts/resmokelib/powercycle/lib/remote_operations.py index 1d175eebdd1..1e3178163b5 100644 --- a/buildscripts/resmokelib/powercycle/lib/remote_operations.py +++ b/buildscripts/resmokelib/powercycle/lib/remote_operations.py @@ -76,7 +76,7 @@ class RemoteOperations(object): # pylint: disable=too-many-instance-attributes shell=self.use_shell) buff_stdout, _ = process.communicate() buff = buff_stdout.decode("utf-8", "replace") - print(f"Result of command:") + print("Result of command:") print(textwrap.indent(buff, "[result body] ")) return process.poll(), buff diff --git a/buildscripts/resmokelib/powercycle/powercycle.py b/buildscripts/resmokelib/powercycle/powercycle.py index 0a168412e59..7125d6a0ca7 100755 --- a/buildscripts/resmokelib/powercycle/powercycle.py +++ b/buildscripts/resmokelib/powercycle/powercycle.py @@ -481,8 +481,7 @@ def install_tarball(tarball, root_dir): fi ; done ; popd ; - """.format( # pylint: disable=bad-continuation - tarball=tarball, tmp_dir=tmp_dir, root_dir=root_dir) + """.format(tarball=tarball, tmp_dir=tmp_dir, root_dir=root_dir) ret, output = execute_cmd(cmds, use_file=True) shutil.rmtree(tmp_dir) else: diff --git a/buildscripts/resmokelib/powercycle/setup/__init__.py b/buildscripts/resmokelib/powercycle/setup/__init__.py index 001f7d57a96..fb980750466 100644 --- a/buildscripts/resmokelib/powercycle/setup/__init__.py +++ b/buildscripts/resmokelib/powercycle/setup/__init__.py @@ -25,9 +25,9 @@ class SetUpEC2Instance(PowercycleCommand): remote_dir = powercycle_constants.REMOTE_DIR db_path = powercycle_constants.DB_PATH - set_permission_stmt = f"chmod -R 777" + set_permission_stmt = "chmod -R 777" if self.is_windows(): - set_permission_stmt = f"setfacl -s user::rwx,group::rwx,other::rwx" + set_permission_stmt = "setfacl -s user::rwx,group::rwx,other::rwx" cmds = f"{self.sudo} mkdir -p {remote_dir}; {self.sudo} chown -R {user_group} {remote_dir}; {set_permission_stmt} {remote_dir}; ls -ld {remote_dir}" cmds = f"{cmds}; {self.sudo} mkdir -p {db_path}; {self.sudo} chown -R {user_group} {db_path}; {set_permission_stmt} {db_path}; ls -ld {db_path}" diff --git a/buildscripts/resmokelib/run/__init__.py b/buildscripts/resmokelib/run/__init__.py index 705c4ec69b9..444ee40b3f0 100644 --- a/buildscripts/resmokelib/run/__init__.py +++ b/buildscripts/resmokelib/run/__init__.py @@ -269,6 +269,7 @@ class TestRunner(Subcommand): # pylint: disable=too-many-instance-attributes suite.test_kind, suite.get_display_name(), config.RANDOM_SEED) random.shuffle(suite.tests) + # pylint: disable=inconsistent-return-statements def _get_suites(self): """Return the list of suites for this resmoke invocation.""" try: diff --git a/buildscripts/tests/test_burn_in_tests.py b/buildscripts/tests/test_burn_in_tests.py index a1eb2e55c95..c1f146862c4 100644 --- a/buildscripts/tests/test_burn_in_tests.py +++ b/buildscripts/tests/test_burn_in_tests.py @@ -181,7 +181,7 @@ class TestRepeatConfig(unittest.TestCase): repeat_config = under_test.RepeatConfig(repeat_tests_num=5) repeat_options = repeat_config.generate_resmoke_options() - self.assertEqual(repeat_options.strip(), f"--repeatSuites=5") + self.assertEqual(repeat_options.strip(), "--repeatSuites=5") def test_get_resmoke_repeat_options_secs(self): repeat_config = under_test.RepeatConfig(repeat_tests_secs=5) diff --git a/etc/pip/components/lint.req b/etc/pip/components/lint.req index 4c1bc8b839a..aabea5938ea 100644 --- a/etc/pip/components/lint.req +++ b/etc/pip/components/lint.req @@ -3,7 +3,7 @@ GitPython ~= 3.1.7 mypy ~= 0.800; python_version > "3.5" pydocstyle == 2.1.1 -pylint == 2.3.1 +pylint == 2.7.2 structlog ~= 19.2.0 typing yamllint == 1.15.0 |