mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-21 20:49:10 +01:00
SERVER-50592 Update mypy and GitPython pip requirements
Update the mypy and GitPython pip modules that are required for linting builds before commits to compatible versions rather than hard version requirements.
This commit is contained in:
parent
c70016c56f
commit
ca4df25002
@ -9,6 +9,9 @@ follow_imports = silent
|
||||
# This will limit effectiveness but avoids mypy complaining about running code.
|
||||
ignore_missing_imports = True
|
||||
|
||||
# Make None compatible with every type (the default prior to v 0.600)
|
||||
strict_optional = False
|
||||
|
||||
[mypy-idl.*]
|
||||
# Error if any code is missing type annotations.
|
||||
disallow_untyped_defs = True
|
||||
|
@ -71,6 +71,7 @@ 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)
|
||||
|
||||
|
||||
|
@ -92,6 +92,7 @@ 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
|
||||
eslint_distfile = ESLINT_SOURCE_TAR_BASE.substitute(platform=platform, arch=arch)
|
||||
extract_eslint(temp_tar_file, eslint_distfile)
|
||||
shutil.move(eslint_distfile, dest_file)
|
||||
|
@ -84,6 +84,7 @@ 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
|
||||
|
||||
|
||||
@ -94,6 +95,7 @@ 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
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@ class MypyLinter(base.LinterBase):
|
||||
"""Create a mypy linter."""
|
||||
# User can override the location of mypy from an environment variable.
|
||||
|
||||
super(MypyLinter, self).__init__("mypy", "mypy 0.580", os.getenv("MYPY"))
|
||||
super(MypyLinter, self).__init__("mypy", "0.580", os.getenv("MYPY"))
|
||||
|
||||
def get_lint_version_cmd_args(self):
|
||||
# type: () -> List[str]
|
||||
|
@ -13,7 +13,7 @@ class PyLintLinter(base.LinterBase):
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
"""Create a pylint linter."""
|
||||
super(PyLintLinter, self).__init__("pylint", "pylint 2.3.1")
|
||||
super(PyLintLinter, self).__init__("pylint", "2.3.1")
|
||||
|
||||
def get_lint_version_cmd_args(self):
|
||||
# type: () -> List[str]
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""Class to support running various linters in a common framework."""
|
||||
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import difflib
|
||||
import logging
|
||||
import os
|
||||
@ -8,7 +10,7 @@ import site
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
from typing import Dict, List, Optional
|
||||
import pkg_resources
|
||||
|
||||
from . import base
|
||||
|
||||
@ -22,22 +24,28 @@ def _check_version(linter, cmd_path, args):
|
||||
logging.info(str(cmd))
|
||||
process_handle = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, stderr = process_handle.communicate()
|
||||
output = output.decode('utf-8')
|
||||
decoded_output = output.decode('utf-8')
|
||||
|
||||
if process_handle.returncode:
|
||||
logging.info(
|
||||
"Version check failed for [%s], return code '%d'."
|
||||
"Standard Output:\n%s\nStandard Error:\n%s", cmd, process_handle.returncode, output,
|
||||
stderr)
|
||||
"Standard Output:\n%s\nStandard Error:\n%s", cmd, process_handle.returncode,
|
||||
decoded_output, stderr)
|
||||
|
||||
required_version = re.escape(linter.required_version)
|
||||
pattern = r"\b(?:(%s) )?(?P<version>\S+)\b" % (linter.cmd_name)
|
||||
required_version = pkg_resources.parse_version(linter.required_version)
|
||||
|
||||
pattern = r"\b%s\b" % (required_version)
|
||||
if not re.search(pattern, output):
|
||||
match = re.search(pattern, decoded_output)
|
||||
if match:
|
||||
found_version = match.group('version')
|
||||
else:
|
||||
found_version = '0.0'
|
||||
|
||||
if pkg_resources.parse_version(found_version) < required_version:
|
||||
logging.info(
|
||||
"Linter %s has wrong version for '%s'. Expected '%s',"
|
||||
"Linter %s has wrong version for '%s'. Expected >= '%s',"
|
||||
"Standard Output:\n'%s'\nStandard Error:\n%s", linter.cmd_name, cmd,
|
||||
required_version, output, stderr)
|
||||
required_version, decoded_output, stderr)
|
||||
return False
|
||||
|
||||
except OSError as os_error:
|
||||
|
@ -11,7 +11,7 @@ class YapfLinter(base.LinterBase):
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
"""Create a yapf linter."""
|
||||
super(YapfLinter, self).__init__("yapf", "yapf 0.26.0")
|
||||
super(YapfLinter, self).__init__("yapf", "0.26.0")
|
||||
|
||||
def get_lint_version_cmd_args(self):
|
||||
# type: () -> List[str]
|
||||
|
@ -370,6 +370,7 @@ 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):
|
||||
|
@ -1,4 +1,4 @@
|
||||
click ~= 7.0
|
||||
GitPython ~= 2.1.11
|
||||
GitPython ~= 3.1.7
|
||||
psutil
|
||||
structlog ~= 19.1.0
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Linters
|
||||
# Note: These versions are checked by python modules in buildscripts/linter/
|
||||
GitPython ~= 2.1.11
|
||||
mypy == 0.580; python_version > "3.4"
|
||||
GitPython ~= 3.1.7
|
||||
mypy ~= 0.580; python_version > "3.4"
|
||||
pydocstyle == 2.1.1
|
||||
pylint == 2.3.1
|
||||
structlog ~= 19.1.0
|
||||
|
Loading…
Reference in New Issue
Block a user