diff --git a/docs/testing/linters.md b/docs/testing/linters.md index a528e38c2c..36f6065a35 100644 --- a/docs/testing/linters.md +++ b/docs/testing/linters.md @@ -99,12 +99,9 @@ following checks: - Check HTML templates for matching tags and indentations. - Check CSS for parsability and formatting. - Check JavaScript code for addClass calls. - -The remaining lint checks occur in `./tools/run-mypy`. It is probably somewhat -of an understatement to call "mypy" a "linter," as it performs static -code analysis of Python type annotations throughout our Python codebase. - -Our [documentation on using mypy](../testing/mypy.html) covers mypy in more detail. +- Running `mypy` to check static types in Python code. Our + [documentation on using mypy](../testing/mypy.html) covers mypy in + more detail. The rest of this document pertains to the checks that occur in `./tools/lint`. diff --git a/tools/ci/backend b/tools/ci/backend index 2b2de42ba5..477815f242 100755 --- a/tools/ci/backend +++ b/tools/ci/backend @@ -6,7 +6,7 @@ echo "Test suite is running under $(python --version)." set -e set -x -./tools/lint --backend --no-gitlint # gitlint disabled because flaky +./tools/lint --backend --no-gitlint --no-mypy # gitlint disabled because flaky ./tools/test-tools ./tools/test-backend --coverage diff --git a/tools/lint b/tools/lint index 8328d861e6..1e4d83e6a3 100755 --- a/tools/lint +++ b/tools/lint @@ -27,6 +27,9 @@ def run(): parser.add_argument('--no-gitlint', action='store_true', help='Disable gitlint') + parser.add_argument('--no-mypy', + action='store_true', + help='Disable mypy') limited_tests_group = parser.add_mutually_exclusive_group() limited_tests_group.add_argument('--frontend', action='store_true', @@ -98,6 +101,8 @@ def run(): linter_config.external_linter('urls', ['tools/check-urls'], ['py']) linter_config.external_linter('swagger', ['node', 'tools/check-swagger'], ['yaml']) linter_config.external_linter('shellcheck', ['shellcheck', '-x'], ['sh']) + if not args.no_mypy: + linter_config.external_linter('mypy', ['tools/run-mypy'], ['py'], pass_targets=False) # Disabled check for imperative mood until it is stabilized if not args.no_gitlint: diff --git a/tools/test-all b/tools/test-all index c587e70126..ad7d8f1507 100755 --- a/tools/test-all +++ b/tools/test-all @@ -42,7 +42,6 @@ run ./tools/clean-repo run ./tools/lint --backend $FORCEARG run ./tools/test-tools run ./tools/test-backend $FORCEARG -run ./tools/run-mypy $FORCEARG run ./tools/test-migrations # Not running SVG optimizing since it's low-churn # run ./tools/setup/optimize-svg diff --git a/tools/zulint/command.py b/tools/zulint/command.py index 6343fe6564..51322c845b 100644 --- a/tools/zulint/command.py +++ b/tools/zulint/command.py @@ -57,8 +57,8 @@ class LinterConfig: self.lint_functions[func.__name__] = func return func - def external_linter(self, name, command, target_langs=[]): - # type: (str, List[str], List[str]) -> None + def external_linter(self, name, command, target_langs=[], pass_targets=True): + # type: (str, List[str], List[str], bool) -> None """Registers an external linter program to be run as part of the linter. This program will be passed the subset of files being linted that have extensions in target_langs. If there are no @@ -80,7 +80,11 @@ class LinterConfig: # invoking the external linter. return 0 - p = subprocess.Popen(command + targets, + if pass_targets: + full_command = command + targets + else: + full_command = command + p = subprocess.Popen(full_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)