SERVER-68593 Disable low value python warnings
This commit is contained in:
parent
d4d4a26801
commit
97ac02fa50
10
.pydocstyle
10
.pydocstyle
@ -2,6 +2,14 @@
|
||||
[pydocstyle]
|
||||
inherit = false
|
||||
|
||||
# D100 - Missing docstring in public module
|
||||
# D101 - Missing docstring in public class
|
||||
# D102 - Missing docstring in public method
|
||||
# D103 - Missing docstring in public function
|
||||
# D104 - Missing docstring in public package
|
||||
# D105 - Missing docstring in magic method
|
||||
# D106 - Missing docstring in public nested class
|
||||
# D107 - Missing docstring in __init__
|
||||
# D105 - Missing docstring in magic method
|
||||
# D107 - Missing docstring in __init__
|
||||
# D202 - No blank lines allowed after function docstring
|
||||
@ -13,6 +21,6 @@ inherit = false
|
||||
# D407 - Missing dashed underline after section
|
||||
# D413 - Missing blank line after last section
|
||||
# D415 - First line should end with a period, question mark, or exclamation point
|
||||
ignore = D105,D202,D203,D212,D213,D301,D401,D407,D413,D415
|
||||
ignore = D100,D101,D102,D103,D104,D105,D106,D107,D202,D203,D212,D213,D301,D401,D407,D413,D415
|
||||
# Do not run on buildscripts/tests/
|
||||
match = ^((?!buildscripts[\\\/]tests[\\\/]).)*$
|
||||
|
||||
@ -31,7 +31,8 @@ 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,raise-missing-from, unnecessary-comprehension,super-with-arguments,consider-using-sys-exit,import-outside-toplevel,no-else-continue,no-else-break,too-many-arguments,too-many-locals
|
||||
disable=bad-continuation,consider-using-sys-exit,deprecated-method,deprecated-module,duplicate-code,exec-used,fixme,import-error,import-outside-toplevel,line-too-long,locally-disabled,missing-class-docstring,missing-docstring,missing-docstring,missing-function-docstring,missing-module-docstring,no-else-break,no-else-continue,no-else-raise,no-else-return,no-member,no-name-in-module,no-self-use,raise-missing-from,redefined-variable-type,super-with-arguments,too-few-public-methods,too-many-arguments,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-lines,too-many-locals,too-many-public-methods,too-many-return-statements,too-many-statements,unnecessary-comprehension,unnecessary-pass,unused-import,useless-object-inheritance
|
||||
enable=useless-suppression
|
||||
|
||||
[IMPORTS]
|
||||
known-third-party=boto3,botocore,psutil,yaml,xmlrunner
|
||||
|
||||
@ -16,7 +16,7 @@ class _Result(Enum):
|
||||
|
||||
|
||||
@dataclass
|
||||
class _ResultTableRow: # pylint: disable=too-many-instance-attributes
|
||||
class _ResultTableRow:
|
||||
"""Representation of result table row."""
|
||||
|
||||
test_name: str
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Utility script to run Black Duck scans and query Black Duck database."""
|
||||
#pylint: disable=too-many-lines
|
||||
|
||||
import argparse
|
||||
import functools
|
||||
@ -19,13 +18,13 @@ from abc import ABCMeta, abstractmethod
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import urllib3.util.retry as urllib3_retry
|
||||
import requests
|
||||
import yaml
|
||||
|
||||
from blackduck.HubRestApi import HubInstance
|
||||
|
||||
import requests
|
||||
try:
|
||||
import requests.packages.urllib3.exceptions as urllib3_exceptions #pylint: disable=ungrouped-imports
|
||||
import requests.packages.urllib3.exceptions as urllib3_exceptions
|
||||
except ImportError:
|
||||
# Versions of the requests package prior to 1.2.0 did not vendor the urllib3 package.
|
||||
urllib3_exceptions = None
|
||||
@ -176,7 +175,6 @@ class HTTPHandler(object):
|
||||
|
||||
# Derived from buildscripts/resmokelib/logging/buildlogger.py
|
||||
class BuildloggerServer(object):
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
"""
|
||||
A remote server to which build logs can be sent.
|
||||
|
||||
@ -185,7 +183,6 @@ class BuildloggerServer(object):
|
||||
"""
|
||||
|
||||
def __init__(self, username, password, task_id, builder, build_num, build_phase, url):
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Initialize BuildloggerServer."""
|
||||
self.username = username
|
||||
self.password = password
|
||||
@ -245,7 +242,7 @@ class BuildloggerServer(object):
|
||||
raise ValueError("Encountered an HTTP error: %s" % (err))
|
||||
except requests.RequestException as err:
|
||||
raise ValueError("Encountered a network error: %s" % (err))
|
||||
except: # pylint: disable=bare-except
|
||||
except:
|
||||
raise ValueError("Encountered an error.")
|
||||
|
||||
return self.handler.make_url(endpoint)
|
||||
@ -451,7 +448,6 @@ class Component:
|
||||
|
||||
def __init__(self, name, version, licenses, policy_status, security_risk, newest_release,
|
||||
is_manually_added):
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Initialize Black Duck component."""
|
||||
self.name = name
|
||||
self.version = version
|
||||
@ -463,7 +459,6 @@ class Component:
|
||||
|
||||
@staticmethod
|
||||
def parse(hub, component):
|
||||
# pylint: disable=too-many-locals
|
||||
"""Parse a Black Duck component from a dictionary."""
|
||||
name = component["componentName"]
|
||||
cversion = component.get("componentVersionName", "unknown_version")
|
||||
@ -621,7 +616,6 @@ class TestResultEncoder(json.JSONEncoder):
|
||||
|
||||
def default(self, o):
|
||||
"""Serialize objects by default as a dictionary."""
|
||||
# pylint: disable=method-hidden
|
||||
return o.__dict__
|
||||
|
||||
|
||||
|
||||
@ -611,7 +611,6 @@ class BurnInOrchestrator:
|
||||
self.burn_in_executor.execute(tests_by_task)
|
||||
|
||||
|
||||
# pylint: disable=too-many-function-args
|
||||
@click.command(context_settings=dict(ignore_unknown_options=True))
|
||||
@click.option("--no-exec", "no_exec", default=False, is_flag=True,
|
||||
help="Do not execute the found tests.")
|
||||
@ -634,7 +633,6 @@ class BurnInOrchestrator:
|
||||
@click.option("--install-dir", "install_dir", type=str,
|
||||
help="Path to bin directory of a testable installation")
|
||||
@click.argument("resmoke_args", nargs=-1, type=click.UNPROCESSED)
|
||||
# pylint: disable=too-many-arguments,too-many-locals
|
||||
def main(build_variant: str, no_exec: bool, repeat_tests_num: Optional[int],
|
||||
repeat_tests_min: Optional[int], repeat_tests_max: Optional[int],
|
||||
repeat_tests_secs: Optional[int], resmoke_args: str, verbose: bool,
|
||||
|
||||
@ -6,7 +6,7 @@ configuration file.
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import distutils.spawn # pylint: disable=no-name-in-module
|
||||
import distutils.spawn
|
||||
from typing import Set, List, Optional
|
||||
|
||||
import yaml
|
||||
@ -39,7 +39,7 @@ def parse_evergreen_file(path, evergreen_binary="evergreen"):
|
||||
return EvergreenProjectConfig(config)
|
||||
|
||||
|
||||
class EvergreenProjectConfig(object): # pylint: disable=too-many-instance-attributes
|
||||
class EvergreenProjectConfig(object):
|
||||
"""Represent an Evergreen project configuration file."""
|
||||
|
||||
def __init__(self, conf):
|
||||
|
||||
@ -71,7 +71,6 @@ def callo(args, **kwargs):
|
||||
|
||||
def get_tar_path(version, tar_path):
|
||||
"""Return the path to clang-format in the llvm tarball."""
|
||||
# pylint: disable=too-many-function-args
|
||||
return CLANG_FORMAT_SOURCE_TAR_BASE.substitute(version=version, tar_path=tar_path)
|
||||
|
||||
|
||||
@ -136,7 +135,6 @@ class ClangFormat(object):
|
||||
"""ClangFormat class."""
|
||||
|
||||
def __init__(self, path, cache_dir):
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
"""Initialize ClangFormat."""
|
||||
self.path = None
|
||||
|
||||
@ -406,8 +404,7 @@ def format_my_func(clang_format, origin_branch):
|
||||
_format_files(clang_format, files)
|
||||
|
||||
|
||||
def reformat_branch( # pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||
clang_format, commit_prior_to_reformat, commit_after_reformat):
|
||||
def reformat_branch(clang_format, commit_prior_to_reformat, commit_after_reformat):
|
||||
"""Reformat a branch made before a clang-format run."""
|
||||
clang_format = ClangFormat(clang_format, _get_build_dir())
|
||||
|
||||
|
||||
@ -153,7 +153,6 @@ class DownloadOptions(object):
|
||||
class Mapper:
|
||||
"""A class to to basically all of the work."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
# This amount of attributes are necessary.
|
||||
|
||||
default_web_service_base_url: str = "https://symbolizer-service.server-tig.prod.corp.mongodb.com"
|
||||
|
||||
@ -25,9 +25,7 @@ except ImportError:
|
||||
|
||||
MAXIMUM_CODE = 9999999 # JIRA Ticket + XX
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
codes = [] # type: ignore
|
||||
# pylint: enable=invalid-name
|
||||
|
||||
# Each AssertLocation identifies the C++ source location of an assertion
|
||||
AssertLocation = namedtuple("AssertLocation", ['sourceFile', 'byteOffset', 'lines', 'code'])
|
||||
@ -237,7 +235,7 @@ def read_error_codes(src_root='src/mongo'):
|
||||
return (codes, errors, seen)
|
||||
|
||||
|
||||
def replace_bad_codes(errors, next_code_generator): # pylint: disable=too-many-locals
|
||||
def replace_bad_codes(errors, next_code_generator):
|
||||
"""
|
||||
Modify C++ source files to replace invalid assertion codes.
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from distutils import spawn # pylint: disable=no-name-in-module
|
||||
from distutils import spawn
|
||||
from optparse import OptionParser
|
||||
import structlog
|
||||
|
||||
@ -93,7 +93,6 @@ def get_eslint_from_cache(dest_file, platform, arch):
|
||||
print("Downloading ESLint %s from %s, saving to %s" % (ESLINT_VERSION, url, temp_tar_file))
|
||||
urllib.request.urlretrieve(url, temp_tar_file)
|
||||
|
||||
# pylint: disable=too-many-function-args
|
||||
print("Extracting ESLint %s to %s" % (ESLINT_VERSION, dest_file))
|
||||
eslint_distfile = ESLINT_SOURCE_TAR_BASE.substitute(platform=platform, arch=arch)
|
||||
extract_eslint(temp_tar_file, eslint_distfile)
|
||||
@ -103,7 +102,7 @@ def get_eslint_from_cache(dest_file, platform, arch):
|
||||
class ESLint(object):
|
||||
"""Class encapsulates finding a suitable copy of ESLint, and linting an individual file."""
|
||||
|
||||
def __init__(self, path, cache_dir): # pylint: disable=too-many-branches
|
||||
def __init__(self, path, cache_dir):
|
||||
"""Initialize ESLint."""
|
||||
eslint_progname = ESLINT_PROGNAME
|
||||
|
||||
|
||||
@ -162,6 +162,9 @@ def output_timeout(exec_timeout: timedelta, idle_timeout: Optional[timedelta],
|
||||
:param idle_timeout: Idle timeout to output.
|
||||
:param output_file: Location of output file to write.
|
||||
"""
|
||||
# the math library is triggering this error in this function for some
|
||||
# reason
|
||||
# pylint: disable=c-extension-no-member
|
||||
output = {
|
||||
"exec_timeout_secs": math.ceil(exec_timeout.total_seconds()),
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ class DumpGlobalServiceContext(gdb.Command):
|
||||
"""Initialize DumpGlobalServiceContext."""
|
||||
RegisterMongoCommand.register(self, "mongodb-service-context", gdb.COMMAND_DATA)
|
||||
|
||||
def invoke(self, arg, _from_tty): # pylint: disable=no-self-use,unused-argument
|
||||
def invoke(self, arg, _from_tty): # pylint: disable=unused-argument
|
||||
"""Invoke GDB command to print the Global Service Context."""
|
||||
gdb.execute("print *('mongo::(anonymous namespace)::globalServiceContext')")
|
||||
|
||||
@ -255,7 +255,7 @@ class GetMongoDecoration(gdb.Command):
|
||||
"""Initialize GetMongoDecoration."""
|
||||
RegisterMongoCommand.register(self, "mongo-decoration", gdb.COMMAND_DATA)
|
||||
|
||||
def invoke(self, args, _from_tty): # pylint: disable=unused-argument,no-self-use
|
||||
def invoke(self, args, _from_tty): # pylint: disable=unused-argument
|
||||
"""Invoke GetMongoDecoration."""
|
||||
argarr = args.split(" ")
|
||||
if len(argarr) < 2:
|
||||
@ -293,7 +293,7 @@ class DumpMongoDSessionCatalog(gdb.Command):
|
||||
"""Initialize DumpMongoDSessionCatalog."""
|
||||
RegisterMongoCommand.register(self, "mongod-dump-sessions", gdb.COMMAND_DATA)
|
||||
|
||||
def invoke(self, args, _from_tty): # pylint: disable=unused-argument,no-self-use,too-many-locals,too-many-branches,too-many-statements
|
||||
def invoke(self, args, _from_tty): # pylint: disable=unused-argument
|
||||
"""Invoke DumpMongoDSessionCatalog."""
|
||||
# See if a particular session id was specified.
|
||||
argarr = args.split(" ")
|
||||
@ -425,7 +425,7 @@ class DumpMongoDBMutexes(gdb.Command):
|
||||
"""Initialize DumpMongoDBMutexs."""
|
||||
RegisterMongoCommand.register(self, "mongodb-dump-mutexes", gdb.COMMAND_DATA)
|
||||
|
||||
def invoke(self, args, _from_tty): # pylint: disable=unused-argument,no-self-use,too-many-locals,too-many-branches,too-many-statements
|
||||
def invoke(self, args, _from_tty): # pylint: disable=unused-argument
|
||||
"""Invoke DumpMongoDBMutexes."""
|
||||
|
||||
print("Dumping mutex info for all Clients")
|
||||
@ -520,7 +520,7 @@ class MongoDBDumpRecoveryUnits(gdb.Command):
|
||||
print("Not invoking mongod recovery unit dump for: %s" % (main_binary_name))
|
||||
|
||||
@staticmethod
|
||||
def dump_recovery_units(recovery_unit_impl_type): # pylint: disable=too-many-locals
|
||||
def dump_recovery_units(recovery_unit_impl_type):
|
||||
"""GDB in-process python supplement."""
|
||||
|
||||
# Temporarily disable printing static members to make the output more readable
|
||||
@ -653,7 +653,7 @@ class BtIfActive(gdb.Command):
|
||||
"""Initialize BtIfActive."""
|
||||
RegisterMongoCommand.register(self, "mongodb-bt-if-active", gdb.COMMAND_DATA)
|
||||
|
||||
def invoke(self, arg, _from_tty): # pylint: disable=no-self-use,unused-argument
|
||||
def invoke(self, arg, _from_tty): # pylint: disable=unused-argument
|
||||
"""Invoke GDB to print stack trace."""
|
||||
try:
|
||||
idle_location = gdb.parse_and_eval("mongo::for_debuggers::idleThreadLocation")
|
||||
@ -862,7 +862,7 @@ class MongoDBPPrintBsonAtPointer(gdb.Command):
|
||||
"""Init."""
|
||||
RegisterMongoCommand.register(self, "mongodb-pprint-bson", gdb.COMMAND_STATUS)
|
||||
|
||||
def invoke(self, args, _from_tty): # pylint: disable=no-self-use
|
||||
def invoke(self, args, _from_tty):
|
||||
"""Invoke."""
|
||||
args = args.split(' ')
|
||||
if len(args) == 0 or (len(args) == 1 and len(args[0]) == 0):
|
||||
@ -892,7 +892,7 @@ class MongoDBHelp(gdb.Command):
|
||||
"""Initialize MongoDBHelp."""
|
||||
gdb.Command.__init__(self, "mongodb-help", gdb.COMMAND_SUPPORT)
|
||||
|
||||
def invoke(self, arg, _from_tty): # pylint: disable=no-self-use,unused-argument
|
||||
def invoke(self, arg, _from_tty): # pylint: disable=unused-argument
|
||||
"""Register the mongo print commands."""
|
||||
RegisterMongoCommand.print_commands()
|
||||
|
||||
|
||||
@ -307,7 +307,7 @@ def find_mutex_holder(graph, thread_dict, show):
|
||||
graph.add_edge(Lock(int(mutex_value), "Mutex"), mutex_holder)
|
||||
|
||||
|
||||
def find_lock_manager_holders(graph, thread_dict, show): # pylint: disable=too-many-locals
|
||||
def find_lock_manager_holders(graph, thread_dict, show):
|
||||
"""Find lock manager holders."""
|
||||
frame = find_frame(r'mongo::LockerImpl::')
|
||||
if not frame:
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
"""Utility functions for udb."""
|
||||
|
||||
# pylint: disable=unused-argument,missing-docstring,no-self-use
|
||||
import os
|
||||
import re
|
||||
from typing import Optional
|
||||
@ -176,7 +175,6 @@ class LoadDistTest(gdb.Command):
|
||||
|
||||
return None
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-locals
|
||||
def invoke(self, args, from_tty):
|
||||
"""GDB Command API invoke."""
|
||||
arglist = args.split()
|
||||
|
||||
@ -42,7 +42,8 @@ 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,wrong-import-order
|
||||
# pylint: disable=wrong-import-position
|
||||
from idl import syntax
|
||||
from buildscripts.idl.lib import list_idls, parse_idl
|
||||
from buildscripts.resmokelib import configure_resmoke
|
||||
from buildscripts.resmokelib.logging import loggers
|
||||
@ -50,7 +51,7 @@ from buildscripts.resmokelib.testing.fixtures import interface
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib
|
||||
from buildscripts.resmokelib.testing.fixtures.shardedcluster import ShardedClusterFixture
|
||||
from buildscripts.resmokelib.testing.fixtures.standalone import MongoDFixture
|
||||
from idl import syntax
|
||||
# pylint: enable=wrong-import-position
|
||||
|
||||
LOGGER_NAME = 'check-idl-definitions'
|
||||
LOGGER = logging.getLogger(LOGGER_NAME)
|
||||
|
||||
@ -54,8 +54,6 @@ class IDLBoundSpec(object):
|
||||
class IDLAST(object):
|
||||
"""The in-memory representation of an IDL file."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
"""Construct an IDLAST."""
|
||||
@ -94,8 +92,6 @@ class Type(common.SourceLocation):
|
||||
The type of a struct field or command field, for the sake of C++ code generation.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Type."""
|
||||
@ -128,8 +124,6 @@ class Struct(common.SourceLocation):
|
||||
represent that struct type using ast.Type with is_struct=True.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a struct."""
|
||||
@ -170,8 +164,6 @@ class Validator(common.SourceLocation):
|
||||
If more than one is included, they must ALL evaluate to true.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Validator."""
|
||||
@ -194,8 +186,6 @@ class Field(common.SourceLocation):
|
||||
Not all fields are set, it depends on the input document.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Field."""
|
||||
@ -261,8 +251,6 @@ class Command(Struct):
|
||||
All fields are either required or have a non-None default.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a command."""
|
||||
@ -402,8 +390,6 @@ class ServerParameterClass(common.SourceLocation):
|
||||
class ServerParameter(common.SourceLocation):
|
||||
"""IDL ServerParameter setting."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a ServerParameter."""
|
||||
@ -457,8 +443,6 @@ class ConfigGlobal(common.SourceLocation):
|
||||
class ConfigOption(common.SourceLocation):
|
||||
"""IDL ConfigOption setting."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a ConfigOption."""
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
# exception statement from all source files in the program, then also delete
|
||||
# it in the license file.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""Transform idl.syntax trees from the parser into well-defined idl.ast trees."""
|
||||
|
||||
import collections
|
||||
@ -177,7 +176,6 @@ def _validate_chain_type_properties(ctxt, idl_type, syntax_type):
|
||||
|
||||
def _validate_type_properties(ctxt, idl_type, syntax_type):
|
||||
# type: (errors.ParserContext, Union[syntax.Type, ast.Type], str) -> None
|
||||
# pylint: disable=too-many-branches
|
||||
"""Validate each type is correct."""
|
||||
# Validate bson type restrictions
|
||||
if not _validate_bson_types_list(ctxt, idl_type, syntax_type):
|
||||
@ -258,7 +256,6 @@ def _get_struct_qualified_cpp_name(struct):
|
||||
|
||||
def _bind_struct_common(ctxt, parsed_spec, struct, ast_struct):
|
||||
# type: (errors.ParserContext, syntax.IDLSpec, syntax.Struct, ast.Struct) -> None
|
||||
# pylint: disable=too-many-branches
|
||||
|
||||
ast_struct.name = struct.name
|
||||
ast_struct.description = struct.description
|
||||
@ -488,7 +485,6 @@ def _bind_variant_field(ctxt, ast_field, idl_type):
|
||||
def _bind_command_type(ctxt, parsed_spec, command):
|
||||
# type: (errors.ParserContext, syntax.IDLSpec, syntax.Command) -> ast.Field
|
||||
"""Bind the type field in a command as the first field."""
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
ast_field = ast.Field(command.file_name, command.line, command.column)
|
||||
ast_field.name = command.name
|
||||
ast_field.description = command.description
|
||||
@ -681,7 +677,6 @@ def _validate_check_uniqueness(ctxt, access_checks):
|
||||
def _bind_access_check(ctxt, parsed_spec, command):
|
||||
# type: (errors.ParserContext, syntax.IDLSpec, syntax.Command) -> Optional[List[ast.AccessCheck]]
|
||||
"""Bind the access_check field in a command."""
|
||||
# pylint: disable=too-many-return-statements
|
||||
|
||||
if not command.access_check:
|
||||
return None
|
||||
@ -770,7 +765,6 @@ def _validate_default_of_type_struct(ctxt, field):
|
||||
|
||||
def _validate_variant_type(ctxt, syntax_symbol, field):
|
||||
# type: (errors.ParserContext, syntax.VariantType, syntax.Field) -> None
|
||||
# pylint: disable=unused-argument
|
||||
"""Validate that this field is a proper variant type."""
|
||||
|
||||
# Check for duplicate BSON serialization types.
|
||||
@ -995,7 +989,6 @@ def _bind_field(ctxt, parsed_spec, field):
|
||||
- Create the idl.ast version from the idl.syntax tree.
|
||||
- Validate the resulting type is correct.
|
||||
"""
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
ast_field = ast.Field(field.file_name, field.line, field.column)
|
||||
ast_field.name = field.name
|
||||
ast_field.description = field.description
|
||||
@ -1467,7 +1460,6 @@ def _bind_config_option(ctxt, globals_spec, option):
|
||||
# type: (errors.ParserContext, syntax.Global, syntax.ConfigOption) -> ast.ConfigOption
|
||||
"""Bind a config setting."""
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-statements,too-many-return-statements
|
||||
node = ast.ConfigOption(option.file_name, option.line, option.column)
|
||||
|
||||
if _is_invalid_config_short_name(option.short_name or ''):
|
||||
|
||||
@ -84,7 +84,6 @@ def template_format(template, template_params=None):
|
||||
# str.
|
||||
# See https://docs.python.org/2/library/string.html#template-strings
|
||||
template = _escape_template_string(template)
|
||||
# pylint: disable=too-many-function-args
|
||||
return string.Template(template).substitute(template_params) # type: ignore
|
||||
|
||||
|
||||
@ -95,7 +94,6 @@ def template_args(template, **kwargs):
|
||||
# str.
|
||||
# See https://docs.python.org/2/library/string.html#template-strings
|
||||
template = _escape_template_string(template)
|
||||
# pylint: disable=too-many-function-args
|
||||
return string.Template(template).substitute(kwargs) # type: ignore
|
||||
|
||||
|
||||
|
||||
@ -47,8 +47,6 @@ from . import syntax
|
||||
class CompilerArgs(object):
|
||||
"""Set of compiler arguments."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
"""Create a container for compiler arguments."""
|
||||
|
||||
@ -652,7 +652,6 @@ class _BinDataBsonCppTypeBase(BsonCppTypeBase):
|
||||
def get_bson_cpp_type(ast_type):
|
||||
# type: (ast.Type) -> Optional[BsonCppTypeBase]
|
||||
"""Get a class that provides custom serialization for the given BSON type."""
|
||||
# pylint: disable=too-many-return-statements
|
||||
|
||||
# Does not support list of types
|
||||
if len(ast_type.bson_serialization_type) > 1:
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
# exception statement from all source files in the program, then also delete
|
||||
# it in the license file.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""
|
||||
Common error handling code for IDL compiler.
|
||||
|
||||
@ -153,7 +152,6 @@ class ParserError(common.SourceLocation):
|
||||
def __init__(self, error_id, msg, file_name, line, column):
|
||||
# type: (str, str, str, int, int) -> None
|
||||
"""Construct a parser error with source location information."""
|
||||
# pylint: disable=too-many-arguments
|
||||
self.error_id = error_id
|
||||
self.msg = msg
|
||||
super(ParserError, self).__init__(file_name, line, column)
|
||||
@ -227,8 +225,6 @@ class ParserContext(object):
|
||||
- single class responsible for producing actual error messages.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
|
||||
def __init__(self, file_name, errors):
|
||||
# type: (str, ParserErrorCollection) -> None
|
||||
"""Construct a new ParserContext."""
|
||||
@ -321,7 +317,6 @@ class ParserContext(object):
|
||||
|
||||
def is_scalar_sequence_or_scalar_node(self, node, node_name):
|
||||
# type: (Union[yaml.nodes.MappingNode, yaml.nodes.ScalarNode, yaml.nodes.SequenceNode], str) -> bool
|
||||
# pylint: disable=invalid-name
|
||||
"""Return True if the YAML node is a Scalar or Sequence."""
|
||||
if not node.id == "scalar" and not node.id == "sequence":
|
||||
self._add_node_error(
|
||||
@ -337,7 +332,6 @@ class ParserContext(object):
|
||||
|
||||
def is_scalar_or_mapping_node(self, node, node_name):
|
||||
# type: (Union[yaml.nodes.MappingNode, yaml.nodes.ScalarNode, yaml.nodes.SequenceNode], str) -> bool
|
||||
# pylint: disable=invalid-name
|
||||
"""Return True if the YAML node is a Scalar or Mapping."""
|
||||
if not node.id == "scalar" and not node.id == "mapping":
|
||||
self._add_node_error(
|
||||
@ -389,7 +383,6 @@ class ParserContext(object):
|
||||
def add_missing_required_field_error(self, node, node_parent, node_name):
|
||||
# type: (yaml.nodes.Node, str, str) -> None
|
||||
"""Add an error about a YAML node missing a required child."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_node_error(
|
||||
node, ERROR_ID_MISSING_REQUIRED_FIELD,
|
||||
"IDL node '%s' is missing required scalar '%s'" % (node_parent, node_name))
|
||||
@ -397,7 +390,6 @@ class ParserContext(object):
|
||||
def add_missing_ast_required_field_error(self, location, ast_type, ast_parent, ast_name):
|
||||
# type: (common.SourceLocation, str, str, str) -> None
|
||||
"""Add an error about a AST node missing a required child."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_MISSING_AST_REQUIRED_FIELD,
|
||||
"%s '%s' is missing required scalar '%s'" % (ast_type, ast_parent, ast_name))
|
||||
@ -426,7 +418,6 @@ class ParserContext(object):
|
||||
def add_bad_bson_bindata_subtype_error(self, location, ast_type, ast_parent, bson_type_name):
|
||||
# type: (common.SourceLocation, str, str, str) -> None
|
||||
"""Add an error about a bindata_subtype associated with a type that is not bindata."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_BAD_BSON_BINDATA_SUBTYPE_TYPE,
|
||||
("The bindata_subtype field for %s '%s' is not valid for bson type '%s'") %
|
||||
(ast_type, ast_parent, bson_type_name))
|
||||
@ -434,7 +425,6 @@ class ParserContext(object):
|
||||
def add_bad_bson_bindata_subtype_value_error(self, location, ast_type, ast_parent, value):
|
||||
# type: (common.SourceLocation, str, str, str) -> None
|
||||
"""Add an error about a bad value for bindata_subtype."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_BAD_BSON_BINDATA_SUBTYPE_VALUE,
|
||||
("The bindata_subtype field's value '%s' for %s '%s' is not valid") %
|
||||
(value, ast_type, ast_parent))
|
||||
@ -442,7 +432,6 @@ class ParserContext(object):
|
||||
def add_bad_setat_specifier(self, location, specifier):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about a bad set_at specifier."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_BAD_SETAT_SPECIFIER,
|
||||
("Unexpected set_at specifier: '%s', expected 'startup' or 'runtime'") % (specifier))
|
||||
@ -457,7 +446,6 @@ class ParserContext(object):
|
||||
def add_ignored_field_must_be_empty_error(self, location, name, field_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about field must be empty for ignored fields."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_FIELD_MUST_BE_EMPTY_FOR_IGNORED,
|
||||
("Field '%s' cannot contain a value for property '%s' when a field is marked as ignored"
|
||||
@ -466,15 +454,13 @@ class ParserContext(object):
|
||||
def add_struct_default_must_be_true_or_empty_error(self, location, name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about default must be True or empty for fields of type struct."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_DEFAULT_MUST_BE_TRUE_OR_EMPTY_FOR_STRUCT, (
|
||||
"Field '%s' can only contain value 'true' for property 'default' when a field's type is a struct"
|
||||
) % (name))
|
||||
|
||||
def add_not_custom_scalar_serialization_not_supported_error(self, location, ast_type,
|
||||
ast_parent, bson_type_name):
|
||||
def add_not_custom_scalar_serialization_not_supported_error( # pylint: disable=invalid-name
|
||||
self, location, ast_type, ast_parent, bson_type_name):
|
||||
# type: (common.SourceLocation, str, str, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about field must be empty for fields of type struct."""
|
||||
self._add_error(
|
||||
location, ERROR_ID_CUSTOM_SCALAR_SERIALIZATION_NOT_SUPPORTED,
|
||||
@ -484,7 +470,6 @@ class ParserContext(object):
|
||||
|
||||
def add_bad_any_type_use_error(self, location, bson_type, ast_type, ast_parent):
|
||||
# type: (common.SourceLocation, str, str, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about any being used in a list of bson types."""
|
||||
self._add_error(
|
||||
location, ERROR_ID_BAD_ANY_TYPE_USE,
|
||||
@ -493,7 +478,6 @@ class ParserContext(object):
|
||||
|
||||
def add_bad_cpp_numeric_type_use_error(self, location, ast_type, ast_parent, cpp_type):
|
||||
# type: (common.SourceLocation, str, str, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about any being used in a list of bson types."""
|
||||
self._add_error(
|
||||
location, ERROR_ID_BAD_NUMERIC_CPP_TYPE,
|
||||
@ -524,21 +508,18 @@ class ParserContext(object):
|
||||
|
||||
def add_bindata_no_default(self, location, ast_type, ast_parent):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about a bindata type with a default value."""
|
||||
self._add_error(location, ERROR_ID_BAD_BINDATA_DEFAULT,
|
||||
("Default values are not allowed for %s '%s'") % (ast_type, ast_parent))
|
||||
|
||||
def add_chained_type_not_found_error(self, location, type_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about a chained_type not found."""
|
||||
self._add_error(location, ERROR_ID_CHAINED_TYPE_NOT_FOUND,
|
||||
("Type '%s' is not a valid chained type") % (type_name))
|
||||
|
||||
def add_chained_type_wrong_type_error(self, location, type_name, bson_type_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about a chained_type being the wrong type."""
|
||||
self._add_error(location, ERROR_ID_CHAINED_TYPE_WRONG_BSON_TYPE,
|
||||
("Chained Type '%s' has the wrong bson serialization type '%s', only" +
|
||||
@ -554,7 +535,6 @@ class ParserContext(object):
|
||||
|
||||
def add_chained_type_no_strict_error(self, location, struct_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about strict parser validate and chained types."""
|
||||
self._add_error(location, ERROR_ID_CHAINED_NO_TYPE_STRICT,
|
||||
("Strict IDL parser validation is not supported with chained types for " +
|
||||
@ -562,14 +542,12 @@ class ParserContext(object):
|
||||
|
||||
def add_chained_struct_not_found_error(self, location, struct_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about a chained_struct not found."""
|
||||
self._add_error(location, ERROR_ID_CHAINED_STRUCT_NOT_FOUND,
|
||||
("Type '%s' is not a valid chained struct") % (struct_name))
|
||||
|
||||
def add_chained_nested_struct_no_strict_error(self, location, struct_name, nested_struct_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about strict parser validate and chained types."""
|
||||
self._add_error(location, ERROR_ID_CHAINED_NO_NESTED_STRUCT_STRICT,
|
||||
("Strict IDL parser validation is not supported for a chained struct '%s'" +
|
||||
@ -578,7 +556,6 @@ class ParserContext(object):
|
||||
|
||||
def add_chained_nested_struct_no_nested_error(self, location, struct_name, chained_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about struct's chaining being a struct with nested chaining."""
|
||||
self._add_error(location, ERROR_ID_CHAINED_NO_NESTED_CHAINED,
|
||||
("Struct '%s' is not allowed to nest struct '%s' since it has chained" +
|
||||
@ -620,7 +597,6 @@ class ParserContext(object):
|
||||
def add_enum_non_continuous_range_error(self, location, enum_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error for an enum having duplicate values."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_ENUM_NON_CONTINUOUS_RANGE,
|
||||
("Enum '%s' has non-continuous integer variables, enums must have a " +
|
||||
"continuous range of integer variables.") % (enum_name))
|
||||
@ -650,7 +626,6 @@ class ParserContext(object):
|
||||
def add_bad_field_default_and_optional(self, location, field_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about a field being optional and having a default value."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_ILLEGAL_FIELD_DEFAULT_AND_OPTIONAL,
|
||||
("Field '%s' can only be marked as optional or have a default value," + " not both.") %
|
||||
@ -659,7 +634,6 @@ class ParserContext(object):
|
||||
def add_bad_struct_field_as_doc_sequence_error(self, location, struct_name, field_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about using a field in a struct being marked with supports_doc_sequence."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_STRUCT_NO_DOC_SEQUENCE,
|
||||
("Field '%s' in struct '%s' cannot be used as a Command Document Sequence"
|
||||
" type. They are only supported in commands.") % (field_name, struct_name))
|
||||
@ -667,7 +641,6 @@ class ParserContext(object):
|
||||
def add_bad_non_array_as_doc_sequence_error(self, location, struct_name, field_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about using a non-array type field being marked with supports_doc_sequence."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_NO_DOC_SEQUENCE_FOR_NON_ARRAY,
|
||||
("Field '%s' in command '%s' cannot be used as a Command Document Sequence"
|
||||
" type since it is not an array.") % (field_name, struct_name))
|
||||
@ -675,7 +648,6 @@ class ParserContext(object):
|
||||
def add_bad_non_object_as_doc_sequence_error(self, location, field_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about using a non-struct or BSON object for a doc sequence."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_NO_DOC_SEQUENCE_FOR_NON_OBJECT,
|
||||
("Field '%s' cannot be used as a Command Document Sequence"
|
||||
" type since it is not a BSON object or struct.") % (field_name))
|
||||
@ -683,15 +655,13 @@ class ParserContext(object):
|
||||
def add_bad_command_name_duplicates_field(self, location, command_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about a command and field having the same name."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_COMMAND_DUPLICATES_FIELD,
|
||||
("Command '%s' cannot have the same name as a field.") % (command_name))
|
||||
|
||||
def add_bad_field_non_const_getter_in_immutable_struct_error(self, location, struct_name,
|
||||
field_name):
|
||||
def add_bad_field_non_const_getter_in_immutable_struct_error( # pylint: disable=invalid-name
|
||||
self, location, struct_name, field_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about marking a field with non_const_getter in an immutable struct."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_NON_CONST_GETTER_IN_IMMUTABLE_STRUCT,
|
||||
("Cannot generate a non-const getter for field '%s' in struct '%s' since"
|
||||
@ -765,7 +735,6 @@ class ParserContext(object):
|
||||
def add_duplicate_comparison_order_field_error(self, location, struct_name, comparison_order):
|
||||
# type: (common.SourceLocation, str, int) -> None
|
||||
"""Add an error about fields having duplicate comparison_orders."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_IS_DUPLICATE_COMPARISON_ORDER,
|
||||
("Struct '%s' cannot have two fields with the same comparison_order value '%d'.") %
|
||||
@ -774,7 +743,6 @@ class ParserContext(object):
|
||||
def add_extranous_command_type(self, location, command_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about commands having type when not needed."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_IS_COMMAND_TYPE_EXTRANEOUS,
|
||||
("Command '%s' cannot have a 'type' property unless namespace equals 'type'.") %
|
||||
@ -783,7 +751,6 @@ class ParserContext(object):
|
||||
def add_value_not_numeric_error(self, location, attrname, value):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about non-numeric value where number expected."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_VALUE_NOT_NUMERIC,
|
||||
("'%s' requires a numeric value, but %s can not be cast") % (attrname, value))
|
||||
@ -791,7 +758,6 @@ class ParserContext(object):
|
||||
def add_server_parameter_invalid_attr(self, location, attrname, conflicts):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about invalid fields in a server parameter definition."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_SERVER_PARAMETER_INVALID_ATTR,
|
||||
("'%s' attribute not permitted with '%s' server parameter") % (attrname, conflicts))
|
||||
@ -799,7 +765,6 @@ class ParserContext(object):
|
||||
def add_server_parameter_required_attr(self, location, attrname, required, dependant=None):
|
||||
# type: (common.SourceLocation, str, str, str) -> None
|
||||
"""Add an error about missing fields in a server parameter definition."""
|
||||
# pylint: disable=invalid-name
|
||||
qualifier = '' if dependant is None else (" when using '%s' attribute" % (dependant))
|
||||
self._add_error(location, ERROR_ID_SERVER_PARAMETER_REQUIRED_ATTR,
|
||||
("'%s' attribute required%s with '%s' server parameter") %
|
||||
@ -808,70 +773,60 @@ class ParserContext(object):
|
||||
def add_server_parameter_invalid_method_override(self, location, method):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about invalid method override in SCP method override."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_SERVER_PARAMETER_INVALID_METHOD_OVERRIDE,
|
||||
("No such method to override in server parameter class: '%s'") % (method))
|
||||
|
||||
def add_bad_source_specifier(self, location, value):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about invalid source specifier."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_BAD_SOURCE_SPECIFIER,
|
||||
("'%s' is not a valid source specifier") % (value))
|
||||
|
||||
def add_bad_duplicate_behavior(self, location, value):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about invalid duplicate behavior specifier."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_BAD_DUPLICATE_BEHAVIOR_SPECIFIER,
|
||||
("'%s' is not a valid duplicate behavior specifier") % (value))
|
||||
|
||||
def add_bad_numeric_range(self, location, attrname, value):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about invalid range specifier."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_BAD_NUMERIC_RANGE,
|
||||
("'%s' is not a valid numeric range for '%s'") % (value, attrname))
|
||||
|
||||
def add_missing_shortname_for_positional_arg(self, location):
|
||||
# type: (common.SourceLocation) -> None
|
||||
"""Add an error about required short_name for positional args."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_MISSING_SHORTNAME_FOR_POSITIONAL,
|
||||
"Missing 'short_name' for positional arg")
|
||||
|
||||
def add_invalid_short_name(self, location, name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about invalid short names."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_INVALID_SHORT_NAME,
|
||||
("Invalid 'short_name' value '%s'") % (name))
|
||||
|
||||
def add_invalid_single_name(self, location, name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about invalid single names."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_INVALID_SINGLE_NAME,
|
||||
("Invalid 'single_name' value '%s'") % (name))
|
||||
|
||||
def add_missing_short_name_with_single_name(self, location, name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about missing required short name when using single name."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_MISSING_SHORT_NAME_WITH_SINGLE_NAME,
|
||||
("Missing 'short_name' required with 'single_name' value '%s'") % (name))
|
||||
|
||||
def add_feature_flag_default_true_missing_version(self, location):
|
||||
# type: (common.SourceLocation) -> None
|
||||
"""Add an error about a default flag with a default value of true but no version."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_FEATURE_FLAG_DEFAULT_TRUE_MISSING_VERSION,
|
||||
("Missing 'version' required for feature flag that defaults to true"))
|
||||
|
||||
def add_feature_flag_default_false_has_version(self, location):
|
||||
# type: (common.SourceLocation) -> None
|
||||
"""Add an error about a default flag with a default value of false but has a version."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_FEATURE_FLAG_DEFAULT_FALSE_HAS_VERSION,
|
||||
("The 'version' attribute is not allowed for feature flag that defaults to false"))
|
||||
@ -879,7 +834,6 @@ class ParserContext(object):
|
||||
def add_reply_type_invalid_type(self, location, command_name, reply_type_name):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about a command whose reply_type refers to an unknown type."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_INVALID_REPLY_TYPE,
|
||||
("Command '%s' has invalid reply_type '%s'" % (command_name, reply_type_name)))
|
||||
@ -887,7 +841,6 @@ class ParserContext(object):
|
||||
def add_stability_no_api_version(self, location, command_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about a command with 'stability' but no 'api_version'."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_STABILITY_NO_API_VERSION,
|
||||
("Command '%s' specifies 'stability' but has no 'api_version'" % (command_name, )))
|
||||
@ -895,7 +848,6 @@ class ParserContext(object):
|
||||
def add_missing_reply_type(self, location, command_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about a command with 'api_version' but no 'reply_type'."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_MISSING_REPLY_TYPE,
|
||||
("Command '%s' has an 'api_version' but no 'reply_type'" % (command_name, )))
|
||||
@ -903,7 +855,6 @@ class ParserContext(object):
|
||||
def add_bad_field_always_serialize_not_optional(self, location, field_name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about a field with 'always_serialize' but 'optional' isn't set to true."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_ILLEGAL_FIELD_ALWAYS_SERIALIZE_NOT_OPTIONAL,
|
||||
("Field '%s' specifies 'always_serialize' but 'optional' isn't true.") % (field_name))
|
||||
@ -911,21 +862,18 @@ class ParserContext(object):
|
||||
def add_duplicate_command_name_and_alias(self, node):
|
||||
# type: (yaml.nodes.Node) -> None
|
||||
"""Add an error about a command name and command alias having the same name."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_node_error(node, ERROR_ID_COMMAND_DUPLICATES_NAME_AND_ALIAS,
|
||||
"Duplicate command_name and command_alias found.")
|
||||
|
||||
def add_unknown_enum_value(self, location, enum_name, enum_value):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about an unknown enum value."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_UNKOWN_ENUM_VALUE,
|
||||
"Cannot find enum value '%s' in enum '%s'." % (enum_value, enum_name))
|
||||
|
||||
def add_either_check_or_privilege(self, location):
|
||||
# type: (common.SourceLocation) -> None
|
||||
"""Add an error about specifing both a check and a privilege or neither."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_EITHER_CHECK_OR_PRIVILEGE,
|
||||
"Must specify either a 'check' and a 'privilege' in an access_check, not both.")
|
||||
@ -933,21 +881,18 @@ class ParserContext(object):
|
||||
def add_duplicate_action_types(self, location, name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about specifying an action type twice in the same list."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_DUPLICATE_ACTION_TYPE,
|
||||
"Cannot specify an action_type '%s' more then once" % (name))
|
||||
|
||||
def add_duplicate_access_check(self, location, name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about specifying an access check twice in the same list."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_DUPLICATE_ACCESS_CHECK,
|
||||
"Cannot specify an access_check '%s' more then once" % (name))
|
||||
|
||||
def add_duplicate_privilege(self, location, resource_pattern, action_type):
|
||||
# type: (common.SourceLocation, str, str) -> None
|
||||
"""Add an error about specifying a privilege twice in the same list."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_DUPLICATE_PRIVILEGE,
|
||||
"Cannot specify the pair of resource_pattern '%s' and action_type '%s' more then once" %
|
||||
@ -956,7 +901,6 @@ class ParserContext(object):
|
||||
def add_empty_access_check(self, location):
|
||||
# type: (common.SourceLocation) -> None
|
||||
"""Add an error about specifying one of ignore, none, simple or complex in an access check."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_EMPTY_ACCESS_CHECK,
|
||||
"Must one and only one of either a 'ignore', 'none', 'simple', or 'complex' in an access_check."
|
||||
@ -965,14 +909,12 @@ class ParserContext(object):
|
||||
def add_missing_access_check(self, location, name):
|
||||
# type: (common.SourceLocation, str) -> None
|
||||
"""Add an error about a missing access_check when api_version != ""."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_MISSING_ACCESS_CHECK,
|
||||
'Command "%s" has api_version != "" but is missing access_check.' % (name))
|
||||
|
||||
def add_stability_unknown_value(self, location):
|
||||
# type: (common.SourceLocation) -> None
|
||||
"""Add an error about a field with unknown value set to 'stability' option."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(
|
||||
location, ERROR_ID_STABILITY_UNKNOWN_VALUE,
|
||||
"Field option 'stability' has unknown value, should be one of 'stable', 'unstable' or 'internal.'"
|
||||
@ -981,7 +923,6 @@ class ParserContext(object):
|
||||
def add_duplicate_unstable_stability(self, location):
|
||||
# type: (common.SourceLocation) -> None
|
||||
"""Add an error about a field specifying both 'unstable' and 'stability'."""
|
||||
# pylint: disable=invalid-name
|
||||
self._add_error(location, ERROR_ID_DUPLICATE_UNSTABLE_STABILITY, (
|
||||
"Field specifies both 'unstable' and 'stability' options, should use 'stability: [stable|unstable|internal]' instead and remove the deprecated 'unstable' option."
|
||||
))
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
# exception statement from all source files in the program, then also delete
|
||||
# it in the license file.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""IDL C++ Code Generator."""
|
||||
|
||||
import hashlib
|
||||
@ -441,8 +440,6 @@ class _CppFileWriterBase(object):
|
||||
class _CppHeaderFileWriter(_CppFileWriterBase):
|
||||
"""C++ .h File writer."""
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
|
||||
def gen_class_declaration_block(self, class_name):
|
||||
# type: (str) -> writer.IndentedScopedBlock
|
||||
"""Generate a class declaration block."""
|
||||
@ -494,7 +491,6 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
|
||||
|
||||
def gen_protected_serializer_methods(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Generate protected serializer method declarations."""
|
||||
struct_type_info = struct_types.get_struct_info(struct)
|
||||
|
||||
@ -628,7 +624,6 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
|
||||
|
||||
def gen_string_constants_declarations(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Generate a StringData constant for field name."""
|
||||
|
||||
for field in _get_all_fields(struct):
|
||||
@ -740,7 +735,6 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
|
||||
def gen_comparison_operators_declarations(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
"""Generate comparison operators declarations for the type."""
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
with self._block("auto _relopTuple() const {", "}"):
|
||||
sorted_fields = sorted([
|
||||
@ -979,7 +973,6 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
|
||||
def generate(self, spec):
|
||||
# type: (ast.IDLAST) -> None
|
||||
"""Generate the C++ header to a stream."""
|
||||
# pylint: disable=too-many-branches,too-many-statements,too-many-locals,too-many-return-statements
|
||||
self.gen_file_header()
|
||||
|
||||
self._writer.write_unindented_line('#pragma once')
|
||||
@ -1174,7 +1167,6 @@ class _CppHeaderFileWriter(_CppFileWriterBase):
|
||||
|
||||
|
||||
class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
# pylint: disable=too-many-public-methods
|
||||
"""C++ .cpp File writer."""
|
||||
|
||||
_EMPTY_TENANT = "boost::optional<mongo::TenantId>{}"
|
||||
@ -1187,7 +1179,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
|
||||
def _gen_field_deserializer_expression(self, element_name, field, ast_type, tenant):
|
||||
# type: (str, ast.Field, ast.Type, str) -> str
|
||||
# pylint: disable=invalid-name,too-many-return-statements
|
||||
"""
|
||||
Generate the C++ deserializer piece for a field.
|
||||
|
||||
@ -1305,7 +1296,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
|
||||
def _gen_variant_deserializer(self, field, bson_element, tenant):
|
||||
# type: (ast.Field, str, str) -> None
|
||||
# pylint: disable=too-many-statements
|
||||
"""Generate the C++ deserializer piece for a variant field."""
|
||||
self._writer.write_empty_line()
|
||||
self._writer.write_line('const BSONType variantType = %s.type();' % (bson_element, ))
|
||||
@ -1403,7 +1393,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
If field_type is scalar and check_type is True (the default), generate type-checking code.
|
||||
Array elements are always type-checked.
|
||||
"""
|
||||
# pylint: disable=too-many-arguments
|
||||
if field_type.is_array:
|
||||
predicate = "MONGO_likely(ctxt.checkAndAssertType(%s, Array))" % (bson_element)
|
||||
with self._predicate(predicate):
|
||||
@ -1510,7 +1499,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
def gen_op_msg_request_namespace_check(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
"""Generate a namespace check for a command."""
|
||||
# pylint: disable=invalid-name
|
||||
if not isinstance(struct, ast.Command):
|
||||
return
|
||||
|
||||
@ -1526,7 +1514,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
def _gen_constructor(self, struct, constructor, default_init):
|
||||
# type: (ast.Struct, struct_types.MethodInfo, bool) -> None
|
||||
"""Generate the C++ constructor definition."""
|
||||
# pylint: disable=too-many-branches
|
||||
|
||||
initializers = ['_%s(std::move(%s))' % (arg.name, arg.name) for arg in constructor.args]
|
||||
|
||||
@ -1625,7 +1612,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
def _gen_fields_deserializer_common(self, struct, bson_object, tenant=_EMPTY_TENANT):
|
||||
# type: (ast.Struct, str, str) -> _FieldUsageCheckerBase
|
||||
"""Generate the C++ code to deserialize list of fields."""
|
||||
# pylint: disable=too-many-branches
|
||||
field_usage_check = _get_field_usage_checker(self._writer, struct)
|
||||
if isinstance(struct, ast.Command):
|
||||
self._writer.write_line('BSONElement commandElement;')
|
||||
@ -1713,7 +1699,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
def get_bson_deserializer_static_common(self, struct, static_method_info, method_info):
|
||||
# type: (ast.Struct, struct_types.MethodInfo, struct_types.MethodInfo) -> None
|
||||
"""Generate the C++ deserializer static method."""
|
||||
# pylint: disable=invalid-name
|
||||
func_def = static_method_info.get_definition()
|
||||
|
||||
with self._block('%s {' % (func_def), '}'):
|
||||
@ -1834,7 +1819,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
def gen_op_msg_request_deserializer_methods(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
"""Generate the C++ deserializer method definitions from OpMsgRequest."""
|
||||
# pylint: disable=invalid-name
|
||||
# Commands that have concatentate_with_db namespaces require db name as a parameter
|
||||
# 'Empty' structs (those with no fields) don't need to be deserialized
|
||||
if not isinstance(struct, ast.Command):
|
||||
@ -2032,7 +2016,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
|
||||
def _gen_serializer_method_common(self, field):
|
||||
# type: (ast.Field) -> None
|
||||
# pylint: disable=too-many-locals
|
||||
"""Generate the serialize method definition."""
|
||||
member_name = _get_field_member_name(field)
|
||||
|
||||
@ -2189,7 +2172,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
def gen_op_msg_request_serializer_method(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
"""Generate the serialzer method definition for OpMsgRequest."""
|
||||
# pylint: disable=invalid-name
|
||||
if not isinstance(struct, ast.Command):
|
||||
return
|
||||
|
||||
@ -2214,7 +2196,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
|
||||
def gen_string_constants_definitions(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Generate a StringData constant for field name in the cpp file."""
|
||||
|
||||
for field in _get_all_fields(struct):
|
||||
@ -2236,7 +2217,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
|
||||
def gen_authorization_contract_definition(self, struct):
|
||||
# type: (ast.Struct) -> None
|
||||
# pylint: disable=invalid-name
|
||||
"""Generate the authorization contract defintion."""
|
||||
|
||||
if not isinstance(struct, ast.Command):
|
||||
@ -2575,8 +2555,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
# type: (ast.IDLAST, str) -> None
|
||||
"""Generate Config Option instances."""
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
|
||||
has_storage_targets = False
|
||||
for opt in spec.configs:
|
||||
if opt.cpp_varname is not None:
|
||||
@ -2645,8 +2623,6 @@ class _CppSourceFileWriter(_CppFileWriterBase):
|
||||
# type: (ast.IDLAST, str) -> None
|
||||
"""Generate the C++ source to a stream."""
|
||||
|
||||
# pylint: disable=too-many-statements
|
||||
|
||||
self.gen_file_header()
|
||||
|
||||
# Include platform/basic.h
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
# exception statement from all source files in the program, then also delete
|
||||
# it in the license file.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""
|
||||
IDL Parser.
|
||||
|
||||
@ -91,7 +90,6 @@ def _generic_parser(
|
||||
syntax_node, # type: Any
|
||||
mapping_rules # type: Dict[str, _RuleDesc]
|
||||
): # type: (...) -> None
|
||||
# pylint: disable=too-many-branches
|
||||
field_name_set = set() # type: Set[str]
|
||||
|
||||
for [first_node, second_node] in node.value:
|
||||
@ -810,8 +808,6 @@ def _parse_command(ctxt, spec, name, node):
|
||||
# type: (errors.ParserContext, syntax.IDLSpec, str, Union[yaml.nodes.MappingNode, yaml.nodes.ScalarNode, yaml.nodes.SequenceNode]) -> None
|
||||
"""Parse a command section in the IDL file."""
|
||||
|
||||
# pylint: disable=too-many-branches
|
||||
|
||||
if not ctxt.is_mapping_node(node, "command"):
|
||||
return
|
||||
|
||||
@ -1034,7 +1030,6 @@ def _parse(stream, error_file_name):
|
||||
stream: is a io.Stream.
|
||||
error_file_name: just a file name for error messages to use.
|
||||
"""
|
||||
# pylint: disable=too-many-branches
|
||||
|
||||
# This will raise an exception if the YAML parse fails
|
||||
root_node = yaml.compose(stream)
|
||||
@ -1128,7 +1123,6 @@ def parse(stream, input_file_name, resolver):
|
||||
stream: is a io.Stream.
|
||||
input_file_name: a file name for error messages to use, and to help resolve imported files.
|
||||
"""
|
||||
# pylint: disable=too-many-locals
|
||||
|
||||
root_doc = _parse(stream, input_file_name)
|
||||
|
||||
|
||||
@ -83,7 +83,6 @@ class MethodInfo(object):
|
||||
def __init__(self, class_name, method_name, args, return_type=None, static=False, const=False,
|
||||
explicit=False):
|
||||
# type: (str, str, List[str], str, bool, bool, bool) -> None
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Create a MethodInfo instance."""
|
||||
self.class_name = class_name
|
||||
self.method_name = method_name
|
||||
@ -193,21 +192,18 @@ class StructTypeInfoBase(object, metaclass=ABCMeta):
|
||||
def get_op_msg_request_serializer_method(self):
|
||||
# type: () -> Optional[MethodInfo]
|
||||
"""Get the OpMsg serializer method for a struct."""
|
||||
# pylint: disable=invalid-name
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_op_msg_request_deserializer_static_method(self):
|
||||
# type: () -> Optional[MethodInfo]
|
||||
"""Get the public static OpMsg deserializer method for a struct."""
|
||||
# pylint: disable=invalid-name
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_op_msg_request_deserializer_method(self):
|
||||
# type: () -> Optional[MethodInfo]
|
||||
"""Get the protected OpMsg deserializer method for a struct."""
|
||||
# pylint: disable=invalid-name
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@ -234,7 +234,6 @@ class SymbolTable(object):
|
||||
def resolve_field_type(self, ctxt, location, field_name, field_type):
|
||||
# type: (errors.ParserContext, common.SourceLocation, str, FieldType) -> Optional[Union[Enum, Struct, Type]]
|
||||
"""Find the type or struct a field refers to or log an error."""
|
||||
# pylint: disable=too-many-return-statements,too-many-branches,too-many-locals
|
||||
|
||||
if isinstance(field_type, FieldTypeVariant):
|
||||
variant = VariantType(field_type.file_name, field_type.line, field_type.column)
|
||||
@ -358,8 +357,6 @@ class Type(common.SourceLocation):
|
||||
populated.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Type."""
|
||||
@ -413,8 +410,6 @@ class Validator(common.SourceLocation):
|
||||
If more than one is included, they must ALL evaluate to true.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Validator."""
|
||||
@ -449,8 +444,6 @@ class Field(common.SourceLocation):
|
||||
populated.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Field."""
|
||||
@ -515,8 +508,6 @@ class Struct(common.SourceLocation):
|
||||
All fields are either required or have a non-None default.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Struct."""
|
||||
@ -634,8 +625,6 @@ class Command(Struct):
|
||||
Namespace is required.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a Command."""
|
||||
@ -846,8 +835,6 @@ class ServerParameterClass(common.SourceLocation):
|
||||
class ServerParameter(common.SourceLocation):
|
||||
"""IDL ServerParameter information."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a ServerParameter."""
|
||||
@ -873,8 +860,6 @@ class ServerParameter(common.SourceLocation):
|
||||
class FeatureFlag(common.SourceLocation):
|
||||
"""IDL FeatureFlag information."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a FeatureFlag."""
|
||||
@ -917,8 +902,6 @@ class ConfigGlobal(common.SourceLocation):
|
||||
class ConfigOption(common.SourceLocation):
|
||||
"""Runtime configuration setting definition."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, file_name, line, column):
|
||||
# type: (str, int, int) -> None
|
||||
"""Construct a ConfigOption."""
|
||||
|
||||
@ -77,7 +77,6 @@ def get_method_name(name):
|
||||
|
||||
def get_method_name_from_qualified_method_name(name):
|
||||
# type: (str) -> str
|
||||
# pylint: disable=invalid-name
|
||||
"""Get a method name from a fully qualified method name."""
|
||||
# TODO: in the future, we may want to support full-qualified calls to static methods
|
||||
# Strip the global prefix from enum functions
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
# exception statement from all source files in the program, then also delete
|
||||
# it in the license file.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""Checks compatibility of old and new IDL files.
|
||||
|
||||
In order to support user-selectable API versions for the server, server commands are now
|
||||
@ -463,7 +462,6 @@ def get_field_type(field: Union[syntax.Field, syntax.Command], idl_file: syntax.
|
||||
def check_subset(ctxt: IDLCompatibilityContext, cmd_name: str, field_name: str, type_name: str,
|
||||
sub_list: List[Union[str, syntax.EnumValue]],
|
||||
super_list: List[Union[str, syntax.EnumValue]], file_path: str):
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Check if sub_list is a subset of the super_list and log an error if not."""
|
||||
if not set(sub_list).issubset(super_list):
|
||||
ctxt.add_reply_field_not_subset_error(cmd_name, field_name, type_name, file_path)
|
||||
@ -473,7 +471,6 @@ def check_superset(ctxt: IDLCompatibilityContext, cmd_name: str, type_name: str,
|
||||
super_list: List[Union[str, syntax.EnumValue]],
|
||||
sub_list: List[Union[str, syntax.EnumValue]], file_path: str,
|
||||
param_name: Optional[str], is_command_parameter: bool):
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Check if super_list is a superset of the sub_list and log an error if not."""
|
||||
if not set(super_list).issuperset(sub_list):
|
||||
ctxt.add_command_or_param_type_not_superset_error(cmd_name, type_name, file_path,
|
||||
@ -482,7 +479,6 @@ def check_superset(ctxt: IDLCompatibilityContext, cmd_name: str, type_name: str,
|
||||
|
||||
def check_reply_field_type_recursive(ctxt: IDLCompatibilityContext,
|
||||
field_pair: FieldCompatibilityPair) -> None:
|
||||
# pylint: disable=too-many-branches
|
||||
"""Check compatibility between old and new reply field type if old field type is a syntax.Type instance."""
|
||||
old_field = field_pair.old
|
||||
new_field = field_pair.new
|
||||
@ -598,7 +594,6 @@ def check_reply_field_type_recursive(ctxt: IDLCompatibilityContext,
|
||||
|
||||
def check_reply_field_type(ctxt: IDLCompatibilityContext, field_pair: FieldCompatibilityPair):
|
||||
"""Check compatibility between old and new reply field type."""
|
||||
# pylint: disable=too-many-branches
|
||||
old_field = field_pair.old
|
||||
new_field = field_pair.new
|
||||
cmd_name = field_pair.cmd_name
|
||||
@ -665,7 +660,6 @@ def check_array_type(ctxt: IDLCompatibilityContext, symbol: str,
|
||||
- ArrayTypeCheckResult.FALSE : when the old type and new type aren't of array type.
|
||||
- ArrayTypeCheckResult.INVALID : when one of the types is not of array type while the other one is.
|
||||
"""
|
||||
# pylint: disable=too-many-arguments,too-many-branches
|
||||
old_is_array = isinstance(old_type, syntax.ArrayType)
|
||||
new_is_array = isinstance(new_type, syntax.ArrayType)
|
||||
if not old_is_array and not new_is_array:
|
||||
@ -684,7 +678,6 @@ def check_reply_field(ctxt: IDLCompatibilityContext, old_field: syntax.Field,
|
||||
new_idl_file: syntax.IDLParsedSpec, old_idl_file_path: str,
|
||||
new_idl_file_path: str):
|
||||
"""Check compatibility between old and new reply field."""
|
||||
# pylint: disable=too-many-arguments
|
||||
old_field_type = get_field_type(old_field, old_idl_file, old_idl_file_path)
|
||||
new_field_type = get_field_type(new_field, new_idl_file, new_idl_file_path)
|
||||
old_field_optional = old_field.optional or (old_field_type
|
||||
@ -730,7 +723,6 @@ def check_reply_fields(ctxt: IDLCompatibilityContext, old_reply: syntax.Struct,
|
||||
new_idl_file: syntax.IDLParsedSpec, old_idl_file_path: str,
|
||||
new_idl_file_path: str):
|
||||
"""Check compatibility between old and new reply fields."""
|
||||
# pylint: disable=too-many-arguments,too-many-branches
|
||||
for new_chained_type in new_reply.chained_types or []:
|
||||
resolved_new_chained_type = get_chained_type_or_struct(new_chained_type, new_idl_file,
|
||||
new_idl_file_path)
|
||||
@ -805,7 +797,6 @@ def check_reply_fields(ctxt: IDLCompatibilityContext, old_reply: syntax.Struct,
|
||||
def check_param_or_command_type_recursive(ctxt: IDLCompatibilityContext,
|
||||
field_pair: FieldCompatibilityPair,
|
||||
is_command_parameter: bool):
|
||||
# pylint: disable=too-many-branches,too-many-locals
|
||||
"""
|
||||
Check compatibility between old and new command or param type recursively.
|
||||
|
||||
@ -936,7 +927,6 @@ def check_param_or_command_type_recursive(ctxt: IDLCompatibilityContext,
|
||||
def check_param_or_command_type(ctxt: IDLCompatibilityContext, field_pair: FieldCompatibilityPair,
|
||||
is_command_parameter: bool):
|
||||
"""Check compatibility between old and new command parameter type or command type."""
|
||||
# pylint: disable=too-many-branches
|
||||
old_field = field_pair.old
|
||||
new_field = field_pair.new
|
||||
field_name = field_pair.field_name
|
||||
@ -1004,7 +994,6 @@ def check_param_or_type_validator(ctxt: IDLCompatibilityContext, old_field: synt
|
||||
Check compatibility between old and new validators in command parameter type and command type
|
||||
struct fields.
|
||||
"""
|
||||
# pylint: disable=too-many-arguments
|
||||
if new_field.validator:
|
||||
if old_field.validator:
|
||||
if new_field.validator != old_field.validator:
|
||||
@ -1034,7 +1023,6 @@ def check_command_params_or_type_struct_fields(
|
||||
cmd_name: str, old_idl_file: syntax.IDLParsedSpec, new_idl_file: syntax.IDLParsedSpec,
|
||||
old_idl_file_path: str, new_idl_file_path: str, is_command_parameter: bool):
|
||||
"""Check compatibility between old and new parameters or command type fields."""
|
||||
# pylint: disable=too-many-arguments,too-many-branches
|
||||
# Check chained types.
|
||||
for old_chained_type in old_struct.chained_types or []:
|
||||
resolved_old_chained_type = get_chained_type_or_struct(old_chained_type, old_idl_file,
|
||||
@ -1137,7 +1125,6 @@ def check_command_param_or_type_struct_field(
|
||||
old_idl_file_path: str, new_idl_file_path: str, type_name: Optional[str],
|
||||
is_command_parameter: bool):
|
||||
"""Check compatibility between the old and new command parameter or command type struct field."""
|
||||
# pylint: disable=too-many-arguments
|
||||
ignore_list_name: str = cmd_name + "-param-" + new_field.name
|
||||
if not is_unstable(old_field.stability) and is_unstable(
|
||||
new_field.stability) and ignore_list_name not in IGNORE_STABLE_TO_UNSTABLE_LIST:
|
||||
@ -1188,7 +1175,6 @@ def check_namespace(ctxt: IDLCompatibilityContext, old_cmd: syntax.Command, new_
|
||||
old_idl_file: syntax.IDLParsedSpec, new_idl_file: syntax.IDLParsedSpec,
|
||||
old_idl_file_path: str, new_idl_file_path: str):
|
||||
"""Check compatibility between old and new namespace."""
|
||||
# pylint: disable=too-many-arguments
|
||||
old_namespace = old_cmd.namespace
|
||||
new_namespace = new_cmd.namespace
|
||||
|
||||
@ -1364,7 +1350,7 @@ def check_security_access_checks(ctxt: IDLCompatibilityContext,
|
||||
new_access_checks: syntax.AccessChecks, cmd: syntax.Command,
|
||||
new_idl_file_path: str) -> None:
|
||||
"""Check the compatibility between security access checks of the old and new command."""
|
||||
# pylint:disable=too-many-locals,too-many-branches,too-many-nested-blocks
|
||||
# pylint:disable=too-many-nested-blocks
|
||||
cmd_name = cmd.command_name
|
||||
if old_access_checks is not None and new_access_checks is not None:
|
||||
old_access_check_type = old_access_checks.get_access_check_type()
|
||||
@ -1405,7 +1391,6 @@ def check_security_access_checks(ctxt: IDLCompatibilityContext,
|
||||
def check_compatibility(old_idl_dir: str, new_idl_dir: str, old_import_directories: List[str],
|
||||
new_import_directories: List[str]) -> IDLCompatibilityErrorCollection:
|
||||
"""Check IDL compatibility between old and new IDL commands."""
|
||||
# pylint: disable=too-many-locals
|
||||
ctxt = IDLCompatibilityContext(old_idl_dir, new_idl_dir, IDLCompatibilityErrorCollection())
|
||||
|
||||
new_commands, new_command_file, new_command_file_path = get_new_commands(
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
# exception statement from all source files in the program, then also delete
|
||||
# it in the license file.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""
|
||||
Common error handling code for IDL compatibility checker.
|
||||
|
||||
@ -151,7 +150,6 @@ class IDLCompatibilityError(object):
|
||||
- file - a string, the path to the IDL file where the error occurred.
|
||||
"""
|
||||
|
||||
#pylint: disable=too-many-arguments
|
||||
def __init__(self, error_id: str, command_name: str, msg: str, old_idl_dir: str,
|
||||
new_idl_dir: str, file: str) -> None:
|
||||
"""Construct an IDLCompatibility error."""
|
||||
@ -182,7 +180,6 @@ class IDLCompatibilityErrorCollection(object):
|
||||
"""Initialize IDLCompatibilityErrorCollection."""
|
||||
self._errors: List[IDLCompatibilityError] = []
|
||||
|
||||
#pylint: disable=too-many-arguments
|
||||
def add(self, error_id: str, command_name: str, msg: str, old_idl_dir: str, new_idl_dir: str,
|
||||
file: str) -> None:
|
||||
"""Add an error message with directory information."""
|
||||
@ -254,8 +251,6 @@ class IDLCompatibilityContext(object):
|
||||
- single class responsible for producing actual error messages.
|
||||
"""
|
||||
|
||||
# pylint:disable=too-many-public-methods
|
||||
|
||||
def __init__(self, old_idl_dir: str, new_idl_dir: str,
|
||||
errors: IDLCompatibilityErrorCollection) -> None:
|
||||
"""Construct a new IDLCompatibilityContext."""
|
||||
@ -319,7 +314,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_command_or_param_type_not_superset_error(self, command_name: str, type_name: str,
|
||||
file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Add an error about the command or parameter type not being a superset."""
|
||||
if is_command_parameter:
|
||||
self._add_error(
|
||||
@ -339,7 +333,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_command_or_param_type_contains_validator_error(self, command_name: str, field_name: str,
|
||||
file: str, type_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about a type containing a validator.
|
||||
|
||||
@ -361,7 +354,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_command_or_param_type_validators_not_equal_error(
|
||||
self, command_name: str, field_name: str, file: str, type_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""Add an error about the new and old command or parameter type validators not being equal."""
|
||||
if is_command_parameter:
|
||||
self._add_error(
|
||||
@ -384,7 +377,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_type_bson_any_error(
|
||||
self, command_name: str, old_type: str, new_type: str, file: str,
|
||||
field_name: Optional[str], is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about BSON serialization type.
|
||||
|
||||
@ -410,7 +402,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_type_enum_or_struct_error(
|
||||
self, command_name: str, new_type: str, old_type: str, file: str,
|
||||
field_name: Optional[str], is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about a type that is an enum or struct.
|
||||
|
||||
@ -434,7 +425,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_param_or_command_type_field_added_required_error(
|
||||
self, command_name: str, field_name: str, file: str, type_name: str,
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""
|
||||
Add a new added required parameter or command type field error.
|
||||
|
||||
@ -458,7 +449,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_param_or_command_type_field_missing_error(self, command_name: str, field_name: str,
|
||||
file: str, type_name: str,
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Add an error about a parameter or command type field that is missing in the new command."""
|
||||
if is_command_parameter:
|
||||
self._add_error(
|
||||
@ -475,7 +465,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_param_or_command_type_field_required_error(self, command_name: str, field_name: str,
|
||||
file: str, type_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add a required parameter or command type field error.
|
||||
|
||||
@ -497,7 +486,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_param_or_command_type_field_stable_required_no_default_error(
|
||||
self, struct_name: str, field_name: str, file: str, type_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""
|
||||
Add a stable required parameter or command type field error.
|
||||
|
||||
@ -523,7 +512,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_param_or_command_type_field_unstable_error(self, command_name: str, field_name: str,
|
||||
file: str, type_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an unstable parameter or command type field error.
|
||||
|
||||
@ -545,7 +533,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_type_not_enum_error(
|
||||
self, command_name: str, new_type: str, old_type: str, file: str,
|
||||
field_name: Optional[str], is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an not enum parameter or command type field error.
|
||||
|
||||
@ -567,7 +554,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_type_not_struct_error(
|
||||
self, command_name: str, new_type: str, old_type: str, file: str,
|
||||
field_name: Optional[str], is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Add an error about the new command or parameter type not being a struct when the old one is."""
|
||||
if is_command_parameter:
|
||||
self._add_error(
|
||||
@ -586,7 +572,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_type_not_variant_type_error(self, command_name: str, new_type: str,
|
||||
file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""
|
||||
Add an error about the new command or parameter type not being a variant type.
|
||||
|
||||
@ -609,7 +595,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_variant_type_not_superset_error(
|
||||
self, command_name: str, variant_type_name: str, file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""
|
||||
Add an error about the new variant types not being a superset.
|
||||
|
||||
@ -635,7 +621,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_chained_type_not_superset_error(
|
||||
self, command_name: str, chained_type_name: str, file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""
|
||||
Add an error about the new chained types not being a superset.
|
||||
|
||||
@ -757,7 +743,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_reply_field_type_not_enum_error(self, command_name: str, field_name: str,
|
||||
new_field_type: str, old_field_type: str,
|
||||
file: str) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Add an error about the new reply field type not being an enum when the old one is."""
|
||||
self._add_error(ERROR_ID_NEW_REPLY_FIELD_TYPE_NOT_ENUM, command_name,
|
||||
("'%s' has a reply field or sub-field '%s' of type '%s' "
|
||||
@ -768,7 +753,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_reply_field_type_not_struct_error(self, command_name: str, field_name: str,
|
||||
new_field_type: str, old_field_type: str,
|
||||
file: str) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Add an error about the new reply field type not being a struct when the old one is."""
|
||||
self._add_error(ERROR_ID_NEW_REPLY_FIELD_TYPE_NOT_STRUCT, command_name,
|
||||
("'%s' has a reply field or sub-field '%s' of type '%s' "
|
||||
@ -779,7 +763,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_reply_field_type_enum_or_struct_error(self, command_name: str, field_name: str,
|
||||
new_field_type: str, old_field_type: str,
|
||||
file: str) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about a reply field type being incompatible with the old field type.
|
||||
|
||||
@ -803,7 +786,6 @@ class IDLCompatibilityContext(object):
|
||||
|
||||
def add_new_reply_field_variant_type_error(self, command_name: str, field_name: str,
|
||||
old_field_type: str, file: str) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Add an error about the new reply field type being variant when the old one is not."""
|
||||
self._add_error(ERROR_ID_NEW_REPLY_FIELD_VARIANT_TYPE, command_name,
|
||||
("'%s' has a reply field or sub-field '%s' that has a variant "
|
||||
@ -813,7 +795,6 @@ class IDLCompatibilityContext(object):
|
||||
|
||||
def add_new_reply_field_variant_type_not_subset_error(
|
||||
self, command_name: str, field_name: str, variant_type_name: str, file: str) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about the reply field variant types not being a subset.
|
||||
|
||||
@ -829,7 +810,6 @@ class IDLCompatibilityContext(object):
|
||||
|
||||
def add_new_reply_chained_type_not_subset_error(self, command_name: str, reply_name: str,
|
||||
chained_type_name: str, file: str) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about the reply chained types not being a subset.
|
||||
|
||||
@ -847,7 +827,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_old_command_or_param_type_bson_any_error(
|
||||
self, command_name: str, old_type: str, new_type: str, file: str,
|
||||
field_name: Optional[str], is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about BSON serialization type.
|
||||
|
||||
@ -872,7 +851,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_old_command_or_param_type_bson_any_not_allowed_error(
|
||||
self, command_name: str, type_name: str, file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""
|
||||
Add an error about the old command or param type bson serialization type being 'any'.
|
||||
|
||||
@ -896,7 +875,7 @@ class IDLCompatibilityContext(object):
|
||||
def add_new_command_or_param_type_bson_any_not_allowed_error(
|
||||
self, command_name: str, type_name: str, file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
"""
|
||||
Add an error about the new command or param type bson serialization type being 'any'.
|
||||
|
||||
@ -920,7 +899,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_command_or_param_cpp_type_not_equal_error(self, command_name: str, type_name: str,
|
||||
file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
"""Add an error about the old and new command or param cpp_type not being equal."""
|
||||
if is_command_parameter:
|
||||
self._add_error(ERROR_ID_COMMAND_PARAMETER_CPP_TYPE_NOT_EQUAL, command_name,
|
||||
@ -937,7 +915,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_command_or_param_serializer_not_equal_error(self, command_name: str, type_name: str,
|
||||
file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
"""Add an error about the old and new command or param serializer not being equal."""
|
||||
if is_command_parameter:
|
||||
self._add_error(ERROR_ID_COMMAND_PARAMETER_SERIALIZER_NOT_EQUAL, command_name,
|
||||
@ -954,7 +931,6 @@ class IDLCompatibilityContext(object):
|
||||
def add_command_or_param_deserializer_not_equal_error(self, command_name: str, type_name: str,
|
||||
file: str, field_name: Optional[str],
|
||||
is_command_parameter: bool) -> None:
|
||||
# pylint: disable=too-many-arguments,invalid-name
|
||||
"""Add an error about the old and new command or param deserializer not being equal."""
|
||||
if is_command_parameter:
|
||||
self._add_error(ERROR_ID_COMMAND_PARAMETER_DESERIALIZER_NOT_EQUAL, command_name,
|
||||
@ -1034,7 +1010,6 @@ class IDLCompatibilityContext(object):
|
||||
|
||||
def add_type_not_array_error(self, symbol: str, command_name: str, symbol_name: str,
|
||||
new_type: str, old_type: str, file: str) -> None:
|
||||
# pylint: disable=too-many-arguments
|
||||
"""
|
||||
Add an error about type not being an ArrayType when it should be.
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@
|
||||
# exception statement from all source files in the program, then also delete
|
||||
# it in the license file.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""Test cases for IDL binder."""
|
||||
|
||||
import textwrap
|
||||
@ -69,8 +68,6 @@ def indent_text(count, unindented_text):
|
||||
class TestBinder(testcase.IDLTestcase):
|
||||
"""Test cases for the IDL binder."""
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
|
||||
# Create a text wrap for common types.
|
||||
common_types = textwrap.dedent("""
|
||||
types:
|
||||
@ -1834,7 +1831,6 @@ class TestBinder(testcase.IDLTestcase):
|
||||
def test_command_doc_sequence_positive(self):
|
||||
# type: () -> None
|
||||
"""Positive supports_doc_sequence tests."""
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
# Setup some common types
|
||||
test_preamble = self.common_types + textwrap.dedent("""
|
||||
@ -1875,7 +1871,6 @@ class TestBinder(testcase.IDLTestcase):
|
||||
def test_command_doc_sequence_negative(self):
|
||||
# type: () -> None
|
||||
"""Negative supports_doc_sequence tests."""
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
# Setup some common types
|
||||
test_preamble = self.common_types
|
||||
|
||||
@ -34,7 +34,6 @@ import sys
|
||||
from os import path
|
||||
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
|
||||
|
||||
# pylint: disable=too-many-lines
|
||||
import idl_check_compatibility # noqa: E402 pylint: disable=wrong-import-position
|
||||
import idl_compatibility_errors # noqa: E402 pylint: disable=wrong-import-position
|
||||
|
||||
@ -140,7 +139,7 @@ class TestIDLCompatibilityChecker(unittest.TestCase):
|
||||
str(new_command_type_struct_bson_serialization_type_any_error),
|
||||
"newCommandTypeStructFieldBsonSerializationTypeAny")
|
||||
|
||||
# pylint: disable=too-many-locals,too-many-statements,invalid-name
|
||||
# pylint: disable=invalid-name
|
||||
def test_should_fail(self):
|
||||
"""Tests that incompatible old and new IDL commands should fail."""
|
||||
dir_path = path.dirname(path.realpath(__file__))
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
# it in the license file.
|
||||
#
|
||||
"""Test cases for IDL parser."""
|
||||
# pylint: disable=too-many-lines
|
||||
|
||||
import textwrap
|
||||
import unittest
|
||||
@ -46,7 +45,6 @@ else:
|
||||
|
||||
|
||||
class TestParser(testcase.IDLTestcase):
|
||||
# pylint: disable=too-many-public-methods
|
||||
"""Test the IDL parser only."""
|
||||
|
||||
def test_empty(self):
|
||||
@ -1386,7 +1384,6 @@ class TestParser(testcase.IDLTestcase):
|
||||
def test_command_doc_sequence_positive(self):
|
||||
# type: () -> None
|
||||
"""Positive supports_doc_sequence test cases."""
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
# supports_doc_sequence can be false
|
||||
self.assert_parse(
|
||||
@ -1421,7 +1418,6 @@ class TestParser(testcase.IDLTestcase):
|
||||
def test_command_doc_sequence_negative(self):
|
||||
# type: () -> None
|
||||
"""Negative supports_doc_sequence test cases."""
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
# supports_doc_sequence must be a bool
|
||||
self.assert_parse_fail(
|
||||
|
||||
@ -225,7 +225,6 @@ def load_graph_data(graph_file, output_format):
|
||||
|
||||
|
||||
def main():
|
||||
# pylint: disable=too-many-branches
|
||||
"""Perform graph analysis based on input args."""
|
||||
|
||||
args = setup_args_parser()
|
||||
|
||||
@ -49,7 +49,6 @@ import libdeps.analyzer
|
||||
class BackendServer:
|
||||
"""Create small class for storing variables and state of the backend."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, graphml_dir, frontend_url, memory_limit):
|
||||
"""Create and setup the state variables."""
|
||||
self.app = flask.Flask(__name__)
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# pylint: disable=too-many-lines
|
||||
"""
|
||||
Libdeps Graph Analysis Tool.
|
||||
|
||||
@ -116,7 +115,6 @@ def schema_check(func, schema_version):
|
||||
class Analyzer:
|
||||
"""Base class for different types of analyzers."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, dependency_graph, progress=True):
|
||||
"""Store the graph and extract the build_dir from the graph."""
|
||||
|
||||
@ -575,7 +573,6 @@ class Efficiency(Analyzer):
|
||||
@schema_check(schema_version=1)
|
||||
def run(self):
|
||||
"""Find efficiency of each public dependency originating from a node."""
|
||||
# pylint:disable=too-many-nested-blocks
|
||||
|
||||
efficiencies_data = {}
|
||||
|
||||
@ -912,7 +909,6 @@ class GaPrettyPrinter(GaPrinter):
|
||||
def _print_depends_reports(self, results):
|
||||
"""Print the depends reports result data."""
|
||||
|
||||
# pylint: disable=too-many-branches
|
||||
if DependsReportTypes.DIRECT_DEPENDS.name in results:
|
||||
print("\nNodes that directly depend on:")
|
||||
for node in results[DependsReportTypes.DIRECT_DEPENDS.name]:
|
||||
|
||||
@ -26,9 +26,8 @@ class LinterBase(object, metaclass=ABCMeta):
|
||||
"""Get the command to run a linter."""
|
||||
pass
|
||||
|
||||
def get_fix_cmd_args(self, file_name):
|
||||
def get_fix_cmd_args(self, _file_name):
|
||||
# type: (str) -> Optional[List[str]]
|
||||
# pylint: disable=no-self-use,unused-argument
|
||||
"""Get the command to run a linter fix."""
|
||||
return None
|
||||
|
||||
@ -40,7 +39,6 @@ class LinterBase(object, metaclass=ABCMeta):
|
||||
|
||||
def needs_file_diff(self):
|
||||
# type: () -> bool
|
||||
# pylint: disable=no-self-use
|
||||
"""
|
||||
Check if we need to diff the output of this linter with the original file.
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ class Repo(_git.Repository):
|
||||
|
||||
Returns the full path to the file for clang-format to consume.
|
||||
"""
|
||||
if candidates is not None and len(candidates) > 0: # pylint: disable=len-as-condition
|
||||
if candidates is not None and len(candidates) > 0:
|
||||
candidates = [self._get_local_dir(f) for f in candidates]
|
||||
valid_files = list(
|
||||
set(candidates).intersection(self.get_candidate_files(filter_function)))
|
||||
@ -122,7 +122,6 @@ class Repo(_git.Repository):
|
||||
|
||||
def get_working_tree_candidate_files(self, filter_function):
|
||||
# type: (Callable[[str], bool]) -> List[str]
|
||||
# pylint: disable=invalid-name
|
||||
"""Query git to get a list of all files in the working tree to consider for analysis."""
|
||||
return self._git_ls_files(["--cached", "--others"], filter_function)
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import subprocess
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Repository(object): # pylint: disable=too-many-public-methods
|
||||
class Repository(object):
|
||||
"""Represent a local git repository."""
|
||||
|
||||
def __init__(self, directory):
|
||||
@ -239,8 +239,8 @@ class GitException(Exception):
|
||||
|
||||
"""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, message, returncode=None, cmd=None, process_args=None, stdout=None, stderr=None):
|
||||
def __init__(self, message, returncode=None, cmd=None, process_args=None, stdout=None,
|
||||
stderr=None):
|
||||
"""Initialize GitException."""
|
||||
Exception.__init__(self, message)
|
||||
self.returncode = returncode
|
||||
@ -262,8 +262,7 @@ class GitCommandResult(object):
|
||||
|
||||
"""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, cmd, process_args, returncode, stdout=None, stderr=None):
|
||||
def __init__(self, cmd, process_args, returncode, stdout=None, stderr=None):
|
||||
"""Initialize GitCommandResult."""
|
||||
self.cmd = cmd
|
||||
self.process_args = process_args
|
||||
|
||||
@ -65,7 +65,6 @@ def _find_linter(linter, config_dict):
|
||||
Return a LinterInstance with the location of the linter binary if a linter binary with the
|
||||
matching version is found. None otherwise.
|
||||
"""
|
||||
# pylint: disable=too-many-branches,too-many-return-statements
|
||||
|
||||
if linter.cmd_name in config_dict and config_dict[linter.cmd_name] is not None:
|
||||
cmd = [config_dict[linter.cmd_name]]
|
||||
@ -172,7 +171,6 @@ class LintRunner(object):
|
||||
def run_lint(self, linter, file_name):
|
||||
# type: (base.LinterInstance, str) -> bool
|
||||
"""Run the specified linter for the file."""
|
||||
# pylint: disable=too-many-locals
|
||||
|
||||
linter_args = linter.linter.get_lint_cmd_args(file_name)
|
||||
if not linter_args:
|
||||
|
||||
@ -119,18 +119,18 @@ class UniquePtrPrinter:
|
||||
self.valobj = valobj
|
||||
self.update()
|
||||
|
||||
def num_children(self): # pylint: disable=no-self-use,no-method-argument
|
||||
def num_children(self):
|
||||
"""Match LLDB's expected API."""
|
||||
return 1
|
||||
|
||||
def get_child_index(self, name): # pylint: disable=no-self-use,no-method-argument
|
||||
def get_child_index(self, name):
|
||||
"""Match LLDB's expected API."""
|
||||
if name == "ptr":
|
||||
return 0
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_child_at_index(self, index): # pylint: disable=no-self-use,no-method-argument
|
||||
def get_child_at_index(self, index):
|
||||
"""Match LLDB's expected API.
|
||||
|
||||
Always prints object pointed at by the ptr.
|
||||
@ -141,11 +141,11 @@ class UniquePtrPrinter:
|
||||
else:
|
||||
return None
|
||||
|
||||
def has_children(): # pylint: disable=no-self-use,no-method-argument
|
||||
def has_children(self):
|
||||
"""Match LLDB's expected API."""
|
||||
return True
|
||||
|
||||
def update(self): # pylint: disable=no-self-use,no-method-argument
|
||||
def update(self):
|
||||
"""Match LLDB's expected API."""
|
||||
pass
|
||||
|
||||
@ -158,25 +158,25 @@ class OptionalPrinter:
|
||||
self.valobj = valobj
|
||||
self.update()
|
||||
|
||||
def num_children(self): # pylint: disable=no-self-use,no-method-argument
|
||||
def num_children(self):
|
||||
"""Match LLDB's expected API."""
|
||||
return 1
|
||||
|
||||
def get_child_index(self, name): # pylint: disable=no-self-use,no-method-argument
|
||||
def get_child_index(self, name):
|
||||
"""Match LLDB's expected API."""
|
||||
if name == "value":
|
||||
return 0
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_child_at_index(self, index): # pylint: disable=no-self-use,no-method-argument
|
||||
def get_child_at_index(self, index):
|
||||
"""Match LLDB's expected API."""
|
||||
if index == 0:
|
||||
return self.value
|
||||
else:
|
||||
return None
|
||||
|
||||
def has_children(): # pylint: disable=no-self-use,no-method-argument
|
||||
def has_children(self):
|
||||
"""Match LLDB's expected API."""
|
||||
return True
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ def _replace_vcxproj(file_name, restore_elements):
|
||||
file_handle.write(str_value)
|
||||
|
||||
|
||||
class ProjFileGenerator(object): # pylint: disable=too-many-instance-attributes
|
||||
class ProjFileGenerator(object):
|
||||
"""Generate a .vcxproj and .vcxprof.filters file."""
|
||||
|
||||
def __init__(self, target, vs_version):
|
||||
@ -274,7 +274,7 @@ class ProjFileGenerator(object): # pylint: disable=too-many-instance-attributes
|
||||
return True
|
||||
return False
|
||||
|
||||
def __write_filters(self): # pylint: disable=too-many-branches
|
||||
def __write_filters(self):
|
||||
"""Generate the vcxproj.filters file."""
|
||||
# 1. get a list of directories for all the files
|
||||
# 2. get all the C++ files in each of these dirs
|
||||
|
||||
@ -33,7 +33,6 @@ import os
|
||||
|
||||
|
||||
def discover_modules(module_root, allowed_modules):
|
||||
# pylint: disable=too-many-branches
|
||||
"""Scan module_root for subdirectories that look like MongoDB modules.
|
||||
|
||||
Return a list of imported build.py module objects.
|
||||
|
||||
@ -31,13 +31,12 @@ from typing import Dict, List, Any, Union, Optional
|
||||
|
||||
import requests
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
# pylint: disable=too-many-branches
|
||||
from tenacity import wait_fixed, stop_after_delay, retry_if_result, Retrying
|
||||
|
||||
sys.path.append(str(Path(os.getcwd(), __file__).parent.parent))
|
||||
from buildscripts.util.oauth import Configs, get_oauth_credentials, get_client_cred_oauth_credentials
|
||||
from buildscripts.build_system_options import PathOptions
|
||||
|
||||
from buildscripts.util.oauth import Configs, get_oauth_credentials, get_client_cred_oauth_credentials #pylint: disable=wrong-import-position
|
||||
from buildscripts.build_system_options import PathOptions #pylint: disable=wrong-import-position
|
||||
|
||||
SYMBOLIZER_PATH_ENV = "MONGOSYMB_SYMBOLIZER_PATH"
|
||||
# since older versions may have issues with symbolizing, we are setting the toolchain version to v4
|
||||
@ -180,7 +179,6 @@ class PathResolver(DbgFileResolver):
|
||||
Cache size differs according to the situation, system resources and overall decision of development team.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
# This amount of attributes are necessary.
|
||||
|
||||
# the main (API) sever that we'll be sending requests to
|
||||
|
||||
@ -192,7 +192,6 @@ class Distro(object):
|
||||
Power and x86 have different names for apt/yum (ppc64le/ppc64el
|
||||
and x86_64/amd64).
|
||||
"""
|
||||
# pylint: disable=too-many-return-statements
|
||||
if re.search("^(debian|ubuntu)", self.dname):
|
||||
if arch == "ppc64le":
|
||||
return "ppc64el"
|
||||
@ -217,7 +216,6 @@ class Distro(object):
|
||||
return "x86_64"
|
||||
else:
|
||||
raise Exception("BUG: unsupported platform?")
|
||||
# pylint: enable=too-many-return-statements
|
||||
|
||||
def repodir(self, arch, build_os, spec): # noqa: D406,D407,D412,D413
|
||||
"""Return the directory where we'll place the package files for (distro, distro_version).
|
||||
@ -276,13 +274,13 @@ class Distro(object):
|
||||
else:
|
||||
raise Exception("unsupported distro: %s" % self.dname)
|
||||
|
||||
def repo_os_version(self, build_os): # pylint: disable=too-many-branches
|
||||
def repo_os_version(self, build_os):
|
||||
"""Return an OS version suitable for package repo directory naming.
|
||||
|
||||
Example, 5, 6 or 7 for redhat/centos, "precise," "wheezy," etc.
|
||||
for Ubuntu/Debian, 11 for suse, "2013.03" for amazon.
|
||||
"""
|
||||
# pylint: disable=too-many-return-statements
|
||||
|
||||
if self.dname == 'suse':
|
||||
return re.sub(r'^suse(\d+)$', r'\1', build_os)
|
||||
if self.dname == 'redhat':
|
||||
@ -319,7 +317,6 @@ class Distro(object):
|
||||
raise Exception("unsupported build_os: %s" % build_os)
|
||||
else:
|
||||
raise Exception("unsupported distro: %s" % self.dname)
|
||||
# pylint: enable=too-many-return-statements
|
||||
|
||||
def make_pkg(self, build_os, arch, spec, srcdir):
|
||||
"""Return the package."""
|
||||
@ -668,7 +665,7 @@ Description: MongoDB packages
|
||||
os.chdir(oldpwd)
|
||||
|
||||
|
||||
def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
|
||||
def move_repos_into_place(src, dst):
|
||||
"""Move the repos into place."""
|
||||
# Find all the stuff in src/*, move it to a freshly-created
|
||||
# directory beside dst, then play some games with symlinks so that
|
||||
@ -758,7 +755,7 @@ def write_debian_changelog(path, spec, srcdir):
|
||||
fh.write(sb)
|
||||
|
||||
|
||||
def make_rpm(distro, build_os, arch, spec, srcdir): # pylint: disable=too-many-locals
|
||||
def make_rpm(distro, build_os, arch, spec, srcdir):
|
||||
"""Create the RPM specfile."""
|
||||
suffix = spec.suffix()
|
||||
sdir = setupdir(distro, build_os, arch, spec)
|
||||
|
||||
@ -116,13 +116,12 @@ class EnterpriseDistro(packager.Distro):
|
||||
else:
|
||||
raise Exception("BUG: unsupported platform?")
|
||||
|
||||
def build_os(self, arch): # pylint: disable=too-many-branches
|
||||
def build_os(self, arch):
|
||||
"""Return the build os label in the binary package to download.
|
||||
|
||||
The labels "rhel57", "rhel62", "rhel67", "rhel70", "rhel80" are for redhat,
|
||||
the others are delegated to the super class.
|
||||
"""
|
||||
# pylint: disable=too-many-return-statements
|
||||
if arch == "ppc64le":
|
||||
if self.dname == 'ubuntu':
|
||||
return ["ubuntu1604", "ubuntu1804"]
|
||||
@ -150,7 +149,6 @@ class EnterpriseDistro(packager.Distro):
|
||||
if re.search("(redhat|fedora|centos)", self.dname):
|
||||
return ["rhel80", "rhel70", "rhel62", "rhel57"]
|
||||
return super(EnterpriseDistro, self).build_os(arch)
|
||||
# pylint: enable=too-many-return-statements
|
||||
|
||||
|
||||
def main():
|
||||
@ -321,7 +319,7 @@ Description: MongoDB packages
|
||||
os.chdir(oldpwd)
|
||||
|
||||
|
||||
def move_repos_into_place(src, dst): # pylint: disable=too-many-branches
|
||||
def move_repos_into_place(src, dst):
|
||||
"""Move the repos into place."""
|
||||
# Find all the stuff in src/*, move it to a freshly-created
|
||||
# directory beside dst, then play some games with symlinks so that
|
||||
|
||||
@ -176,7 +176,7 @@ def _fix_files(linters, config_dict, file_names):
|
||||
|
||||
for linter in linter_instances:
|
||||
run_linter = lambda param1: lint_runner.run(linter.cmd_path + linter.linter. # pylint: disable=cell-var-from-loop
|
||||
get_fix_cmd_args(param1)) # pylint: disable=cell-var-from-loop
|
||||
get_fix_cmd_args(param1))
|
||||
|
||||
lint_clean = parallel.parallel_process([os.path.abspath(f) for f in file_names], run_linter)
|
||||
|
||||
|
||||
@ -63,7 +63,6 @@ def lint_all(file_names: List[str]) -> None:
|
||||
|
||||
|
||||
def lint_my(origin_branch: List[str]) -> None:
|
||||
# pylint: disable=unused-argument
|
||||
"""Lint files command based on local changes."""
|
||||
files = git.get_my_files_to_check(is_interesting_file, origin_branch)
|
||||
files = [f for f in files if os.path.exists(f)]
|
||||
|
||||
@ -97,7 +97,7 @@ def _validate_options(parser, args):
|
||||
parser.error(str(error_msgs))
|
||||
|
||||
|
||||
def _validate_config(parser): # pylint: disable=too-many-branches
|
||||
def _validate_config(parser):
|
||||
"""Do validation on the config settings."""
|
||||
|
||||
if _config.REPEAT_TESTS_MAX:
|
||||
@ -150,7 +150,7 @@ def _find_resmoke_wrappers():
|
||||
return list(candidate_installs)
|
||||
|
||||
|
||||
def _update_config_vars(values): # pylint: disable=too-many-statements,too-many-locals,too-many-branches
|
||||
def _update_config_vars(values):
|
||||
"""Update the variables of the config module."""
|
||||
|
||||
config = _config.DEFAULTS.copy()
|
||||
|
||||
@ -13,7 +13,7 @@ from typing import List
|
||||
MAX_LOG_LINE = int(3.5 * 1024 * 1024)
|
||||
|
||||
|
||||
class LoggerPipe(threading.Thread): # pylint: disable=too-many-instance-attributes
|
||||
class LoggerPipe(threading.Thread):
|
||||
"""Asynchronously reads the output of a subprocess and sends it to a logger."""
|
||||
|
||||
# The start() and join() methods are not intended to be called directly on the LoggerPipe
|
||||
|
||||
@ -76,8 +76,6 @@ class Process(object):
|
||||
"""Wrapper around subprocess.Popen class."""
|
||||
|
||||
# pylint: disable=protected-access
|
||||
# pylint: disable=too-many-arguments
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, logger, args, env=None, env_vars=None, cwd=None):
|
||||
"""Initialize the process with the specified logger, arguments, and environment."""
|
||||
@ -175,7 +173,7 @@ class Process(object):
|
||||
if return_code == win32con.STILL_ACTIVE:
|
||||
raise
|
||||
|
||||
def stop(self, mode=None): # pylint: disable=too-many-branches
|
||||
def stop(self, mode=None):
|
||||
"""Terminate the process."""
|
||||
if mode is None:
|
||||
mode = fixture_interface.TeardownMode.TERMINATE
|
||||
|
||||
@ -76,7 +76,7 @@ def mongod_program(logger, job_num, executable, process_kwargs, mongod_options):
|
||||
return make_process(logger, args, **process_kwargs), mongod_options["port"]
|
||||
|
||||
|
||||
def mongos_program(logger, job_num, executable=None, process_kwargs=None, mongos_options=None): # pylint: disable=too-many-arguments
|
||||
def mongos_program(logger, job_num, executable=None, process_kwargs=None, mongos_options=None):
|
||||
"""Return a Process instance that starts a mongos with arguments constructed from 'kwargs'."""
|
||||
args = [executable]
|
||||
|
||||
@ -97,9 +97,8 @@ def mongos_program(logger, job_num, executable=None, process_kwargs=None, mongos
|
||||
return make_process(logger, args, **process_kwargs), mongos_options["port"]
|
||||
|
||||
|
||||
def mongo_shell_program( # pylint: disable=too-many-arguments,too-many-branches,too-many-locals,too-many-statements
|
||||
logger, executable=None, connection_string=None, filename=None, test_filename=None,
|
||||
process_kwargs=None, **kwargs):
|
||||
def mongo_shell_program(logger, executable=None, connection_string=None, filename=None,
|
||||
test_filename=None, process_kwargs=None, **kwargs):
|
||||
"""Return a Process instance that starts a mongo shell.
|
||||
|
||||
The shell is started with the given connection string and arguments constructed from 'kwargs'.
|
||||
|
||||
@ -28,7 +28,7 @@ class GenerateFCVConstants(Subcommand):
|
||||
# This will cause multiversion constants to be generated.
|
||||
self._setup_logging()
|
||||
|
||||
import buildscripts.resmokelib.multiversionconstants # pylint: disable=unused-import
|
||||
import buildscripts.resmokelib.multiversionconstants
|
||||
buildscripts.resmokelib.multiversionconstants.log_constants(self._exec_logger)
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import sys
|
||||
import tempfile
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from collections import namedtuple
|
||||
from distutils import spawn # pylint: disable=no-name-in-module
|
||||
from distutils import spawn
|
||||
|
||||
from buildscripts.resmokelib.hang_analyzer.process import call, callo, find_program
|
||||
from buildscripts.resmokelib.hang_analyzer.process_list import Pinfo
|
||||
@ -52,7 +52,7 @@ class Dumper(metaclass=ABCMeta):
|
||||
self._dbg_output = dbg_output
|
||||
|
||||
@abstractmethod
|
||||
def dump_info( # pylint: disable=too-many-arguments,too-many-locals
|
||||
def dump_info(
|
||||
self,
|
||||
pinfo: Pinfo,
|
||||
take_dump: bool,
|
||||
@ -174,8 +174,7 @@ class WindowsDumper(Dumper):
|
||||
|
||||
return cmds
|
||||
|
||||
def dump_info( # pylint: disable=too-many-arguments
|
||||
self, pinfo, take_dump):
|
||||
def dump_info(self, pinfo, take_dump):
|
||||
"""Dump useful information to the console."""
|
||||
debugger = "cdb.exe"
|
||||
dbg = self._find_debugger(debugger)
|
||||
@ -358,8 +357,7 @@ class GDBDumper(Dumper):
|
||||
]
|
||||
return cmds
|
||||
|
||||
def _process_specific( # pylint: disable=too-many-locals
|
||||
self, pinfo, take_dump, logger=None):
|
||||
def _process_specific(self, pinfo, take_dump, logger=None):
|
||||
"""Return the commands that attach to each process, dump info and detach."""
|
||||
cmds = []
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ from buildscripts.resmokelib.symbolizer import Symbolizer
|
||||
class HangAnalyzer(Subcommand):
|
||||
"""Main class for the hang analyzer subcommand."""
|
||||
|
||||
def __init__(self, options, task_id=None, logger=None, **_kwargs): # pylint: disable=unused-argument
|
||||
def __init__(self, options, task_id=None, logger=None, **_kwargs):
|
||||
"""
|
||||
Configure processe lists based on options.
|
||||
|
||||
@ -68,7 +68,7 @@ class HangAnalyzer(Subcommand):
|
||||
self._configure_processes()
|
||||
self._setup_logging(logger)
|
||||
|
||||
def execute(self): # pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||
def execute(self):
|
||||
"""
|
||||
Execute hang analysis.
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from distutils import spawn # pylint: disable=no-name-in-module
|
||||
from distutils import spawn
|
||||
from datetime import datetime
|
||||
|
||||
import psutil
|
||||
|
||||
@ -218,9 +218,8 @@ class _BaseBuildloggerHandler(handlers.BufferedHandler):
|
||||
class BuildloggerTestHandler(_BaseBuildloggerHandler):
|
||||
"""Buildlogger handler for the test logs."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, build_config, build_id, test_id, capacity=_SEND_AFTER_LINES,
|
||||
interval_secs=_SEND_AFTER_SECS):
|
||||
def __init__(self, build_config, build_id, test_id, capacity=_SEND_AFTER_LINES,
|
||||
interval_secs=_SEND_AFTER_SECS):
|
||||
"""Initialize the buildlogger handler with the credentials, build id, and test id."""
|
||||
endpoint = APPEND_TEST_LOGS_ENDPOINT % {
|
||||
"build_id": build_id,
|
||||
|
||||
@ -31,8 +31,6 @@ class BufferedHandler(logging.Handler):
|
||||
should be flushed. If it should, then flush() is expected to do what's needed.
|
||||
"""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
|
||||
def __init__(self, capacity, interval_secs):
|
||||
"""Initialize the handler with the buffer size and timeout.
|
||||
|
||||
@ -84,7 +82,7 @@ class BufferedHandler(logging.Handler):
|
||||
"""Release."""
|
||||
pass
|
||||
|
||||
def process_record(self, record): # pylint: disable=no-self-use
|
||||
def process_record(self, record):
|
||||
"""Apply a transformation to the record before it gets added to the buffer.
|
||||
|
||||
The default implementation returns 'record' unmodified.
|
||||
|
||||
@ -193,7 +193,6 @@ def new_testqueue_logger(test_kind):
|
||||
return logger
|
||||
|
||||
|
||||
#pylint: disable=too-many-arguments
|
||||
def new_test_logger(test_shortname, test_basename, command, parent, job_num, test_id, job_logger):
|
||||
"""Create a new test logger that will be a child of the given parent."""
|
||||
name = "%s:%s" % (parent.name, test_shortname)
|
||||
|
||||
@ -163,15 +163,15 @@ class MongoReleases(BaseModel):
|
||||
|
||||
def get_fcv_versions(self) -> List[Version]:
|
||||
"""Get the Version representation of all fcv versions."""
|
||||
return [Version(fcv) for fcv in self.feature_compatibility_versions]
|
||||
return [Version(fcv) for fcv in self.feature_compatibility_versions] # pylint: disable=not-an-iterable
|
||||
|
||||
def get_lts_versions(self) -> List[Version]:
|
||||
"""Get the Version representation of the lts versions."""
|
||||
return [Version(lts) for lts in self.long_term_support_releases]
|
||||
return [Version(lts) for lts in self.long_term_support_releases] # pylint: disable=not-an-iterable
|
||||
|
||||
def get_eol_versions(self) -> List[Version]:
|
||||
"""Get the Version representation of the EOL versions."""
|
||||
return [Version(eol) for eol in self.eol_versions]
|
||||
return [Version(eol) for eol in self.eol_versions] # pylint: disable=not-an-iterable
|
||||
|
||||
|
||||
class MultiversionService:
|
||||
|
||||
@ -103,7 +103,7 @@ class PowercyclePlugin(PluginInterface):
|
||||
# Only need to return run_parser for further processing; others don't need additional args.
|
||||
return run_parser
|
||||
|
||||
def add_subcommand(self, subparsers): # pylint: disable=too-many-statements
|
||||
def add_subcommand(self, subparsers):
|
||||
"""Create and add the parser for the subcommand."""
|
||||
intermediate_parser = subparsers.add_parser(
|
||||
SUBCOMMAND, help=__doc__, usage="""
|
||||
|
||||
@ -18,7 +18,7 @@ from buildscripts.resmokelib.powercycle.lib.named_temp_file import NamedTempFile
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=abstract-method, too-many-instance-attributes
|
||||
# pylint: disable=abstract-method
|
||||
class PowercycleCommand(Subcommand):
|
||||
"""Base class for remote operations to set up powercycle."""
|
||||
|
||||
|
||||
@ -46,12 +46,11 @@ def posix_path(path):
|
||||
return "{quote}{path}{quote}".format(quote=path_quote, path=new_path)
|
||||
|
||||
|
||||
class RemoteOperations(object): # pylint: disable=too-many-instance-attributes
|
||||
class RemoteOperations(object):
|
||||
"""Class to support remote operations."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, user_host, ssh_connection_options=None, ssh_options=None, scp_options=None,
|
||||
shell_binary="/bin/bash", use_shell=False, ignore_ret=False, access_retry_count=5):
|
||||
def __init__(self, user_host, ssh_connection_options=None, ssh_options=None, scp_options=None,
|
||||
shell_binary="/bin/bash", use_shell=False, ignore_ret=False, access_retry_count=5):
|
||||
"""Initialize RemoteOperations."""
|
||||
|
||||
self.user_host = user_host
|
||||
@ -125,7 +124,7 @@ class RemoteOperations(object): # pylint: disable=too-many-instance-attributes
|
||||
"""
|
||||
return message.startswith("ssh:")
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-arguments,too-many-locals,inconsistent-return-statements
|
||||
# pylint: disable=inconsistent-return-statements
|
||||
def operation(self, operation_type, operation_param, operation_dir=None, retry=False,
|
||||
retry_count=5):
|
||||
"""Execute Main entry for remote operations. Returns (code, output).
|
||||
|
||||
@ -37,7 +37,7 @@ if _IS_WINDOWS:
|
||||
_try_import("win32serviceutil")
|
||||
|
||||
|
||||
# pylint: disable=undefined-variable,unused-variable,too-many-instance-attributes
|
||||
# pylint: disable=undefined-variable,unused-variable
|
||||
class WindowsService(object):
|
||||
"""Windows service control class."""
|
||||
|
||||
@ -191,15 +191,15 @@ class PosixService(object):
|
||||
self.db_path = db_path
|
||||
self.pids = []
|
||||
|
||||
def create(self): # pylint: disable=no-self-use
|
||||
def create(self):
|
||||
"""Simulate create service. Returns (code, output) tuple."""
|
||||
return 0, None
|
||||
|
||||
def update(self): # pylint: disable=no-self-use
|
||||
def update(self):
|
||||
"""Simulate update service. Returns (code, output) tuple."""
|
||||
return 0, None
|
||||
|
||||
def delete(self): # pylint: disable=no-self-use
|
||||
def delete(self):
|
||||
"""Simulate delete service. Returns (code, output) tuple."""
|
||||
return 0, None
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import atexit
|
||||
import collections
|
||||
import copy
|
||||
import datetime
|
||||
import distutils.spawn # pylint: disable=no-name-in-module
|
||||
import distutils.spawn
|
||||
import importlib
|
||||
import json
|
||||
import logging
|
||||
@ -69,8 +69,6 @@ if _IS_WINDOWS:
|
||||
_try_import("win32service")
|
||||
_try_import("win32serviceutil")
|
||||
|
||||
# pylint: disable=too-many-lines
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ONE_HOUR_SECS = 60 * 60
|
||||
@ -596,11 +594,10 @@ class Processes(object):
|
||||
cls.kill(proc)
|
||||
|
||||
|
||||
class MongodControl(object): # pylint: disable=too-many-instance-attributes
|
||||
class MongodControl(object):
|
||||
"""Control mongod process."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, bin_dir, db_path, log_path, port, options=None):
|
||||
def __init__(self, bin_dir, db_path, log_path, port, options=None):
|
||||
"""Initialize MongodControl."""
|
||||
self.process_name = "mongod{}".format(executable_extension())
|
||||
|
||||
@ -725,9 +722,8 @@ class LocalToRemoteOperations(object):
|
||||
Return (return code, output).
|
||||
"""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, user_host, ssh_connection_options=None, ssh_options=None,
|
||||
shell_binary="/bin/bash", use_shell=False, access_retry_count=5):
|
||||
def __init__(self, user_host, ssh_connection_options=None, ssh_options=None,
|
||||
shell_binary="/bin/bash", use_shell=False, access_retry_count=5):
|
||||
"""Initialize LocalToRemoteOperations."""
|
||||
|
||||
self.remote_op = remote_operations.RemoteOperations(
|
||||
@ -760,7 +756,6 @@ class LocalToRemoteOperations(object):
|
||||
return self.remote_op.access_info()
|
||||
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||
def remote_handler(options, task_config, root_dir):
|
||||
"""Remote operations handler executes all remote operations on the remote host.
|
||||
|
||||
@ -1055,8 +1050,7 @@ def internal_crash():
|
||||
return 1, "Crash did not occur"
|
||||
|
||||
|
||||
def crash_server_or_kill_mongod( # pylint: disable=too-many-arguments,too-many-locals
|
||||
task_config, crash_canary, local_ops, script_name, client_args):
|
||||
def crash_server_or_kill_mongod(task_config, crash_canary, local_ops, script_name, client_args):
|
||||
"""Crash server or kill mongod and optionally write canary doc. Return tuple (ret, output)."""
|
||||
|
||||
crash_wait_time = powercycle_constants.CRASH_WAIT_TIME + random.randint(
|
||||
@ -1127,8 +1121,7 @@ def get_mongo_client_args(host=None, port=None, task_config=None,
|
||||
return mongo_args
|
||||
|
||||
|
||||
def mongo_shell( # pylint: disable=too-many-arguments
|
||||
mongo_path, work_dir, host_port, mongo_cmds, retries=5, retry_sleep=5):
|
||||
def mongo_shell(mongo_path, work_dir, host_port, mongo_cmds, retries=5, retry_sleep=5):
|
||||
"""Start mongo_path from work_dir, connecting to host_port and executes mongo_cmds."""
|
||||
cmds = "cd {}; echo {} | {} {}".format(
|
||||
pipes.quote(work_dir), pipes.quote(mongo_cmds), pipes.quote(mongo_path), host_port)
|
||||
@ -1268,9 +1261,8 @@ def new_resmoke_config(config_file, new_config_file, test_data, eval_str=""):
|
||||
yaml.safe_dump(config, yaml_stream)
|
||||
|
||||
|
||||
def resmoke_client( # pylint: disable=too-many-arguments
|
||||
work_dir, mongo_path, host_port, js_test, resmoke_suite, repeat_num=1, no_wait=False,
|
||||
log_file=None):
|
||||
def resmoke_client(work_dir, mongo_path, host_port, js_test, resmoke_suite, repeat_num=1,
|
||||
no_wait=False, log_file=None):
|
||||
"""Start resmoke client from work_dir, connecting to host_port and executes js_test."""
|
||||
log_output = f">> {log_file} 2>&1" if log_file else ""
|
||||
cmds = (f"cd {pipes.quote(work_dir)};"
|
||||
@ -1300,7 +1292,7 @@ def get_remote_python():
|
||||
return remote_python
|
||||
|
||||
|
||||
def main(parser_actions, options): # pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||
def main(parser_actions, options):
|
||||
"""Execute Main program."""
|
||||
|
||||
# pylint: disable=global-statement
|
||||
|
||||
@ -6,7 +6,7 @@ from buildscripts.resmokelib.powercycle import powercycle, powercycle_constants
|
||||
POWERCYCLE_TASKS_CONFIG = "buildscripts/resmokeconfig/powercycle/powercycle_tasks.yml"
|
||||
|
||||
|
||||
class PowercycleTaskConfig: # pylint: disable=too-many-instance-attributes
|
||||
class PowercycleTaskConfig:
|
||||
"""Class represents single task in powercycle tasks config."""
|
||||
|
||||
def __init__(self, task_yaml):
|
||||
|
||||
@ -13,7 +13,7 @@ class RunHangAnalyzerOnRemoteInstance(PowercycleCommand):
|
||||
|
||||
COMMAND = "runHangAnalyzerOnRemoteInstance"
|
||||
|
||||
def execute(self) -> None: # pylint: disable=too-many-locals
|
||||
def execute(self) -> None:
|
||||
""":return: None."""
|
||||
if "private_ip_address" not in self.expansions:
|
||||
return
|
||||
|
||||
@ -12,7 +12,7 @@ class SetUpEC2Instance(PowercycleCommand):
|
||||
|
||||
COMMAND = "setUpEC2Instance"
|
||||
|
||||
def execute(self) -> None: # pylint: disable=too-many-instance-attributes, too-many-locals, too-many-statements
|
||||
def execute(self) -> None:
|
||||
""":return: None."""
|
||||
|
||||
default_retry_count = 2
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
"""Command line utility for executing MongoDB tests of all kinds."""
|
||||
# pylint: disable=too-many-lines
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
@ -40,7 +39,7 @@ _EVERGREEN_ARGUMENT_TITLE = "Evergreen options"
|
||||
_CEDAR_ARGUMENT_TITLE = "Cedar options"
|
||||
|
||||
|
||||
class TestRunner(Subcommand): # pylint: disable=too-many-instance-attributes
|
||||
class TestRunner(Subcommand):
|
||||
"""The main class to run tests with resmoke."""
|
||||
|
||||
def __init__(self, command, start_time=time.time()):
|
||||
@ -285,7 +284,6 @@ class TestRunner(Subcommand): # pylint: disable=too-many-instance-attributes
|
||||
fh.write(f"{resmoke_env_options} {local_resmoke_invocation}")
|
||||
|
||||
def _check_for_mongo_processes(self):
|
||||
# pylint: disable=too-many-branches,
|
||||
"""Check for existing mongo processes as they could interfere with running the tests."""
|
||||
|
||||
if config.AUTO_KILL == 'off' or config.SHELL_CONN_STRING is not None:
|
||||
@ -599,7 +597,6 @@ class TestRunnerEvg(TestRunner):
|
||||
class RunPlugin(PluginInterface):
|
||||
"""Interface to parsing."""
|
||||
|
||||
# pylint: disable=missing-docstring
|
||||
def add_subcommand(self, subparsers):
|
||||
"""
|
||||
Add subcommand parser.
|
||||
@ -632,7 +629,7 @@ class RunPlugin(PluginInterface):
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def _add_run(cls, subparsers): # pylint: disable=too-many-statements
|
||||
def _add_run(cls, subparsers):
|
||||
"""Create and add the parser for the Run subcommand."""
|
||||
parser = subparsers.add_parser("run", help="Runs the specified tests.")
|
||||
|
||||
@ -1166,7 +1163,7 @@ class RunPlugin(PluginInterface):
|
||||
help="Where to output the generated tags.")
|
||||
|
||||
|
||||
def to_local_args(input_args=None): # pylint: disable=too-many-branches,too-many-locals
|
||||
def to_local_args(input_args=None):
|
||||
"""
|
||||
Return a command line invocation for resmoke.py suitable for being run outside of Evergreen.
|
||||
|
||||
|
||||
@ -339,10 +339,9 @@ def _make_expression_list(configs):
|
||||
class _SelectorConfig(object):
|
||||
"""Base object to represent the configuration for test selection."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, root=None, roots=None, include_files=None, exclude_files=None, include_tags=None,
|
||||
exclude_tags=None, include_with_any_tags=None, exclude_with_any_tags=None,
|
||||
tag_file=None):
|
||||
def __init__(self, root=None, roots=None, include_files=None, exclude_files=None,
|
||||
include_tags=None, exclude_tags=None, include_with_any_tags=None,
|
||||
exclude_with_any_tags=None, tag_file=None):
|
||||
"""Initialize the _SelectorConfig from the configuration elements.
|
||||
|
||||
Args:
|
||||
@ -472,9 +471,9 @@ class _Selector(object):
|
||||
class _JSTestSelectorConfig(_SelectorConfig):
|
||||
"""_SelectorConfig subclass for JavaScript tests."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, roots=None, include_files=None, exclude_files=None, include_with_any_tags=None,
|
||||
exclude_with_any_tags=None, include_tags=None, exclude_tags=None, tag_file=None):
|
||||
def __init__(self, roots=None, include_files=None, exclude_files=None,
|
||||
include_with_any_tags=None, exclude_with_any_tags=None, include_tags=None,
|
||||
exclude_tags=None, tag_file=None):
|
||||
_SelectorConfig.__init__(
|
||||
self, roots=roots, include_files=include_files, exclude_files=exclude_files,
|
||||
include_with_any_tags=include_with_any_tags,
|
||||
|
||||
@ -93,7 +93,6 @@ class EvgURLInfo(NamedTuple):
|
||||
class SetupMultiversion(Subcommand):
|
||||
"""Main class for the setup multiversion subcommand."""
|
||||
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, download_options, install_dir="", link_dir="", mv_platform=None,
|
||||
edition=None, architecture=None, use_latest=None, versions=None, variant=None,
|
||||
install_last_lts=None, install_last_continuous=None, evergreen_config=None,
|
||||
@ -373,7 +372,6 @@ class SetupMultiversion(Subcommand):
|
||||
@staticmethod
|
||||
def setup_mongodb(artifacts_url, binaries_url, symbols_url, python_venv_url, install_dir,
|
||||
bin_suffix=None, link_dir=None, install_dir_list=None):
|
||||
# pylint: disable=too-many-arguments
|
||||
"""Download, extract and symlink."""
|
||||
|
||||
for url in [artifacts_url, binaries_url, symbols_url, python_venv_url]:
|
||||
|
||||
@ -230,9 +230,7 @@ class MatrixSuiteConfig(SuiteConfigInterface):
|
||||
base_suite = ExplicitSuiteConfig.get_config_obj(base_suite_name)
|
||||
|
||||
if base_suite is None:
|
||||
# pylint: disable=too-many-format-args
|
||||
raise ValueError("Unknown base suite %s for matrix suite %s".format(
|
||||
base_suite_name, suite_name))
|
||||
raise ValueError(f"Unknown base suite {base_suite_name} for matrix suite {suite_name}")
|
||||
|
||||
res = base_suite.copy()
|
||||
|
||||
@ -265,7 +263,7 @@ class MatrixSuiteConfig(SuiteConfigInterface):
|
||||
all_matrix_suites = cls.get_all_mappings(suites_dir)
|
||||
|
||||
if suite_name in all_matrix_suites.keys():
|
||||
return all_matrix_suites[suite_name] # pylint: disable=unsubscriptable-object
|
||||
return all_matrix_suites[suite_name]
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -161,7 +161,7 @@ class Symbolizer(Subcommand):
|
||||
LOGGER.info("Applying patch diff (if any)...")
|
||||
self._patch_diff_by_id()
|
||||
|
||||
except: # pylint: disable=bare-except
|
||||
except:
|
||||
if self.dest_dir is not None:
|
||||
LOGGER.warning("Removing downloaded directory due to error",
|
||||
directory=self.dest_dir)
|
||||
|
||||
@ -19,7 +19,7 @@ from buildscripts.resmokelib.testing.queue_element import queue_elem_factory, Qu
|
||||
from buildscripts.resmokelib.utils import queue as _queue
|
||||
|
||||
|
||||
class TestSuiteExecutor(object): # pylint: disable=too-many-instance-attributes
|
||||
class TestSuiteExecutor(object):
|
||||
"""Execute a test suite.
|
||||
|
||||
Responsible for setting up and tearing down the fixtures that the
|
||||
@ -28,9 +28,8 @@ class TestSuiteExecutor(object): # pylint: disable=too-many-instance-attributes
|
||||
|
||||
_TIMEOUT = 24 * 60 * 60 # =1 day (a long time to have tests run)
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, exec_logger, suite, config=None, fixture=None, hooks=None, archive_instance=None,
|
||||
archive=None):
|
||||
def __init__(self, exec_logger, suite, config=None, fixture=None, hooks=None,
|
||||
archive_instance=None, archive=None):
|
||||
"""Initialize the TestSuiteExecutor with the test suite to run."""
|
||||
self.logger = exec_logger
|
||||
|
||||
@ -66,7 +65,7 @@ class TestSuiteExecutor(object): # pylint: disable=too-many-instance-attributes
|
||||
"""
|
||||
return [self._make_job(job_num) for job_num in range(num_jobs)]
|
||||
|
||||
def run(self): # pylint: disable=too-many-branches
|
||||
def run(self):
|
||||
"""Execute the test suite.
|
||||
|
||||
Any exceptions that occur during setting up or tearing down a
|
||||
|
||||
@ -15,8 +15,6 @@ from buildscripts.resmokelib.testing.fixtures import _builder
|
||||
class FixtureLib:
|
||||
"""Class that exposes the resmokelib API that fixtures can use."""
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
#################
|
||||
# Logger tools #
|
||||
#################
|
||||
@ -45,7 +43,7 @@ class FixtureLib:
|
||||
"""Build fixtures by calling builder API."""
|
||||
return _builder.make_fixture(class_name, logger, job_num, *args, **kwargs)
|
||||
|
||||
def mongod_program(self, logger, job_num, executable, process_kwargs, mongod_options): # pylint: disable=too-many-arguments
|
||||
def mongod_program(self, logger, job_num, executable, process_kwargs, mongod_options):
|
||||
"""
|
||||
Return a Process instance that starts mongod arguments constructed from 'mongod_options'.
|
||||
|
||||
@ -58,12 +56,12 @@ class FixtureLib:
|
||||
mongod_options)
|
||||
|
||||
def mongos_program(self, logger, job_num, executable=None, process_kwargs=None,
|
||||
mongos_options=None): # pylint: disable=too-many-arguments
|
||||
mongos_options=None):
|
||||
"""Return a Process instance that starts a mongos with arguments constructed from 'kwargs'."""
|
||||
return core.programs.mongos_program(logger, job_num, executable, process_kwargs,
|
||||
mongos_options)
|
||||
|
||||
def generic_program(self, logger, args, process_kwargs=None, **kwargs): # pylint: disable=too-many-arguments
|
||||
def generic_program(self, logger, args, process_kwargs=None, **kwargs):
|
||||
"""Return a Process instance that starts an arbitrary executable.
|
||||
|
||||
The executable arguments are constructed from 'kwargs'.
|
||||
@ -112,7 +110,7 @@ class FixtureLib:
|
||||
return original
|
||||
|
||||
|
||||
class _FixtureConfig(object): # pylint: disable=too-many-instance-attributes
|
||||
class _FixtureConfig(object):
|
||||
"""Class that stores fixture configuration info."""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@ -148,11 +148,11 @@ class Fixture(object, metaclass=registry.make_registry_metaclass(_FIXTURES)): #
|
||||
"""
|
||||
pass
|
||||
|
||||
def is_running(self): # pylint: disable=no-self-use
|
||||
def is_running(self):
|
||||
"""Return true if the fixture is still operating and more tests and can be run."""
|
||||
return True
|
||||
|
||||
def get_node_info(self): # pylint: disable=no-self-use
|
||||
def get_node_info(self):
|
||||
"""Return a list of NodeInfo objects."""
|
||||
return []
|
||||
|
||||
|
||||
@ -37,17 +37,16 @@ def compare_optime(optime1, optime2):
|
||||
return compare_timestamp(optime1["ts"], optime2["ts"])
|
||||
|
||||
|
||||
class ReplicaSetFixture(interface.ReplFixture): # pylint: disable=too-many-instance-attributes, too-many-public-methods
|
||||
class ReplicaSetFixture(interface.ReplFixture):
|
||||
"""Fixture which provides JSTests with a replica set to run against."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments, too-many-locals
|
||||
self, logger, job_num, fixturelib, mongod_executable=None, mongod_options=None,
|
||||
dbpath_prefix=None, preserve_dbpath=False, num_nodes=2, start_initial_sync_node=False,
|
||||
write_concern_majority_journal_default=None, auth_options=None,
|
||||
replset_config_options=None, voting_secondaries=True, all_nodes_electable=False,
|
||||
use_replica_set_connection_string=None, linear_chain=False, default_read_concern=None,
|
||||
default_write_concern=None, shard_logging_prefix=None, replicaset_logging_prefix=None,
|
||||
replset_name=None):
|
||||
def __init__(self, logger, job_num, fixturelib, mongod_executable=None, mongod_options=None,
|
||||
dbpath_prefix=None, preserve_dbpath=False, num_nodes=2,
|
||||
start_initial_sync_node=False, write_concern_majority_journal_default=None,
|
||||
auth_options=None, replset_config_options=None, voting_secondaries=True,
|
||||
all_nodes_electable=False, use_replica_set_connection_string=None,
|
||||
linear_chain=False, default_read_concern=None, default_write_concern=None,
|
||||
shard_logging_prefix=None, replicaset_logging_prefix=None, replset_name=None):
|
||||
"""Initialize ReplicaSetFixture."""
|
||||
|
||||
interface.ReplFixture.__init__(self, logger, job_num, fixturelib,
|
||||
@ -110,7 +109,7 @@ class ReplicaSetFixture(interface.ReplFixture): # pylint: disable=too-many-inst
|
||||
self.initial_sync_node = None
|
||||
self.initial_sync_node_idx = -1
|
||||
|
||||
def setup(self): # pylint: disable=too-many-branches,too-many-statements,too-many-locals
|
||||
def setup(self):
|
||||
"""Set up the replica set."""
|
||||
|
||||
# Version-agnostic options for mongod/s can be set here.
|
||||
|
||||
@ -23,13 +23,13 @@ def _teardown_and_clean_node(node):
|
||||
shutil.rmtree(node.get_dbpath_prefix(), ignore_errors=False)
|
||||
|
||||
|
||||
class ShardSplitFixture(interface.MultiClusterFixture): # pylint: disable=too-many-instance-attributes
|
||||
class ShardSplitFixture(interface.MultiClusterFixture):
|
||||
"""Fixture which provides JSTests with a replica set and recipient nodes to run splits against."""
|
||||
|
||||
AWAIT_REPL_TIMEOUT_MINS = 5
|
||||
AWAIT_REPL_TIMEOUT_FOREVER_MINS = 24 * 60
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments,too-many-locals
|
||||
def __init__(
|
||||
self,
|
||||
logger,
|
||||
job_num,
|
||||
|
||||
@ -11,7 +11,7 @@ import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
import buildscripts.resmokelib.testing.fixtures.external as external
|
||||
|
||||
|
||||
class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-instance-attributes
|
||||
class ShardedClusterFixture(interface.Fixture):
|
||||
"""Fixture which provides JSTests with a sharded cluster to run against."""
|
||||
|
||||
_CONFIGSVR_REPLSET_NAME = "config-rs"
|
||||
@ -19,12 +19,12 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
|
||||
|
||||
AWAIT_SHARDING_INITIALIZATION_TIMEOUT_SECS = 60
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments,too-many-locals
|
||||
self, logger, job_num, fixturelib, mongos_executable=None, mongos_options=None,
|
||||
mongod_executable=None, mongod_options=None, dbpath_prefix=None, preserve_dbpath=False,
|
||||
num_shards=1, num_rs_nodes_per_shard=1, num_mongos=1, enable_sharding=None,
|
||||
enable_balancer=True, enable_autosplit=True, auth_options=None, configsvr_options=None,
|
||||
shard_options=None, cluster_logging_prefix=None):
|
||||
def __init__(self, logger, job_num, fixturelib, mongos_executable=None, mongos_options=None,
|
||||
mongod_executable=None, mongod_options=None, dbpath_prefix=None,
|
||||
preserve_dbpath=False, num_shards=1, num_rs_nodes_per_shard=1, num_mongos=1,
|
||||
enable_sharding=None, enable_balancer=True, enable_autosplit=True,
|
||||
auth_options=None, configsvr_options=None, shard_options=None,
|
||||
cluster_logging_prefix=None):
|
||||
"""Initialize ShardedClusterFixture with different options for the cluster processes."""
|
||||
|
||||
interface.Fixture.__init__(self, logger, job_num, fixturelib, dbpath_prefix=dbpath_prefix)
|
||||
@ -429,7 +429,6 @@ class ExternalShardedClusterFixture(external.ExternalFixture, ShardedClusterFixt
|
||||
class _MongoSFixture(interface.Fixture):
|
||||
"""Fixture which provides JSTests with a mongos to connect to."""
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
def __init__(self, logger, job_num, fixturelib, dbpath_prefix, mongos_executable=None,
|
||||
mongos_options=None, add_feature_flags=False):
|
||||
"""Initialize _MongoSFixture."""
|
||||
@ -542,7 +541,6 @@ class _MongoSFixture(interface.Fixture):
|
||||
exit_code = self.mongos.wait()
|
||||
|
||||
# Python's subprocess module returns negative versions of system calls.
|
||||
# pylint: disable=invalid-unary-operand-type
|
||||
if exit_code == 0 or (mode is not None and exit_code == -(mode.value)):
|
||||
self.logger.info("Successfully stopped the mongos on port {:d}".format(self.port))
|
||||
else:
|
||||
|
||||
@ -17,9 +17,8 @@ import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
class MongoDFixture(interface.Fixture):
|
||||
"""Fixture which provides JSTests with a standalone mongod to run against."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, job_num, fixturelib, mongod_executable=None, mongod_options=None,
|
||||
add_feature_flags=False, dbpath_prefix=None, preserve_dbpath=False, port=None):
|
||||
def __init__(self, logger, job_num, fixturelib, mongod_executable=None, mongod_options=None,
|
||||
add_feature_flags=False, dbpath_prefix=None, preserve_dbpath=False, port=None):
|
||||
"""Initialize MongoDFixture with different options for the mongod process."""
|
||||
interface.Fixture.__init__(self, logger, job_num, fixturelib, dbpath_prefix=dbpath_prefix)
|
||||
self.mongod_options = self.fixturelib.make_historic(
|
||||
@ -149,7 +148,6 @@ class MongoDFixture(interface.Fixture):
|
||||
exit_code = self.mongod.wait()
|
||||
|
||||
# Python's subprocess module returns negative versions of system calls.
|
||||
# pylint: disable=invalid-unary-operand-type
|
||||
if exit_code == 0 or (mode is not None and exit_code == -(mode.value)):
|
||||
self.logger.info("Successfully stopped the mongod on port {:d}.".format(self.port))
|
||||
else:
|
||||
@ -215,8 +213,8 @@ class MongodLauncher(object):
|
||||
self.fixturelib = fixturelib
|
||||
self.config = fixturelib.get_config()
|
||||
|
||||
def launch_mongod_program( # pylint: disable=too-many-branches,too-many-statements,too-many-arguments
|
||||
self, logger, job_num, executable=None, process_kwargs=None, mongod_options=None):
|
||||
def launch_mongod_program(self, logger, job_num, executable=None, process_kwargs=None,
|
||||
mongod_options=None):
|
||||
"""
|
||||
Return a Process instance that starts mongod arguments constructed from 'mongod_options'.
|
||||
|
||||
|
||||
@ -9,16 +9,16 @@ import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib
|
||||
|
||||
|
||||
class TalkDirectlyToShardsvrsFixture(interface.MultiClusterFixture): # pylint: disable=too-many-instance-attributes
|
||||
class TalkDirectlyToShardsvrsFixture(interface.MultiClusterFixture):
|
||||
"""Fixture which provides JSTests with a set of shardsvrs and a config svr set to run against."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments,too-many-locals
|
||||
self, logger, job_num, fixturelib, common_mongod_options=None, dbpath_prefix=None,
|
||||
preserve_dbpath=False, num_replica_sets=1, num_nodes_per_replica_set=3,
|
||||
start_initial_sync_node=False, write_concern_majority_journal_default=None,
|
||||
auth_options=None, replset_config_options=None, voting_secondaries=True,
|
||||
all_nodes_electable=False, use_replica_set_connection_string=None, linear_chain=False,
|
||||
mixed_bin_versions=None, default_read_concern=None, default_write_concern=None):
|
||||
def __init__(self, logger, job_num, fixturelib, common_mongod_options=None, dbpath_prefix=None,
|
||||
preserve_dbpath=False, num_replica_sets=1, num_nodes_per_replica_set=3,
|
||||
start_initial_sync_node=False, write_concern_majority_journal_default=None,
|
||||
auth_options=None, replset_config_options=None, voting_secondaries=True,
|
||||
all_nodes_electable=False, use_replica_set_connection_string=None,
|
||||
linear_chain=False, mixed_bin_versions=None, default_read_concern=None,
|
||||
default_write_concern=None):
|
||||
"""Initialize TalkDirectlyToShardsvrsFixture with different options for the replica set processes."""
|
||||
|
||||
interface.MultiClusterFixture.__init__(self, logger, job_num, fixturelib,
|
||||
|
||||
@ -6,17 +6,16 @@ import buildscripts.resmokelib.testing.fixtures.interface as interface
|
||||
from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib
|
||||
|
||||
|
||||
class TenantMigrationFixture(interface.MultiClusterFixture): # pylint: disable=too-many-instance-attributes
|
||||
class TenantMigrationFixture(interface.MultiClusterFixture):
|
||||
"""Fixture which provides JSTests with a set of replica sets to run tenant migration against."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments,too-many-locals
|
||||
self, logger, job_num, fixturelib, common_mongod_options=None, per_mongod_options=None,
|
||||
dbpath_prefix=None, preserve_dbpath=False, num_replica_sets=1,
|
||||
num_nodes_per_replica_set=2, start_initial_sync_node=False,
|
||||
write_concern_majority_journal_default=None, auth_options=None,
|
||||
replset_config_options=None, voting_secondaries=True, all_nodes_electable=False,
|
||||
use_replica_set_connection_string=None, linear_chain=False, mixed_bin_versions=None,
|
||||
default_read_concern=None, default_write_concern=None):
|
||||
def __init__(self, logger, job_num, fixturelib, common_mongod_options=None,
|
||||
per_mongod_options=None, dbpath_prefix=None, preserve_dbpath=False,
|
||||
num_replica_sets=1, num_nodes_per_replica_set=2, start_initial_sync_node=False,
|
||||
write_concern_majority_journal_default=None, auth_options=None,
|
||||
replset_config_options=None, voting_secondaries=True, all_nodes_electable=False,
|
||||
use_replica_set_connection_string=None, linear_chain=False,
|
||||
mixed_bin_versions=None, default_read_concern=None, default_write_concern=None):
|
||||
"""Initialize TenantMigrationFixture with different options for the replica set processes."""
|
||||
|
||||
interface.MultiClusterFixture.__init__(self, logger, job_num, fixturelib,
|
||||
|
||||
@ -9,7 +9,7 @@ from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib
|
||||
class YesFixture(interface.Fixture): # pylint: disable=abstract-method
|
||||
"""Fixture which spawns several 'yes' executables to generate lots of log messages."""
|
||||
|
||||
def __init__(self, logger, job_num, fixturelib, num_instances=1, message_length=100): # pylint: disable=too-many-arguments
|
||||
def __init__(self, logger, job_num, fixturelib, num_instances=1, message_length=100):
|
||||
"""Initialize YesFixture."""
|
||||
interface.Fixture.__init__(self, logger, job_num, fixturelib)
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ from time import sleep
|
||||
from buildscripts.resmokelib.testing.hooks import interface
|
||||
|
||||
|
||||
class AntithesisLogging(interface.Hook): # pylint: disable=too-many-instance-attributes
|
||||
class AntithesisLogging(interface.Hook):
|
||||
"""Prints antithesis commands before & after test run."""
|
||||
|
||||
DESCRIPTION = "Prints antithesis commands before & after test run."
|
||||
|
||||
@ -6,7 +6,7 @@ import threading
|
||||
from buildscripts.resmokelib.testing.hooks import jsfile
|
||||
|
||||
|
||||
class _BackgroundJob(threading.Thread): # pylint: disable=too-many-instance-attributes
|
||||
class _BackgroundJob(threading.Thread):
|
||||
"""A thread for running a JS file while a test is running."""
|
||||
|
||||
def __init__(self, thread_name):
|
||||
|
||||
@ -20,8 +20,8 @@ class CleanupConcurrencyWorkloads(interface.Hook):
|
||||
|
||||
IS_BACKGROUND = False
|
||||
|
||||
def __init__( #pylint: disable=too-many-arguments
|
||||
self, hook_logger, fixture, exclude_dbs=None, same_collection=False, same_db=False):
|
||||
def __init__(self, hook_logger, fixture, exclude_dbs=None, same_collection=False,
|
||||
same_db=False):
|
||||
"""Initialize CleanupConcurrencyWorkloads."""
|
||||
description = "CleanupConcurrencyWorkloads drops all databases in the fixture"
|
||||
interface.Hook.__init__(self, hook_logger, fixture, description)
|
||||
|
||||
@ -6,7 +6,7 @@ from buildscripts.resmokelib import core
|
||||
from buildscripts.resmokelib.testing.hooks import interface
|
||||
|
||||
|
||||
class LibfuzzerHook(interface.Hook): # pylint: disable=too-many-instance-attributes
|
||||
class LibfuzzerHook(interface.Hook):
|
||||
"""Merges inputs after a fuzzer run."""
|
||||
|
||||
DESCRIPTION = "Merges inputs after a fuzzer run"
|
||||
|
||||
@ -13,10 +13,9 @@ class DropShardedCollections(jsfile.JSHook):
|
||||
|
||||
IS_BACKGROUND = False
|
||||
|
||||
def __init__( # pylint: disable=super-init-not-called
|
||||
self, hook_logger, fixture, shell_options=None):
|
||||
def __init__(self, hook_logger, fixture, shell_options=None):
|
||||
"""."""
|
||||
description = "Drop all sharded collections"
|
||||
js_filename = os.path.join("jstests", "hooks", "drop_sharded_collections.js")
|
||||
jsfile.JSHook.__init__( # pylint: disable=non-parent-init-called
|
||||
self, hook_logger, fixture, js_filename, description, shell_options=shell_options)
|
||||
jsfile.JSHook.__init__(self, hook_logger, fixture, js_filename, description,
|
||||
shell_options=shell_options)
|
||||
|
||||
@ -15,8 +15,7 @@ class EnableSpuriousWriteConflicts(interface.Hook):
|
||||
|
||||
IS_BACKGROUND = False
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, hook_logger, fixture, shell_options=None):
|
||||
def __init__(self, hook_logger, fixture, shell_options=None):
|
||||
"""Initialize ToggleWriteConflicts."""
|
||||
super().__init__(hook_logger, fixture, "TogglesWTWriteConflictExceptions")
|
||||
self._enable_js_filename = os.path.join("jstests", "hooks", "enable_write_conflicts.js")
|
||||
|
||||
@ -63,8 +63,7 @@ class BackgroundInitialSyncTestCase(jsfile.DynamicJSTestCase):
|
||||
INTERRUPTED_DUE_TO_REPL_STATE_CHANGE = 11602
|
||||
INTERRUPTED_DUE_TO_STORAGE_CHANGE = 355
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, test_name, description, base_test_name, hook, shell_options=None):
|
||||
def __init__(self, logger, test_name, description, base_test_name, hook, shell_options=None):
|
||||
"""Initialize BackgroundInitialSyncTestCase."""
|
||||
jsfile.DynamicJSTestCase.__init__(self, logger, test_name, description, base_test_name,
|
||||
hook, self.JS_FILENAME, shell_options)
|
||||
@ -198,8 +197,7 @@ class IntermediateInitialSyncTestCase(jsfile.DynamicJSTestCase):
|
||||
|
||||
JS_FILENAME = os.path.join("jstests", "hooks", "run_initial_sync_node_validation.js")
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, test_name, description, base_test_name, hook):
|
||||
def __init__(self, logger, test_name, description, base_test_name, hook):
|
||||
"""Initialize IntermediateInitialSyncTestCase."""
|
||||
jsfile.DynamicJSTestCase.__init__(self, logger, test_name, description, base_test_name,
|
||||
hook, self.JS_FILENAME)
|
||||
|
||||
@ -62,8 +62,7 @@ class Hook(object, metaclass=registry.make_registry_metaclass(_HOOKS)): # pylin
|
||||
class DynamicTestCase(testcase.TestCase): # pylint: disable=abstract-method
|
||||
"""DynamicTestCase class."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, test_name, description, base_test_name, hook):
|
||||
def __init__(self, logger, test_name, description, base_test_name, hook):
|
||||
"""Initialize DynamicTestCase."""
|
||||
testcase.TestCase.__init__(self, logger, "Hook", test_name, dynamic=True)
|
||||
self.description = description
|
||||
|
||||
@ -12,14 +12,13 @@ class JSHook(interface.Hook):
|
||||
|
||||
REGISTERED_NAME = registry.LEAVE_UNREGISTERED
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, hook_logger, fixture, js_filename, description, shell_options=None):
|
||||
def __init__(self, hook_logger, fixture, js_filename, description, shell_options=None):
|
||||
"""Initialize JSHook."""
|
||||
interface.Hook.__init__(self, hook_logger, fixture, description)
|
||||
self._js_filename = js_filename
|
||||
self._shell_options = shell_options
|
||||
|
||||
def _should_run_after_test(self): # pylint: disable=no-self-use
|
||||
def _should_run_after_test(self):
|
||||
"""Provide base callback.
|
||||
|
||||
Callback that can be overrided by subclasses to indicate if the JavaScript file should be
|
||||
@ -84,9 +83,8 @@ class PerClusterDataConsistencyHook(DataConsistencyHook):
|
||||
class DynamicJSTestCase(interface.DynamicTestCase):
|
||||
"""A dynamic TestCase that runs a JavaScript file."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, test_name, description, base_test_name, hook, js_filename,
|
||||
shell_options=None):
|
||||
def __init__(self, logger, test_name, description, base_test_name, hook, js_filename,
|
||||
shell_options=None):
|
||||
"""Initialize DynamicJSTestCase."""
|
||||
interface.DynamicTestCase.__init__(self, logger, test_name, description, base_test_name,
|
||||
hook)
|
||||
@ -104,7 +102,7 @@ class DynamicJSTestCase(interface.DynamicTestCase):
|
||||
interface.DynamicTestCase.reset_logger(self)
|
||||
self._js_test_case.reset_logger()
|
||||
|
||||
def configure(self, fixture, *args, **kwargs): # pylint: disable=unused-argument
|
||||
def configure(self, fixture, *args, **kwargs):
|
||||
"""Configure the fixture."""
|
||||
super().configure(fixture, *args, **kwargs)
|
||||
self._js_test_builder.configure(fixture, *args, **kwargs)
|
||||
|
||||
@ -5,7 +5,7 @@ import os.path
|
||||
from buildscripts.resmokelib.testing.hooks import jsfile
|
||||
|
||||
|
||||
class CheckReplOplogs(jsfile.PerClusterDataConsistencyHook): # pylint: disable=non-parent-init-called,super-init-not-called
|
||||
class CheckReplOplogs(jsfile.PerClusterDataConsistencyHook):
|
||||
"""Check that local.oplog.rs matches on the primary and secondaries."""
|
||||
|
||||
IS_BACKGROUND = False
|
||||
|
||||
@ -126,8 +126,7 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase):
|
||||
INTERRUPTED_DUE_TO_REPL_STATE_CHANGE = 11602
|
||||
INTERRUPTED_DUE_TO_STORAGE_CHANGE = 355
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, test_name, description, base_test_name, hook, test_report):
|
||||
def __init__(self, logger, test_name, description, base_test_name, hook, test_report):
|
||||
"""Initialize PeriodicKillSecondariesTestCase."""
|
||||
interface.DynamicTestCase.__init__(self, logger, test_name, description, base_test_name,
|
||||
hook)
|
||||
@ -262,8 +261,7 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase):
|
||||
self.logger.info(fixture.create_fixture_table(self.fixture))
|
||||
self.fixture.await_ready()
|
||||
|
||||
def _check_invariants_as_standalone(self, secondary): # pylint: disable=too-many-locals
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
def _check_invariants_as_standalone(self, secondary):
|
||||
# We remove the --replSet option in order to start the node as a standalone.
|
||||
replset_name = secondary.mongod_options.pop("replSet")
|
||||
self.logger.info(
|
||||
|
||||
@ -16,7 +16,7 @@ from buildscripts.resmokelib.testing.hooks import interface
|
||||
from buildscripts.resmokelib.testing.hooks import dbhash_tenant_migration
|
||||
|
||||
|
||||
class ContinuousShardSplit(interface.Hook): # pylint: disable=too-many-instance-attributes
|
||||
class ContinuousShardSplit(interface.Hook):
|
||||
"""Starts a shard split thread at the beginning of each test."""
|
||||
|
||||
DESCRIPTION = ("Continuous shard split operations")
|
||||
@ -154,8 +154,8 @@ class ShardSplitLifeCycle(object):
|
||||
|
||||
|
||||
class _ShardSplitOptions:
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, shard_split_fixture, tenant_ids, recipient_tag_name, recipient_set_name):
|
||||
def __init__(self, logger, shard_split_fixture, tenant_ids, recipient_tag_name,
|
||||
recipient_set_name):
|
||||
self.logger = logger
|
||||
self.migration_id = uuid.uuid4()
|
||||
self.shard_split_fixture = shard_split_fixture
|
||||
@ -197,7 +197,7 @@ class _ShardSplitOptions:
|
||||
return str(opts)
|
||||
|
||||
|
||||
class _ShardSplitThread(threading.Thread): # pylint: disable=too-many-instance-attributes
|
||||
class _ShardSplitThread(threading.Thread):
|
||||
THREAD_NAME = "ShardSplitThread"
|
||||
|
||||
WAIT_SECS_RANGES = [[0.05, 0.1], [0.1, 0.5], [1, 5], [5, 15]]
|
||||
|
||||
@ -17,7 +17,7 @@ from buildscripts.resmokelib.testing.fixtures import tenant_migration
|
||||
from buildscripts.resmokelib.testing.hooks import interface
|
||||
|
||||
|
||||
class ContinuousStepdown(interface.Hook): # pylint: disable=too-many-instance-attributes
|
||||
class ContinuousStepdown(interface.Hook):
|
||||
"""Regularly connect to replica sets and send a replSetStepDown command."""
|
||||
|
||||
DESCRIPTION = ("Continuous stepdown (steps down the primary of replica sets at regular"
|
||||
@ -28,11 +28,10 @@ class ContinuousStepdown(interface.Hook): # pylint: disable=too-many-instance-a
|
||||
# The hook stops the fixture partially during its execution.
|
||||
STOPS_FIXTURE = True
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, hook_logger, fixture, config_stepdown=True, shard_stepdown=True,
|
||||
stepdown_interval_ms=8000, terminate=False, kill=False,
|
||||
use_stepdown_permitted_file=False, wait_for_mongos_retarget=False,
|
||||
background_reconfig=False, auth_options=None, should_downgrade=False):
|
||||
def __init__(self, hook_logger, fixture, config_stepdown=True, shard_stepdown=True,
|
||||
stepdown_interval_ms=8000, terminate=False, kill=False,
|
||||
use_stepdown_permitted_file=False, wait_for_mongos_retarget=False,
|
||||
background_reconfig=False, auth_options=None, should_downgrade=False):
|
||||
"""Initialize the ContinuousStepdown.
|
||||
|
||||
Args:
|
||||
@ -119,7 +118,7 @@ class ContinuousStepdown(interface.Hook): # pylint: disable=too-many-instance-a
|
||||
self._stepdown_thread.pause()
|
||||
self.logger.info("Paused the stepdown thread.")
|
||||
|
||||
def _add_fixture(self, fixture): # pylint: disable=too-many-branches
|
||||
def _add_fixture(self, fixture):
|
||||
if isinstance(fixture, replicaset.ReplicaSetFixture):
|
||||
if not fixture.all_nodes_electable:
|
||||
raise ValueError(
|
||||
@ -371,11 +370,10 @@ def is_shard_split(fixture):
|
||||
return fixture.__class__.__name__ == 'ShardSplitFixture'
|
||||
|
||||
|
||||
class _StepdownThread(threading.Thread): # pylint: disable=too-many-instance-attributes
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, mongos_fixtures, rs_fixtures, stepdown_interval_secs, terminate, kill,
|
||||
stepdown_lifecycle, wait_for_mongos_retarget, background_reconfig, fixture,
|
||||
auth_options=None, should_downgrade=False):
|
||||
class _StepdownThread(threading.Thread):
|
||||
def __init__(self, logger, mongos_fixtures, rs_fixtures, stepdown_interval_secs, terminate,
|
||||
kill, stepdown_lifecycle, wait_for_mongos_retarget, background_reconfig, fixture,
|
||||
auth_options=None, should_downgrade=False):
|
||||
"""Initialize _StepdownThread."""
|
||||
threading.Thread.__init__(self, name="StepdownThread")
|
||||
self.daemon = True
|
||||
@ -403,7 +401,6 @@ class _StepdownThread(threading.Thread): # pylint: disable=too-many-instance-at
|
||||
self._is_idle_evt = threading.Event()
|
||||
self._is_idle_evt.set()
|
||||
|
||||
# pylint: disable=too-many-function-args
|
||||
self._step_up_stats = collections.Counter()
|
||||
|
||||
def run(self):
|
||||
@ -519,7 +516,6 @@ class _StepdownThread(threading.Thread): # pylint: disable=too-many-instance-at
|
||||
for rs_fixture in self._rs_fixtures:
|
||||
self._step_down(rs_fixture)
|
||||
|
||||
# pylint: disable=R0912,R0914,R0915
|
||||
def _step_down(self, rs_fixture):
|
||||
try:
|
||||
old_primary = rs_fixture.get_primary(timeout_secs=self._stepdown_interval_secs)
|
||||
@ -603,7 +599,7 @@ class _StepdownThread(threading.Thread): # pylint: disable=too-many-instance-at
|
||||
new_primary.get_internal_connection_string() if secondaries else "none")
|
||||
self._step_up_stats[key] += 1
|
||||
|
||||
def _do_wait_for_mongos_retarget(self): # pylint: disable=too-many-branches
|
||||
def _do_wait_for_mongos_retarget(self):
|
||||
"""Run collStats on each collection in each database on each mongos.
|
||||
|
||||
This is to ensure mongos can target the primary for each shard with data, including the
|
||||
|
||||
@ -17,7 +17,7 @@ from buildscripts.resmokelib.testing.hooks import dbhash_tenant_migration
|
||||
from buildscripts.resmokelib.testing.hooks import interface
|
||||
|
||||
|
||||
class ContinuousTenantMigration(interface.Hook): # pylint: disable=too-many-instance-attributes
|
||||
class ContinuousTenantMigration(interface.Hook):
|
||||
"""Starts a tenant migration thread at the beginning of each test."""
|
||||
|
||||
DESCRIPTION = ("Continuous tenant migrations")
|
||||
@ -187,8 +187,7 @@ def get_primary(rs, logger, max_tries=5): # noqa: D205,D400
|
||||
|
||||
|
||||
class _TenantMigrationOptions:
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, donor_rs, recipient_rs, tenant_id, read_preference, logger):
|
||||
def __init__(self, donor_rs, recipient_rs, tenant_id, read_preference, logger):
|
||||
self.donor_rs = donor_rs
|
||||
self.recipient_rs = recipient_rs
|
||||
self.migration_id = uuid.uuid4()
|
||||
@ -229,7 +228,7 @@ class _TenantMigrationOptions:
|
||||
return str(opts)
|
||||
|
||||
|
||||
class _TenantMigrationThread(threading.Thread): # pylint: disable=too-many-instance-attributes
|
||||
class _TenantMigrationThread(threading.Thread):
|
||||
THREAD_NAME = "TenantMigrationThread"
|
||||
|
||||
WAIT_SECS_RANGES = [[0.05, 0.1], [0.1, 0.5], [1, 5], [5, 15]]
|
||||
|
||||
@ -12,12 +12,11 @@ from buildscripts.resmokelib.testing.testcases import fixture as _fixture
|
||||
from buildscripts.resmokelib.utils import queue as _queue
|
||||
|
||||
|
||||
class Job(object): # pylint: disable=too-many-instance-attributes
|
||||
class Job(object):
|
||||
"""Run tests from a queue."""
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, job_num, logger, fixture, hooks, report, archival, suite_options,
|
||||
test_queue_logger):
|
||||
def __init__(self, job_num, logger, fixture, hooks, report, archival, suite_options,
|
||||
test_queue_logger):
|
||||
"""Initialize the job with the specified fixture and hooks."""
|
||||
|
||||
self.logger = logger
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# pylint: disable=invalid-name
|
||||
"""Extension to the unittest.TestResult.
|
||||
|
||||
This is used to support additional test status and timing information for the report.json file.
|
||||
@ -14,7 +15,7 @@ from buildscripts.resmokelib.testing.symbolizer_service import ResmokeSymbolizer
|
||||
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attributes
|
||||
class TestReport(unittest.TestResult):
|
||||
"""Record test status and timing information."""
|
||||
|
||||
def __init__(self, job_logger, suite_options, job_num=None):
|
||||
@ -103,7 +104,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
|
||||
return combined_report
|
||||
|
||||
def startTest(self, test): # pylint: disable=invalid-name
|
||||
def startTest(self, test):
|
||||
"""Call before 'test' is run."""
|
||||
|
||||
unittest.TestResult.startTest(self, test)
|
||||
@ -136,7 +137,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
test.override_logger(test_logger)
|
||||
test_info.start_time = time.time()
|
||||
|
||||
def stopTest(self, test): # pylint: disable=invalid-name
|
||||
def stopTest(self, test):
|
||||
"""Call after 'test' has run."""
|
||||
|
||||
# check if there are stacktrace files, if so, invoke the symbolizer here.
|
||||
@ -171,7 +172,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
# Restore the original logger for the test.
|
||||
test.reset_logger()
|
||||
|
||||
def addError(self, test, err): # pylint: disable=invalid-name
|
||||
def addError(self, test, err):
|
||||
"""Call when a non-failureException was raised during the execution of 'test'."""
|
||||
|
||||
unittest.TestResult.addError(self, test, err)
|
||||
@ -185,7 +186,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
test_info.evergreen_status = "fail"
|
||||
test_info.return_code = test.return_code
|
||||
|
||||
def setError(self, test): # pylint: disable=invalid-name
|
||||
def setError(self, test):
|
||||
"""Change the outcome of an existing test to an error."""
|
||||
self.job_logger.info("setError(%s)", test)
|
||||
|
||||
@ -205,7 +206,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
self.num_errored = len(self.get_errored())
|
||||
self.num_interrupted = len(self.get_interrupted())
|
||||
|
||||
def addFailure(self, test, err): # pylint: disable=invalid-name
|
||||
def addFailure(self, test, err):
|
||||
"""Call when a failureException was raised during the execution of 'test'."""
|
||||
|
||||
unittest.TestResult.addFailure(self, test, err)
|
||||
@ -223,7 +224,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
test_info.evergreen_status = self.suite_options.report_failure_status
|
||||
test_info.return_code = test.return_code
|
||||
|
||||
def setFailure(self, test, return_code=1): # pylint: disable=invalid-name
|
||||
def setFailure(self, test, return_code=1):
|
||||
"""Change the outcome of an existing test to a failure."""
|
||||
|
||||
with self._lock:
|
||||
@ -246,7 +247,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
self.num_errored = len(self.get_errored())
|
||||
self.num_interrupted = len(self.get_interrupted())
|
||||
|
||||
def addSuccess(self, test): # pylint: disable=invalid-name
|
||||
def addSuccess(self, test):
|
||||
"""Call when 'test' executed successfully."""
|
||||
|
||||
unittest.TestResult.addSuccess(self, test)
|
||||
@ -259,7 +260,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
test_info.evergreen_status = "pass"
|
||||
test_info.return_code = test.return_code
|
||||
|
||||
def wasSuccessful(self): # pylint: disable=invalid-name
|
||||
def wasSuccessful(self):
|
||||
"""Return true if all tests executed successfully."""
|
||||
|
||||
with self._lock:
|
||||
@ -387,7 +388,7 @@ class TestReport(unittest.TestResult): # pylint: disable=too-many-instance-attr
|
||||
raise ValueError("Details for %s not found in the report" % (test.basename()))
|
||||
|
||||
|
||||
class TestInfo(object): # pylint: disable=too-many-instance-attributes
|
||||
class TestInfo(object):
|
||||
"""Holder for the test status and timing information."""
|
||||
|
||||
def __init__(self, test_id, test_file, dynamic):
|
||||
|
||||
@ -59,7 +59,7 @@ def synchronized(method):
|
||||
return synced
|
||||
|
||||
|
||||
class Suite(object): # pylint: disable=too-many-instance-attributes,too-many-public-methods
|
||||
class Suite(object):
|
||||
"""A suite of tests of a particular kind (e.g. C++ unit tests, dbtests, jstests)."""
|
||||
|
||||
def __init__(self, suite_name, suite_config, suite_options=_config.SuiteOptions.ALL_INHERITED):
|
||||
|
||||
@ -21,7 +21,7 @@ class BenchmarkTestCase(interface.ProcessTestCase):
|
||||
self.suite_bm_options = program_options
|
||||
self.bm_options = {}
|
||||
|
||||
def validate_benchmark_options(self): # pylint: disable=no-self-use
|
||||
def validate_benchmark_options(self):
|
||||
"""Error out early if any options are incompatible with benchmark test suites.
|
||||
|
||||
:return: None
|
||||
|
||||
@ -15,9 +15,8 @@ class CPPLibfuzzerTestCase(interface.ProcessTestCase):
|
||||
REGISTERED_NAME = "cpp_libfuzzer_test"
|
||||
DEFAULT_TIMEOUT = datetime.timedelta(hours=1)
|
||||
|
||||
def __init__( # pylint: disable=too-many-arguments
|
||||
self, logger, program_executable, program_options=None, runs=1000000,
|
||||
corpus_directory_stem="corpora"):
|
||||
def __init__(self, logger, program_executable, program_options=None, runs=1000000,
|
||||
corpus_directory_stem="corpora"):
|
||||
"""Initialize the CPPLibfuzzerTestCase with the executable to run."""
|
||||
|
||||
interface.ProcessTestCase.__init__(self, logger, "C++ libfuzzer test", program_executable)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user