summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorDaniel Moody <daniel.moody@mongodb.com>2022-07-12 13:38:18 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-12 18:52:26 +0000
commit1919b5797cc6e5bb3d03fe6d0d24a61498b3445e (patch)
treeba56662bdadee2b6009c687112c9ed57249c27ee /buildscripts
parentfafbdd8cc4abd580bb403aaf8ea2dab15375551b (diff)
downloadmongo-1919b5797cc6e5bb3d03fe6d0d24a61498b3445e.tar.gz
SERVER-67993 fix 4.4 pylinters
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/burn_in_tags.py5
-rw-r--r--buildscripts/burn_in_tests.py9
-rw-r--r--buildscripts/burn_in_tests_multiversion.py4
-rwxr-xr-xbuildscripts/bypass_compile_and_fetch_binaries.py11
-rwxr-xr-xbuildscripts/clang_format.py8
-rwxr-xr-xbuildscripts/evergreen_gen_multiversion_tests.py2
-rwxr-xr-xbuildscripts/evergreen_generate_resmoke_tasks.py5
-rwxr-xr-xbuildscripts/evergreen_task_tags.py4
-rw-r--r--buildscripts/gdb/mongo_printers.py4
-rw-r--r--buildscripts/idl/idl/ast.py28
-rw-r--r--buildscripts/idl/idl/binder.py2
-rw-r--r--buildscripts/idl/idl/bson.py2
-rw-r--r--buildscripts/idl/idl/compiler.py2
-rw-r--r--buildscripts/idl/idl/cpp_types.py6
-rw-r--r--buildscripts/idl/idl/errors.py2
-rw-r--r--buildscripts/idl/idl/generator.py10
-rw-r--r--buildscripts/idl/idl/struct_types.py10
-rw-r--r--buildscripts/idl/idl/syntax.py36
-rw-r--r--buildscripts/idl/tests/test_import.py2
-rw-r--r--buildscripts/idl/tests/testcase.py2
-rw-r--r--buildscripts/linter/mypy.py2
-rw-r--r--buildscripts/linter/pydocstyle.py2
-rw-r--r--buildscripts/linter/pylint.py2
-rw-r--r--buildscripts/linter/yapf.py2
-rwxr-xr-xbuildscripts/mongosymb.py2
-rwxr-xr-xbuildscripts/packager.py22
-rwxr-xr-xbuildscripts/packager_enterprise.py18
-rw-r--r--buildscripts/patch_builds/change_data.py4
-rw-r--r--buildscripts/resmokelib/commands/run.py10
-rw-r--r--buildscripts/resmokelib/configure_resmoke.py4
-rw-r--r--buildscripts/resmokelib/hang_analyzer/dumper.py2
-rw-r--r--buildscripts/resmokelib/hang_analyzer/extractor.py3
-rw-r--r--buildscripts/resmokelib/parser.py10
-rw-r--r--buildscripts/resmokelib/testing/fixtures/interface.py10
-rw-r--r--buildscripts/resmokelib/testing/fixtures/shardedcluster.py4
-rw-r--r--buildscripts/resmokelib/testing/fixtures/standalone.py4
-rw-r--r--buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py13
-rw-r--r--buildscripts/resmokelib/testing/job.py16
-rw-r--r--buildscripts/resmokelib/testing/queue_element.py2
-rw-r--r--buildscripts/resmokelib/utils/__init__.py6
-rw-r--r--buildscripts/resmokelib/utils/archival.py2
-rw-r--r--buildscripts/resmokelib/utils/jscomment.py4
-rw-r--r--buildscripts/scons_cache_prune.py6
-rw-r--r--buildscripts/selected_tests.py3
-rwxr-xr-xbuildscripts/setup_multiversion_mongodb.py5
-rw-r--r--buildscripts/tests/test_burn_in_tests.py2
46 files changed, 161 insertions, 153 deletions
diff --git a/buildscripts/burn_in_tags.py b/buildscripts/burn_in_tags.py
index 7cebcbc114e..ba25fe37dfd 100644
--- a/buildscripts/burn_in_tags.py
+++ b/buildscripts/burn_in_tags.py
@@ -5,12 +5,11 @@ import logging
import os
import sys
from typing import Any, Dict, List
-
+from git import Repo
+from shrub.v2 import ShrubProject, BuildVariant, ExistingTask
import click
from evergreen.api import RetryingEvergreenApi, EvergreenApi
-from git import Repo
-from shrub.v2 import ShrubProject, BuildVariant, ExistingTask
# Get relative imports to work when the package is not installed on the PYTHONPATH.
if __name__ == "__main__" and __package__ is None:
diff --git a/buildscripts/burn_in_tests.py b/buildscripts/burn_in_tests.py
index b607c54e6ce..525a3253fc6 100644
--- a/buildscripts/burn_in_tests.py
+++ b/buildscripts/burn_in_tests.py
@@ -14,13 +14,15 @@ from typing import Optional, Set, Tuple, List, Dict
import click
import requests
import yaml
-from evergreen.api import RetryingEvergreenApi, EvergreenApi
+
from git import Repo
import structlog
from structlog.stdlib import LoggerFactory
from shrub.v2 import Task, TaskDependency, BuildVariant, ShrubProject, ExistingTask
+from evergreen.api import RetryingEvergreenApi, EvergreenApi
+
# Get relative imports to work when the package is not installed on the PYTHONPATH.
if __name__ == "__main__" and __package__ is None:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -256,8 +258,9 @@ def find_excludes(selector_file: str) -> Tuple[List, List, List]:
try:
js_test = yml["selector"]["js_test"]
- except KeyError:
- raise Exception(f"The selector file {selector_file} is missing the 'selector.js_test' key")
+ except KeyError as exc:
+ raise Exception(
+ f"The selector file {selector_file} is missing the 'selector.js_test' key") from exc
return (default_if_none(js_test.get("exclude_suites"), []),
default_if_none(js_test.get("exclude_tasks"), []),
diff --git a/buildscripts/burn_in_tests_multiversion.py b/buildscripts/burn_in_tests_multiversion.py
index 9b9deeda41f..3267357e023 100644
--- a/buildscripts/burn_in_tests_multiversion.py
+++ b/buildscripts/burn_in_tests_multiversion.py
@@ -6,12 +6,14 @@ import sys
from typing import Dict
import click
-from evergreen.api import EvergreenApi
+
from git import Repo
from shrub.v2 import BuildVariant, ExistingTask, ShrubProject
import structlog
from structlog.stdlib import LoggerFactory
+from evergreen.api import EvergreenApi
+
import buildscripts.evergreen_gen_multiversion_tests as gen_multiversion
import buildscripts.evergreen_generate_resmoke_tasks as gen_resmoke
from buildscripts.burn_in_tests import GenerateConfig, DEFAULT_PROJECT, CONFIG_FILE, _configure_logging, RepeatConfig, \
diff --git a/buildscripts/bypass_compile_and_fetch_binaries.py b/buildscripts/bypass_compile_and_fetch_binaries.py
index 75379d44a1a..e0b180098e4 100755
--- a/buildscripts/bypass_compile_and_fetch_binaries.py
+++ b/buildscripts/bypass_compile_and_fetch_binaries.py
@@ -12,15 +12,14 @@ import urllib.parse
from urllib.parse import urlparse
import urllib.request
from typing import Any, Dict, List
-
-import click
-
-from evergreen.api import RetryingEvergreenApi, EvergreenApi, Build, Task
from git.repo import Repo
import requests
import structlog
from structlog.stdlib import LoggerFactory
import yaml
+import click
+
+from evergreen.api import RetryingEvergreenApi, EvergreenApi, Build, Task
# Get relative imports to work when the package is not installed on the PYTHONPATH.
if __name__ == "__main__" and __package__ is None:
@@ -338,11 +337,11 @@ def download_file(download_url: str, download_location: str) -> None:
"""
try:
urllib.request.urlretrieve(download_url, download_location)
- except urllib.error.ContentTooShortError:
+ except urllib.error.ContentTooShortError as exc:
LOGGER.warning(
"The artifact could not be completely downloaded. Default"
" compile bypass to false.", filename=download_location)
- raise ValueError("No artifacts were found for the current task")
+ raise ValueError("No artifacts were found for the current task") from exc
def extract_artifacts(filename: str) -> None:
diff --git a/buildscripts/clang_format.py b/buildscripts/clang_format.py
index 2b25cccbc43..db1fd9d23f0 100755
--- a/buildscripts/clang_format.py
+++ b/buildscripts/clang_format.py
@@ -190,12 +190,10 @@ class ClangFormat(object):
for ospath in directories_to_check:
for program in programs:
self.path = os.path.join(ospath, program)
- if os.path.exists(self.path) and self._validate_version():
- break
- else:
+ if not os.path.exists(self.path) or not self._validate_version():
self.path = None
- continue
- break
+ else:
+ break
else:
continue
break
diff --git a/buildscripts/evergreen_gen_multiversion_tests.py b/buildscripts/evergreen_gen_multiversion_tests.py
index f8d7d15e9ff..323de188446 100755
--- a/buildscripts/evergreen_gen_multiversion_tests.py
+++ b/buildscripts/evergreen_gen_multiversion_tests.py
@@ -15,9 +15,9 @@ import requests
import click
import structlog
-from evergreen.api import RetryingEvergreenApi, EvergreenApi
from shrub.v2 import ShrubProject, FunctionCall, Task, TaskDependency, BuildVariant, ExistingTask
+from evergreen.api import RetryingEvergreenApi, EvergreenApi
from buildscripts.resmokelib import config as _config
from buildscripts.resmokelib.multiversionconstants import (LAST_STABLE_MONGO_BINARY,
REQUIRES_FCV_TAG)
diff --git a/buildscripts/evergreen_generate_resmoke_tasks.py b/buildscripts/evergreen_generate_resmoke_tasks.py
index 2426a9167d6..774cb7f0daa 100755
--- a/buildscripts/evergreen_generate_resmoke_tasks.py
+++ b/buildscripts/evergreen_generate_resmoke_tasks.py
@@ -23,11 +23,12 @@ import requests
import structlog
import yaml
-from evergreen.api import EvergreenApi, RetryingEvergreenApi
from pydantic.main import BaseModel
from shrub.v2 import Task, TaskDependency, BuildVariant, ExistingTask, ShrubProject
+from evergreen.api import EvergreenApi, RetryingEvergreenApi
+
# Get relative imports to work when the package is not installed on the PYTHONPATH.
if __name__ == "__main__" and __package__ is None:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -69,7 +70,7 @@ you need to:
(1) add a "large_distro_name" expansion to this build variant ("{build_variant}").
-- or --
-
+
(2) add this build variant ("{build_variant}") to the "build_variant_large_distro_exception"
list in the "etc/generate_subtasks_config.yml" file.
***************************************************************************************
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/gdb/mongo_printers.py b/buildscripts/gdb/mongo_printers.py
index 92cbef3aacf..e58aabca277 100644
--- a/buildscripts/gdb/mongo_printers.py
+++ b/buildscripts/gdb/mongo_printers.py
@@ -502,7 +502,7 @@ class MongoSubPrettyPrinter(gdb.printing.SubPrettyPrinter):
def __init__(self, name, prefix, is_template, printer):
"""Initialize MongoSubPrettyPrinter."""
- super(MongoSubPrettyPrinter, self).__init__(name)
+ super().__init__(name)
self.prefix = prefix
self.printer = printer
self.is_template = is_template
@@ -516,7 +516,7 @@ class MongoPrettyPrinterCollection(gdb.printing.PrettyPrinter):
def __init__(self):
"""Initialize MongoPrettyPrinterCollection."""
- super(MongoPrettyPrinterCollection, self).__init__("mongo", [])
+ super().__init__("mongo", [])
def add(self, name, prefix, is_template, printer):
"""Add a subprinter."""
diff --git a/buildscripts/idl/idl/ast.py b/buildscripts/idl/idl/ast.py
index 6af6ca4e94a..617f55c048b 100644
--- a/buildscripts/idl/idl/ast.py
+++ b/buildscripts/idl/idl/ast.py
@@ -82,7 +82,7 @@ class Global(common.SourceLocation):
self.cpp_includes = [] # type: List[str]
self.configs = None # type: ConfigGlobal
- super(Global, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Struct(common.SourceLocation):
@@ -105,7 +105,7 @@ class Struct(common.SourceLocation):
self.inline_chained_structs = False # type: bool
self.generate_comparison_operators = False # type: bool
self.fields = [] # type: List[Field]
- super(Struct, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Expression(common.SourceLocation):
@@ -118,7 +118,7 @@ class Expression(common.SourceLocation):
self.validate_constexpr = True # type: bool
self.export = False # type: bool
- super(Expression, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Validator(common.SourceLocation):
@@ -142,7 +142,7 @@ class Validator(common.SourceLocation):
self.lte = None # type: Expression
self.callback = None # type: Optional[str]
- super(Validator, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Field(common.SourceLocation):
@@ -196,7 +196,7 @@ class Field(common.SourceLocation):
# Validation rules.
self.validator = None # type: Optional[Validator]
- super(Field, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Command(Struct):
@@ -211,7 +211,7 @@ class Command(Struct):
"""Construct a command."""
self.namespace = None # type: str
self.command_field = None # type: Field
- super(Command, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class EnumValue(common.SourceLocation):
@@ -227,7 +227,7 @@ class EnumValue(common.SourceLocation):
self.name = None # type: str
self.value = None # type: str
- super(EnumValue, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Enum(common.SourceLocation):
@@ -246,7 +246,7 @@ class Enum(common.SourceLocation):
self.type = None # type: str
self.values = [] # type: List[EnumValue]
- super(Enum, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Condition(common.SourceLocation):
@@ -259,7 +259,7 @@ class Condition(common.SourceLocation):
self.constexpr = None # type: str
self.preprocessor = None # type: str
- super(Condition, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ServerParameterClass(common.SourceLocation):
@@ -274,7 +274,7 @@ class ServerParameterClass(common.SourceLocation):
self.override_ctor = False # type: bool
self.override_set = False # type: bool
- super(ServerParameterClass, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ServerParameter(common.SourceLocation):
@@ -301,7 +301,7 @@ class ServerParameter(common.SourceLocation):
self.validator = None # type: Validator
self.on_update = None # type: str
- super(ServerParameter, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class GlobalInitializer(common.SourceLocation):
@@ -315,7 +315,7 @@ class GlobalInitializer(common.SourceLocation):
self.register = None # type: str
self.store = None # type: str
- super(GlobalInitializer, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ConfigGlobal(common.SourceLocation):
@@ -328,7 +328,7 @@ class ConfigGlobal(common.SourceLocation):
# Other config globals are consumed in bind phase.
self.initializer = None # type: GlobalInitializer
- super(ConfigGlobal, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ConfigOption(common.SourceLocation):
@@ -365,4 +365,4 @@ class ConfigOption(common.SourceLocation):
self.positional_end = None # type: int
self.validator = None # type: Validator
- super(ConfigOption, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
diff --git a/buildscripts/idl/idl/binder.py b/buildscripts/idl/idl/binder.py
index 4d9bd3ff79c..fbd5c944abd 100644
--- a/buildscripts/idl/idl/binder.py
+++ b/buildscripts/idl/idl/binder.py
@@ -850,7 +850,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/bson.py b/buildscripts/idl/idl/bson.py
index 3d1e004dbc0..4ff5b42246b 100644
--- a/buildscripts/idl/idl/bson.py
+++ b/buildscripts/idl/idl/bson.py
@@ -98,7 +98,7 @@ def cpp_bson_type_name(name):
def list_valid_types():
# type: () -> List[str]
"""Return a list of supported bson types."""
- return [a for a in _BSON_TYPE_INFORMATION]
+ return list(_BSON_TYPE_INFORMATION)
def is_valid_bindata_subtype(name):
diff --git a/buildscripts/idl/idl/compiler.py b/buildscripts/idl/idl/compiler.py
index fb1c1278f1f..03f3bd6c44b 100644
--- a/buildscripts/idl/idl/compiler.py
+++ b/buildscripts/idl/idl/compiler.py
@@ -73,7 +73,7 @@ class CompilerImportResolver(parser.ImportResolverBase):
"""Construct a ImportResolver."""
self._import_directories = import_directories
- super(CompilerImportResolver, self).__init__()
+ super().__init__()
def resolve(self, base_file, imported_file_name):
# type: (str, str) -> str
diff --git a/buildscripts/idl/idl/cpp_types.py b/buildscripts/idl/idl/cpp_types.py
index 72f8f31fa57..9d9834d4d61 100644
--- a/buildscripts/idl/idl/cpp_types.py
+++ b/buildscripts/idl/idl/cpp_types.py
@@ -247,7 +247,7 @@ class _CppTypeView(CppTypeBase):
# type: (ast.Field, str, str) -> None
self._storage_type = storage_type
self._view_type = view_type
- super(_CppTypeView, self).__init__(field)
+ super().__init__(field)
def get_type_name(self):
# type: () -> str
@@ -363,7 +363,7 @@ class _CppTypeDelegating(CppTypeBase):
def __init__(self, base, field):
# type: (CppTypeBase, ast.Field) -> None
self._base = base
- super(_CppTypeDelegating, self).__init__(field)
+ super().__init__(field)
def get_type_name(self):
# type: () -> str
@@ -614,7 +614,7 @@ class _CommonBsonCppTypeBase(BsonCppTypeBase):
def __init__(self, field, deserialize_method_name):
# type: (ast.Field, str) -> None
self._deserialize_method_name = deserialize_method_name
- super(_CommonBsonCppTypeBase, self).__init__(field)
+ super().__init__(field)
def gen_deserializer_expression(self, indented_writer, object_instance):
# type: (writer.IndentedTextWriter, str) -> str
diff --git a/buildscripts/idl/idl/errors.py b/buildscripts/idl/idl/errors.py
index fc3ecef8ff8..795e5e008d2 100644
--- a/buildscripts/idl/idl/errors.py
+++ b/buildscripts/idl/idl/errors.py
@@ -136,7 +136,7 @@ class ParserError(common.SourceLocation):
# pylint: disable=too-many-arguments
self.error_id = error_id
self.msg = msg
- super(ParserError, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
def __str__(self):
# type: () -> str
diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py
index 01a528cb603..25f5456d5be 100644
--- a/buildscripts/idl/idl/generator.py
+++ b/buildscripts/idl/idl/generator.py
@@ -184,7 +184,7 @@ def _get_all_fields(struct):
all_fields += struct.fields
- return sorted([field for field in all_fields], key=lambda f: f.cpp_name)
+ return sorted(all_fields, key=lambda f: f.cpp_name)
class _FieldUsageCheckerBase(object, metaclass=ABCMeta):
@@ -226,7 +226,7 @@ class _SlowFieldUsageChecker(_FieldUsageCheckerBase):
def __init__(self, indented_writer):
# type: (writer.IndentedTextWriter) -> None
- super(_SlowFieldUsageChecker, self).__init__(indented_writer)
+ super().__init__(indented_writer)
self._writer.write_line('std::set<StringData> usedFields;')
@@ -285,7 +285,7 @@ class _FastFieldUsageChecker(_FieldUsageCheckerBase):
def __init__(self, indented_writer, fields):
# type: (writer.IndentedTextWriter, List[ast.Field]) -> None
- super(_FastFieldUsageChecker, self).__init__(indented_writer)
+ super().__init__(indented_writer)
self._writer.write_line('std::bitset<%d> usedFields;' % (len(fields)))
@@ -1054,7 +1054,7 @@ class _CppSourceFileWriter(_CppFileWriterBase):
# type: (writer.IndentedTextWriter, str) -> None
"""Create a C++ .cpp file code writer."""
self._target_arch = target_arch
- super(_CppSourceFileWriter, self).__init__(indented_writer)
+ super().__init__(indented_writer)
def _gen_field_deserializer_expression(self, element_name, field):
# type: (str, ast.Field) -> str
@@ -1450,7 +1450,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/idl/struct_types.py b/buildscripts/idl/idl/struct_types.py
index f5d7a7489d9..970ed48560e 100644
--- a/buildscripts/idl/idl/struct_types.py
+++ b/buildscripts/idl/idl/struct_types.py
@@ -314,7 +314,7 @@ class _CommandBaseTypeInfo(_StructTypeInfo):
"""Create a _CommandBaseTypeInfo instance."""
self._command = command
- super(_CommandBaseTypeInfo, self).__init__(command)
+ super().__init__(command)
def get_op_msg_request_serializer_method(self):
# type: () -> Optional[MethodInfo]
@@ -344,7 +344,7 @@ class _IgnoredCommandTypeInfo(_CommandBaseTypeInfo):
"""Create a _IgnoredCommandTypeInfo instance."""
self._command = command
- super(_IgnoredCommandTypeInfo, self).__init__(command)
+ super().__init__(command)
def get_serializer_method(self):
# type: () -> MethodInfo
@@ -387,7 +387,7 @@ class _CommandFromType(_CommandBaseTypeInfo):
"""Create a _CommandFromType instance."""
assert command.command_field
self._command = command
- super(_CommandFromType, self).__init__(command)
+ super().__init__(command)
def get_constructor_method(self):
# type: () -> MethodInfo
@@ -449,7 +449,7 @@ class _CommandWithNamespaceTypeInfo(_CommandBaseTypeInfo):
"""Create a _CommandWithNamespaceTypeInfo instance."""
self._command = command
- super(_CommandWithNamespaceTypeInfo, self).__init__(command)
+ super().__init__(command)
def get_constructor_method(self):
# type: () -> MethodInfo
@@ -511,7 +511,7 @@ class _CommandWithUUIDNamespaceTypeInfo(_CommandBaseTypeInfo):
"""Create a _CommandWithUUIDNamespaceTypeInfo instance."""
self._command = command
- super(_CommandWithUUIDNamespaceTypeInfo, self).__init__(command)
+ super().__init__(command)
def get_constructor_method(self):
# type: () -> MethodInfo
diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py
index 3c9bb7bedf1..3b1c90721a8 100644
--- a/buildscripts/idl/idl/syntax.py
+++ b/buildscripts/idl/idl/syntax.py
@@ -231,7 +231,7 @@ class Global(common.SourceLocation):
self.cpp_includes = [] # type: List[str]
self.configs = None # type: ConfigGlobal
- super(Global, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Import(common.SourceLocation):
@@ -248,7 +248,7 @@ class Import(common.SourceLocation):
# All imports directly or indirectly included
self.dependencies = [] # type: List[str]
- super(Import, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Type(common.SourceLocation):
@@ -274,7 +274,7 @@ class Type(common.SourceLocation):
self.deserializer = None # type: str
self.default = None # type: str
- super(Type, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Validator(common.SourceLocation):
@@ -298,7 +298,7 @@ class Validator(common.SourceLocation):
self.lte = None # type: Expression
self.callback = None # type: str
- super(Validator, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Field(common.SourceLocation):
@@ -331,7 +331,7 @@ class Field(common.SourceLocation):
self.serialize_op_msg_request_only = False # type: bool
self.constructed = False # type: bool
- super(Field, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ChainedStruct(common.SourceLocation):
@@ -347,7 +347,7 @@ class ChainedStruct(common.SourceLocation):
self.name = None # type: str
self.cpp_name = None # type: str
- super(ChainedStruct, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ChainedType(common.SourceLocation):
@@ -363,7 +363,7 @@ class ChainedType(common.SourceLocation):
self.name = None # type: str
self.cpp_name = None # type: str
- super(ChainedType, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Struct(common.SourceLocation):
@@ -398,7 +398,7 @@ class Struct(common.SourceLocation):
# Internal property: cpp_namespace from globals section
self.cpp_namespace = None # type: str
- super(Struct, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Command(Struct):
@@ -414,7 +414,7 @@ class Command(Struct):
self.namespace = None # type: str
self.type = None # type: str
- super(Command, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class EnumValue(common.SourceLocation):
@@ -430,7 +430,7 @@ class EnumValue(common.SourceLocation):
self.name = None # type: str
self.value = None # type: str
- super(EnumValue, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Enum(common.SourceLocation):
@@ -455,7 +455,7 @@ class Enum(common.SourceLocation):
# Internal property: cpp_namespace from globals section
self.cpp_namespace = None # type: str
- super(Enum, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Condition(common.SourceLocation):
@@ -468,7 +468,7 @@ class Condition(common.SourceLocation):
self.constexpr = None # type: str
self.preprocessor = None # type: str
- super(Condition, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class Expression(common.SourceLocation):
@@ -482,7 +482,7 @@ class Expression(common.SourceLocation):
self.expr = None # type: str
self.is_constexpr = True # type: bool
- super(Expression, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ServerParameterClass(common.SourceLocation):
@@ -497,7 +497,7 @@ class ServerParameterClass(common.SourceLocation):
self.override_ctor = False # type: bool
self.override_set = False # type: bool
- super(ServerParameterClass, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ServerParameter(common.SourceLocation):
@@ -524,7 +524,7 @@ class ServerParameter(common.SourceLocation):
self.validator = None # type: Validator
self.on_update = None # type: str
- super(ServerParameter, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class GlobalInitializer(common.SourceLocation):
@@ -538,7 +538,7 @@ class GlobalInitializer(common.SourceLocation):
self.register = None # type: str
self.store = None # type: str
- super(GlobalInitializer, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ConfigGlobal(common.SourceLocation):
@@ -551,7 +551,7 @@ class ConfigGlobal(common.SourceLocation):
self.source = [] # type: List[str]
self.initializer = None # type: GlobalInitializer
- super(ConfigGlobal, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
class ConfigOption(common.SourceLocation):
@@ -588,4 +588,4 @@ class ConfigOption(common.SourceLocation):
self.positional = None # type str
self.validator = None # type: Validator
- super(ConfigOption, self).__init__(file_name, line, column)
+ super().__init__(file_name, line, column)
diff --git a/buildscripts/idl/tests/test_import.py b/buildscripts/idl/tests/test_import.py
index 67cd2a7dcd6..2daf20959d1 100644
--- a/buildscripts/idl/tests/test_import.py
+++ b/buildscripts/idl/tests/test_import.py
@@ -53,7 +53,7 @@ class DictionaryImportResolver(idl.parser.ImportResolverBase):
# type: (Dict[str, str]) -> None
"""Construct a DictionaryImportResolver."""
self._import_dict = import_dict
- super(DictionaryImportResolver, self).__init__()
+ super().__init__()
def resolve(self, base_file, imported_file_name):
# type: (str, str) -> str
diff --git a/buildscripts/idl/tests/testcase.py b/buildscripts/idl/tests/testcase.py
index 0a4cf59e050..92c3cd581c1 100644
--- a/buildscripts/idl/tests/testcase.py
+++ b/buildscripts/idl/tests/testcase.py
@@ -64,7 +64,7 @@ class NothingImportResolver(idl.parser.ImportResolverBase):
class IDLTestcase(unittest.TestCase):
"""IDL Test case base class."""
- def _parse(self, doc_str, resolver):
+ def _parse(self, doc_str, resolver): # pylint: disable=inconsistent-return-statements
# 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/linter/mypy.py b/buildscripts/linter/mypy.py
index e87d26c5e43..9696f96158d 100644
--- a/buildscripts/linter/mypy.py
+++ b/buildscripts/linter/mypy.py
@@ -14,7 +14,7 @@ class MypyLinter(base.LinterBase):
"""Create a mypy linter."""
# User can override the location of mypy from an environment variable.
- super(MypyLinter, self).__init__("mypy", "0.800", os.getenv("MYPY"))
+ super().__init__("mypy", "0.800", os.getenv("MYPY"))
def get_lint_version_cmd_args(self):
# type: () -> List[str]
diff --git a/buildscripts/linter/pydocstyle.py b/buildscripts/linter/pydocstyle.py
index 8d6b7dde0c7..816e305a6f6 100644
--- a/buildscripts/linter/pydocstyle.py
+++ b/buildscripts/linter/pydocstyle.py
@@ -11,7 +11,7 @@ class PyDocstyleLinter(base.LinterBase):
def __init__(self):
# type: () -> None
"""Create a pydocstyle linter."""
- super(PyDocstyleLinter, self).__init__("pydocstyle", "2.1.1")
+ super().__init__("pydocstyle", "2.1.1")
def get_lint_version_cmd_args(self):
# type: () -> List[str]
diff --git a/buildscripts/linter/pylint.py b/buildscripts/linter/pylint.py
index 7f5c921f032..6d2dd048953 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().__init__("pylint", "2.3.1")
def get_lint_version_cmd_args(self):
# type: () -> List[str]
diff --git a/buildscripts/linter/yapf.py b/buildscripts/linter/yapf.py
index e339e3fc763..d0ae482d6c9 100644
--- a/buildscripts/linter/yapf.py
+++ b/buildscripts/linter/yapf.py
@@ -11,7 +11,7 @@ class YapfLinter(base.LinterBase):
def __init__(self):
# type: () -> None
"""Create a yapf linter."""
- super(YapfLinter, self).__init__("yapf", "0.26.0")
+ super().__init__("yapf", "0.26.0")
def get_lint_version_cmd_args(self):
# type: () -> List[str]
diff --git a/buildscripts/mongosymb.py b/buildscripts/mongosymb.py
index 44cfd56008d..76b7d39ac50 100755
--- a/buildscripts/mongosymb.py
+++ b/buildscripts/mongosymb.py
@@ -228,7 +228,7 @@ def main():
if not trace_doc:
print("could not find json backtrace object in input", file=sys.stderr)
- exit(1)
+ sys.exit(1)
output_fn = None
if options.output_format == 'json':
diff --git a/buildscripts/packager.py b/buildscripts/packager.py
index c515301b895..e641be75fbb 100755
--- a/buildscripts/packager.py
+++ b/buildscripts/packager.py
@@ -502,10 +502,10 @@ def unpack_binaries_into(build_os, arch, spec, where):
print("moving file: %s/%s" % (release_dir, releasefile))
os.rename("%s/%s" % (release_dir, releasefile), releasefile)
os.rmdir(release_dir)
- except Exception:
+ except Exception as oexc:
exc = sys.exc_info()[1]
os.chdir(rootdir)
- raise exc
+ raise exc from oexc
os.chdir(rootdir)
@@ -666,12 +666,12 @@ def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
try:
os.mkdir(dname)
break
- except OSError:
+ except OSError as oexc:
exc = sys.exc_info()[1]
if exc.errno == errno.EEXIST:
pass
else:
- raise exc
+ raise exc from oexc
i = i + 1
# Put the stuff in our new directory.
@@ -686,12 +686,12 @@ def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
try:
os.symlink(dname, tmpnam)
break
- except OSError: # as exc: # Python >2.5
+ except OSError as oexc: # as exc: # Python >2.5
exc = sys.exc_info()[1]
if exc.errno == errno.EEXIST:
pass
else:
- raise exc
+ raise exc from oexc
i = i + 1
# Make a symlink to the old directory; this symlink will be
@@ -704,12 +704,12 @@ def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
try:
os.symlink(os.readlink(dst), oldnam)
break
- except OSError: # as exc: # Python >2.5
+ except OSError as oexc: # as exc: # Python >2.5
exc = sys.exc_info()[1]
if exc.errno == errno.EEXIST:
pass
else:
- raise exc
+ raise exc from oexc
os.rename(tmpnam, dst)
if oldnam:
@@ -803,7 +803,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",
@@ -844,12 +844,12 @@ def ensure_dir(filename):
dirpart = os.path.dirname(filename)
try:
os.makedirs(dirpart)
- except OSError: # as exc: # Python >2.5
+ except OSError as oexc: # as exc: # Python >2.5
exc = sys.exc_info()[1]
if exc.errno == errno.EEXIST:
pass
else:
- raise exc
+ raise exc from oexc
return filename
diff --git a/buildscripts/packager_enterprise.py b/buildscripts/packager_enterprise.py
index 4bbbfb4b738..35213a4152b 100755
--- a/buildscripts/packager_enterprise.py
+++ b/buildscripts/packager_enterprise.py
@@ -146,7 +146,7 @@ class EnterpriseDistro(packager.Distro):
if re.search("(redhat|fedora|centos)", self.dname):
return ["rhel80", "rhel70", "rhel62", "rhel57"]
- return super(EnterpriseDistro, self).build_os(arch)
+ return super().build_os(arch)
# pylint: enable=too-many-return-statements
@@ -228,10 +228,10 @@ def unpack_binaries_into(build_os, arch, spec, where):
for releasefile in "bin", "snmp", "LICENSE-Enterprise.txt", "README", "THIRD-PARTY-NOTICES", "MPL-2":
os.rename("%s/%s" % (release_dir, releasefile), releasefile)
os.rmdir(release_dir)
- except Exception:
+ except Exception as oexc:
exc = sys.exc_info()[1]
os.chdir(rootdir)
- raise exc
+ raise exc from oexc
os.chdir(rootdir)
@@ -333,12 +333,12 @@ def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
try:
os.mkdir(dname)
break
- except OSError:
+ except OSError as oexc:
exc = sys.exc_info()[1]
if exc.errno == errno.EEXIST:
pass
else:
- raise exc
+ raise exc from oexc
idx = idx + 1
# Put the stuff in our new directory.
@@ -353,12 +353,12 @@ def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
try:
os.symlink(dname, tmpnam)
break
- except OSError: # as exc: # Python >2.5
+ except OSError as oexc: # as exc: # Python >2.5
exc = sys.exc_info()[1]
if exc.errno == errno.EEXIST:
pass
else:
- raise exc
+ raise exc from oexc
idx = idx + 1
# Make a symlink to the old directory; this symlink will be
@@ -371,12 +371,12 @@ def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
try:
os.symlink(os.readlink(dst), oldnam)
break
- except OSError: # as exc: # Python >2.5
+ except OSError as oexc: # as exc: # Python >2.5
exc = sys.exc_info()[1]
if exc.errno == errno.EEXIST:
pass
else:
- raise exc
+ raise exc from oexc
os.rename(tmpnam, dst)
if oldnam:
diff --git a/buildscripts/patch_builds/change_data.py b/buildscripts/patch_builds/change_data.py
index 59d07dcb8b9..026e1c0ea2f 100644
--- a/buildscripts/patch_builds/change_data.py
+++ b/buildscripts/patch_builds/change_data.py
@@ -4,9 +4,11 @@ from itertools import chain
from typing import Any, Dict, Iterable, Set, Optional, List
import structlog
-from evergreen import EvergreenApi
+
from git import DiffIndex, Repo
+from evergreen import EvergreenApi
+
LOGGER = structlog.get_logger(__name__)
RevisionMap = Dict[str, str]
diff --git a/buildscripts/resmokelib/commands/run.py b/buildscripts/resmokelib/commands/run.py
index 0d8fe334597..c3c9a7a3ae1 100644
--- a/buildscripts/resmokelib/commands/run.py
+++ b/buildscripts/resmokelib/commands/run.py
@@ -248,7 +248,7 @@ class TestRunner(interface.Subcommand): # pylint: disable=too-many-instance-att
suite.test_kind, suite.get_display_name(), config.RANDOM_SEED)
random.shuffle(suite.tests)
- def _get_suites(self):
+ def _get_suites(self): # pylint: disable=inconsistent-return-statements
"""Return the list of suites for this resmoke invocation."""
try:
return suitesconfig.get_suites(config.SUITE_FILES, config.TEST_FILES)
@@ -297,9 +297,9 @@ class TestRunner(interface.Subcommand): # pylint: disable=too-many-instance-att
proto_file = os.path.join(root_dir, "buildscripts", "resmokelib", "core", "jasper.proto")
try:
well_known_protos_include = pkg_resources.resource_filename("grpc_tools", "_proto")
- except ImportError:
+ except ImportError as exc:
raise ImportError("You must run: sys.executable + '-m pip install grpcio grpcio-tools "
- "googleapis-common-protos' to use --spawnUsing=jasper.")
+ "googleapis-common-protos' to use --spawnUsing=jasper.") from exc
# We use the build/ directory as the output directory because the generated files aren't
# meant to because tracked by git or linted.
@@ -331,8 +331,8 @@ class TestRunner(interface.Subcommand): # pylint: disable=too-many-instance-att
sys.path.append(os.path.dirname(proto_out))
- from jasper import jasper_pb2
- from jasper import jasper_pb2_grpc
+ from jasper import jasper_pb2 # pylint: disable=import-outside-toplevel
+ from jasper import jasper_pb2_grpc # pylint: disable=import-outside-toplevel
jasper_process.Process.jasper_pb2 = jasper_pb2
jasper_process.Process.jasper_pb2_grpc = jasper_pb2_grpc
diff --git a/buildscripts/resmokelib/configure_resmoke.py b/buildscripts/resmokelib/configure_resmoke.py
index 1177cfa53e9..ae94be34fcf 100644
--- a/buildscripts/resmokelib/configure_resmoke.py
+++ b/buildscripts/resmokelib/configure_resmoke.py
@@ -344,8 +344,8 @@ def _set_logging_config():
return
raise ValueError("Unknown logger '%s'" % pathname)
- except FileNotFoundError:
- raise IOError("Directory {} does not exist.".format(_config.LOGGER_DIR))
+ except FileNotFoundError as exc:
+ raise IOError("Directory {} does not exist.".format(_config.LOGGER_DIR)) from exc
def _expand_user(pathname):
diff --git a/buildscripts/resmokelib/hang_analyzer/dumper.py b/buildscripts/resmokelib/hang_analyzer/dumper.py
index 31a3a2d78f9..151eaf0d193 100644
--- a/buildscripts/resmokelib/hang_analyzer/dumper.py
+++ b/buildscripts/resmokelib/hang_analyzer/dumper.py
@@ -61,7 +61,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 7ea38d5ad3a..c2801c45e2a 100644
--- a/buildscripts/resmokelib/hang_analyzer/extractor.py
+++ b/buildscripts/resmokelib/hang_analyzer/extractor.py
@@ -3,6 +3,7 @@
import os
import sys
import glob
+import shutil
def extract_debug_symbols(root_logger):
@@ -31,7 +32,7 @@ def extract_debug_symbols(root_logger):
def _extract_tar(path, root_logger):
- import shutil
+
# 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/parser.py b/buildscripts/resmokelib/parser.py
index 7334f424360..63ee73d9811 100644
--- a/buildscripts/resmokelib/parser.py
+++ b/buildscripts/resmokelib/parser.py
@@ -538,25 +538,25 @@ def to_local_args(input_args=None): # pylint: disable=too-many-branches,too-man
# one such argument has been visited.
if arg_dest in arg_dests_visited:
continue
- else:
- arg_dests_visited.add(arg_dest)
+
+ arg_dests_visited.add(arg_dest)
# If the arg doesn't exist in the parsed namespace, skip.
# This is mainly for "--help".
if not hasattr(parsed_args, arg_dest):
continue
# Skip any evergreen centric args.
- elif group.title in [_INTERNAL_OPTIONS_TITLE, _EVERGREEN_ARGUMENT_TITLE]:
+ if group.title in [_INTERNAL_OPTIONS_TITLE, _EVERGREEN_ARGUMENT_TITLE]:
continue
# Keep these args.
- elif group.title == 'optional arguments':
+ if group.title == 'optional arguments':
arg_name = action.option_strings[-1]
# If an option has the same value as the default, we don't need to specify it.
if getattr(parsed_args, arg_dest, None) == action.default:
continue
# These are arguments that take no value.
- elif action.nargs == 0:
+ if action.nargs == 0:
other_local_args.append(arg_name)
elif isinstance(action, argparse._AppendAction): # pylint: disable=protected-access
args = [format_option(arg_name, elem) for elem in arg_value]
diff --git a/buildscripts/resmokelib/testing/fixtures/interface.py b/buildscripts/resmokelib/testing/fixtures/interface.py
index c22765b1619..553e869dedd 100644
--- a/buildscripts/resmokelib/testing/fixtures/interface.py
+++ b/buildscripts/resmokelib/testing/fixtures/interface.py
@@ -198,21 +198,21 @@ class ReplFixture(Fixture):
remaining = deadline - time.time()
insert_fn(remaining)
break
- except pymongo.errors.ConnectionFailure:
+ except pymongo.errors.ConnectionFailure as exc:
remaining = deadline - time.time()
if remaining <= 0.0:
message = "Failed to connect to {} within {} minutes".format(
self.get_driver_connection_url(), ReplFixture.AWAIT_REPL_TIMEOUT_MINS)
self.logger.error(message)
- raise errors.ServerFailure(message)
- except pymongo.errors.WTimeoutError:
+ raise errors.ServerFailure(message) from exc
+ except pymongo.errors.WTimeoutError as exc:
message = "Replication of write operation timed out."
self.logger.error(message)
- raise errors.ServerFailure(message)
+ raise errors.ServerFailure(message) from exc
except pymongo.errors.PyMongoError as err:
message = "Write operation on {} failed: {}".format(
self.get_driver_connection_url(), err)
- raise errors.ServerFailure(message)
+ raise errors.ServerFailure(message) from err
class NoOpFixture(Fixture):
diff --git a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
index 3f871f6f1da..2152cf42daa 100644
--- a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
+++ b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
@@ -465,12 +465,12 @@ class _MongoSFixture(interface.Fixture):
client = self.mongo_client(timeout_millis=500)
client.admin.command("ping")
break
- except pymongo.errors.ConnectionFailure:
+ except pymongo.errors.ConnectionFailure as exc:
remaining = deadline - time.time()
if remaining <= 0.0:
raise errors.ServerFailure(
"Failed to connect to mongos on port {} after {} seconds".format(
- self.port, standalone.MongoDFixture.AWAIT_READY_TIMEOUT_SECS))
+ self.port, standalone.MongoDFixture.AWAIT_READY_TIMEOUT_SECS)) from exc
self.logger.info("Waiting to connect to mongos on port %d.", self.port)
time.sleep(0.1) # Wait a little bit before trying again.
diff --git a/buildscripts/resmokelib/testing/fixtures/standalone.py b/buildscripts/resmokelib/testing/fixtures/standalone.py
index 908085077e2..4a433f0bfa2 100644
--- a/buildscripts/resmokelib/testing/fixtures/standalone.py
+++ b/buildscripts/resmokelib/testing/fixtures/standalone.py
@@ -105,12 +105,12 @@ class MongoDFixture(interface.Fixture):
client = self.mongo_client(timeout_millis=500)
client.admin.command("ping")
break
- except pymongo.errors.ConnectionFailure:
+ except pymongo.errors.ConnectionFailure as exc:
remaining = deadline - time.time()
if remaining <= 0.0:
raise errors.ServerFailure(
"Failed to connect to mongod on port {} after {} seconds".format(
- self.port, MongoDFixture.AWAIT_READY_TIMEOUT_SECS))
+ self.port, MongoDFixture.AWAIT_READY_TIMEOUT_SECS)) from exc
self.logger.info("Waiting to connect to mongod on port %d.", self.port)
time.sleep(0.1) # Wait a little bit before trying again.
diff --git a/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py b/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py
index 1136d69806e..33912e323e4 100644
--- a/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py
+++ b/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py
@@ -198,10 +198,10 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase):
try:
secondary.teardown()
- except errors.ServerFailure:
+ except errors.ServerFailure as exc:
raise errors.ServerFailure(
"{} did not exit cleanly after reconciling the end of its oplog".format(
- secondary))
+ secondary)) from exc
self.logger.info("Starting the fixture back up again with its data files intact for final"
" validation...")
@@ -244,9 +244,10 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase):
try:
self.fixture.teardown()
- except errors.ServerFailure:
+ except errors.ServerFailure as exc:
raise errors.ServerFailure(
- "{} did not exit cleanly after verifying data consistency".format(self.fixture))
+ "{} did not exit cleanly after verifying data consistency".format(
+ self.fixture)) from exc
self.logger.info("Starting the fixture back up again with no data...")
self.fixture.setup()
@@ -407,10 +408,10 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase):
try:
secondary.teardown()
- except errors.ServerFailure:
+ except errors.ServerFailure as exc:
raise errors.ServerFailure(
"{} did not exit cleanly after being started up as a standalone".format(
- secondary))
+ secondary)) from exc
except pymongo.errors.OperationFailure as err:
self.logger.exception(
"Failed to read the minValid document, the oplogTruncateAfterPoint document,"
diff --git a/buildscripts/resmokelib/testing/job.py b/buildscripts/resmokelib/testing/job.py
index 5707a218a1a..3de11ad3278 100644
--- a/buildscripts/resmokelib/testing/job.py
+++ b/buildscripts/resmokelib/testing/job.py
@@ -220,18 +220,18 @@ class Job(object): # pylint: disable=too-many-instance-attributes
except errors.StopExecution:
raise
- except errors.ServerFailure:
+ except errors.ServerFailure as exc:
self.logger.exception("%s marked as a failure by a hook's before_test.",
test.short_description())
self._fail_test(test, sys.exc_info(), return_code=2)
- raise errors.StopExecution("A hook's before_test failed")
+ raise errors.StopExecution("A hook's before_test failed") from exc
- except errors.TestFailure:
+ except errors.TestFailure as exc:
self.logger.exception("%s marked as a failure by a hook's before_test.",
test.short_description())
self._fail_test(test, sys.exc_info(), return_code=1)
if self.suite_options.fail_fast:
- raise errors.StopExecution("A hook's before_test failed")
+ raise errors.StopExecution("A hook's before_test failed") from exc
except:
# Record the before_test() error in 'self.report'.
@@ -253,18 +253,18 @@ class Job(object): # pylint: disable=too-many-instance-attributes
except errors.StopExecution:
raise
- except errors.ServerFailure:
+ except errors.ServerFailure as exc:
self.logger.exception("%s marked as a failure by a hook's after_test.",
test.short_description())
self.report.setFailure(test, return_code=2)
- raise errors.StopExecution("A hook's after_test failed")
+ raise errors.StopExecution("A hook's after_test failed") from exc
- except errors.TestFailure:
+ except errors.TestFailure as exc:
self.logger.exception("%s marked as a failure by a hook's after_test.",
test.short_description())
self.report.setFailure(test, return_code=1)
if self.suite_options.fail_fast:
- raise errors.StopExecution("A hook's after_test failed")
+ raise errors.StopExecution("A hook's after_test failed") from exc
except:
self.report.setError(test)
diff --git a/buildscripts/resmokelib/testing/queue_element.py b/buildscripts/resmokelib/testing/queue_element.py
index db30e95e1fa..f1100666bce 100644
--- a/buildscripts/resmokelib/testing/queue_element.py
+++ b/buildscripts/resmokelib/testing/queue_element.py
@@ -48,7 +48,7 @@ class QueueElemRepeatTime(QueueElem):
def __init__(self, testcase, config, suite_options):
"""Initialize QueueElemRepeatTime class."""
- super(QueueElemRepeatTime, self).__init__(testcase, config, suite_options)
+ super().__init__(testcase, config, suite_options)
self.repeat_num_min = suite_options.num_repeat_tests_min
self.repeat_num_max = suite_options.num_repeat_tests_max
self.repeat_secs = suite_options.time_repeat_tests_secs
diff --git a/buildscripts/resmokelib/utils/__init__.py b/buildscripts/resmokelib/utils/__init__.py
index 04099310bec..73a66741932 100644
--- a/buildscripts/resmokelib/utils/__init__.py
+++ b/buildscripts/resmokelib/utils/__init__.py
@@ -80,7 +80,7 @@ def load_yaml_file(filename):
with open(filename, "r") as fp:
return yaml.safe_load(fp)
except yaml.YAMLError as err:
- raise ValueError("File '%s' contained invalid YAML: %s" % (filename, err))
+ raise ValueError("File '%s' contained invalid YAML: %s" % (filename, err)) from err
def dump_yaml_file(value, filename):
@@ -89,7 +89,7 @@ def dump_yaml_file(value, filename):
with open(filename, "w") as fp:
return yaml.safe_dump(value, fp)
except yaml.YAMLError as err:
- raise ValueError("Could not write YAML to file '%s': %s" % (filename, err))
+ raise ValueError("Could not write YAML to file '%s': %s" % (filename, err)) from err
def dump_yaml(value):
@@ -103,4 +103,4 @@ def load_yaml(value):
try:
return yaml.safe_load(value)
except yaml.YAMLError as err:
- raise ValueError("Attempted to parse invalid YAML value '%s': %s" % (value, err))
+ raise ValueError("Attempted to parse invalid YAML value '%s': %s" % (value, err)) from err
diff --git a/buildscripts/resmokelib/utils/archival.py b/buildscripts/resmokelib/utils/archival.py
index 8a73e812ecf..a56f1192135 100644
--- a/buildscripts/resmokelib/utils/archival.py
+++ b/buildscripts/resmokelib/utils/archival.py
@@ -123,7 +123,7 @@ class Archival(object): # pylint: disable=too-many-instance-attributes
@staticmethod
def _get_s3_client():
# Since boto3 is a 3rd party module, we import locally.
- import boto3
+ import boto3 # pylint: disable=import-outside-toplevel
return boto3.client("s3")
def archive_files_to_s3(self, display_name, input_files, s3_bucket, s3_path):
diff --git a/buildscripts/resmokelib/utils/jscomment.py b/buildscripts/resmokelib/utils/jscomment.py
index 8e0a1f39ce3..98d4652ee72 100644
--- a/buildscripts/resmokelib/utils/jscomment.py
+++ b/buildscripts/resmokelib/utils/jscomment.py
@@ -38,8 +38,8 @@ def get_tags(pathname):
raise TypeError("Expected a list of string tags, but got '%s'" % (tags))
return tags
except yaml.YAMLError as err:
- raise ValueError(
- "File '%s' contained invalid tags (expected YAML): %s" % (pathname, err))
+ raise ValueError("File '%s' contained invalid tags (expected YAML): %s" %
+ (pathname, err)) from err
return []
diff --git a/buildscripts/scons_cache_prune.py b/buildscripts/scons_cache_prune.py
index b63fd48ca30..bad9fbc650f 100644
--- a/buildscripts/scons_cache_prune.py
+++ b/buildscripts/scons_cache_prune.py
@@ -15,7 +15,7 @@ import argparse
import collections
import logging
import os
-import shutil
+import sys
LOGGER = logging.getLogger("scons.cache.prune.lru") # type: ignore
@@ -124,14 +124,14 @@ def main():
if args.cache_dir is None or not os.path.isdir(args.cache_dir):
LOGGER.error("must specify a valid cache path, [%s]", args.cache_dir)
- exit(1)
+ sys.exit(1)
ok = prune_cache(cache_path=args.cache_dir, cache_size_gb=args.cache_size,
clean_ratio=args.prune_ratio)
if not ok:
LOGGER.error("encountered error cleaning the cache. exiting.")
- exit(1)
+ sys.exit(1)
if __name__ == "__main__":
diff --git a/buildscripts/selected_tests.py b/buildscripts/selected_tests.py
index ff2179d7daa..dcdecccf531 100644
--- a/buildscripts/selected_tests.py
+++ b/buildscripts/selected_tests.py
@@ -9,11 +9,12 @@ from typing import Any, Dict, List, Set
import click
import structlog
from structlog.stdlib import LoggerFactory
-from evergreen.api import EvergreenApi, RetryingEvergreenApi
from git import Repo
from shrub.v2 import ShrubProject, BuildVariant
+from evergreen.api import EvergreenApi, RetryingEvergreenApi
+
# Get relative imports to work when the package is not installed on the PYTHONPATH.
from buildscripts.patch_builds.change_data import find_changed_files_in_repos, \
generate_revision_map_from_manifest
diff --git a/buildscripts/setup_multiversion_mongodb.py b/buildscripts/setup_multiversion_mongodb.py
index 853acb09ba5..74fe9ddf10b 100755
--- a/buildscripts/setup_multiversion_mongodb.py
+++ b/buildscripts/setup_multiversion_mongodb.py
@@ -93,7 +93,8 @@ def download_file(url, file_name, download_retries=5):
except requests.exceptions.ChunkedEncodingError as err:
download_retries -= 1
if download_retries == 0:
- raise Exception("Incomplete download for URL {}: {}".format(url, err))
+ raise Exception("Incomplete download for URL {}: {}".format(url,
+ err)) from err
continue
# Check if file download was completed.
@@ -350,7 +351,7 @@ class MultiVersionDownloader(object): # pylint: disable=too-many-instance-attri
# os.symlink is not supported on Windows, use a direct method instead.
def symlink_ms(source, link_name):
"""Provide symlink for Windows."""
- import ctypes
+ import ctypes # pylint: disable=import-outside-toplevel
csl = ctypes.windll.kernel32.CreateSymbolicLinkW
csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
csl.restype = ctypes.c_ubyte
diff --git a/buildscripts/tests/test_burn_in_tests.py b/buildscripts/tests/test_burn_in_tests.py
index 5fdf0475ebd..493da8d406e 100644
--- a/buildscripts/tests/test_burn_in_tests.py
+++ b/buildscripts/tests/test_burn_in_tests.py
@@ -179,7 +179,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)