Skip to content

Commit

Permalink
SERVER-68593 Disable low value python warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
IamXander authored and Evergreen Agent committed Sep 2, 2022
1 parent d4d4a26 commit 97ac02f
Show file tree
Hide file tree
Showing 177 changed files with 301 additions and 639 deletions.
10 changes: 9 additions & 1 deletion .pydocstyle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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[\\\/]).)*$
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion buildscripts/benchmarks/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions buildscripts/blackduck_hub.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,13 +18,13 @@
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
Expand Down Expand Up @@ -176,7 +175,6 @@ def post(self, endpoint, data=None, headers=None, timeout_secs=BUILD_LOGGER_TIME

# 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.
Expand All @@ -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
Expand Down Expand Up @@ -245,7 +242,7 @@ def post_new_file(self, build_id, test_name, lines):
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)
Expand Down Expand Up @@ -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
Expand All @@ -463,7 +459,6 @@ def __init__(self, name, version, licenses, policy_status, security_risk, newest

@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")
Expand Down Expand Up @@ -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__


Expand Down
2 changes: 0 additions & 2 deletions buildscripts/burn_in_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ def burn_in(self, repos: List[Repo], build_variant: str) -> None:
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.")
Expand All @@ -634,7 +633,6 @@ def burn_in(self, repos: List[Repo], build_variant: str) -> None:
@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,
Expand Down
4 changes: 2 additions & 2 deletions buildscripts/ciconfig/evergreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions buildscripts/clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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())

Expand Down
1 change: 0 additions & 1 deletion buildscripts/debugsymb_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def __init__(self, download_binaries=False, download_symbols=False, download_art
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"
Expand Down
4 changes: 1 addition & 3 deletions buildscripts/errorcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

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'])
Expand Down Expand Up @@ -237,7 +235,7 @@ def callback(assert_loc):
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.
Expand Down
5 changes: 2 additions & 3 deletions buildscripts/eslint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions buildscripts/evergreen_task_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
Expand Down
16 changes: 8 additions & 8 deletions buildscripts/gdb/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def __init__(self):
"""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')")

Expand All @@ -255,7 +255,7 @@ def __init__(self):
"""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:
Expand Down Expand Up @@ -293,7 +293,7 @@ def __init__(self):
"""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(" ")
Expand Down Expand Up @@ -425,7 +425,7 @@ def __init__(self):
"""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")
Expand Down Expand Up @@ -520,7 +520,7 @@ def invoke(self, arg, _from_tty):
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
Expand Down Expand Up @@ -653,7 +653,7 @@ def __init__(self):
"""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")
Expand Down Expand Up @@ -862,7 +862,7 @@ def __init__(self):
"""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):
Expand Down Expand Up @@ -892,7 +892,7 @@ def __init__(self):
"""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()

Expand Down
2 changes: 1 addition & 1 deletion buildscripts/gdb/mongo_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions buildscripts/gdb/udb.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -176,7 +175,6 @@ def binary_name():

return None

# pylint: disable=too-many-branches,too-many-locals
def invoke(self, args, from_tty):
"""GDB Command API invoke."""
arglist = args.split()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@
# 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
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)
Expand Down
Loading

0 comments on commit 97ac02f

Please sign in to comment.