summaryrefslogtreecommitdiff
path: root/buildscripts/linter/yapf.py
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2017-04-18 18:18:26 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2017-04-18 18:18:26 -0400
commitc776e095ac25d0426624f4a84c03f0094c3c661f (patch)
tree4ee2b13dd37a64194934abf672e23759c112ca0b /buildscripts/linter/yapf.py
parentb9f9195390142f4e1363dc83b986ead5dc8993b8 (diff)
downloadmongo-c776e095ac25d0426624f4a84c03f0094c3c661f.tar.gz
SERVER-28308 Integrate python linting for IDL into Evergreen
Diffstat (limited to 'buildscripts/linter/yapf.py')
-rw-r--r--buildscripts/linter/yapf.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/buildscripts/linter/yapf.py b/buildscripts/linter/yapf.py
new file mode 100644
index 00000000000..86955981092
--- /dev/null
+++ b/buildscripts/linter/yapf.py
@@ -0,0 +1,36 @@
+"""YAPF linter support module."""
+from __future__ import absolute_import
+from __future__ import print_function
+
+from typing import List
+
+from . import base
+
+
+class YapfLinter(base.LinterBase):
+ """Yapf linter."""
+
+ def __init__(self):
+ # type: () -> None
+ """Create a yapf linter."""
+ super(YapfLinter, self).__init__("yapf", "yapf 0.16.0")
+
+ def get_lint_version_cmd_args(self):
+ # type: () -> List[str]
+ """Get the command to run a linter version check."""
+ return ["--version"]
+
+ def needs_file_diff(self):
+ # type: () -> bool
+ """See comment in base class."""
+ return True
+
+ def get_lint_cmd_args(self, file_name):
+ # type: (str) -> List[str]
+ """Get the command to run a linter."""
+ return [file_name]
+
+ def get_fix_cmd_args(self, file_name):
+ # type: (str) -> List[str]
+ """Get the command to run a linter fix."""
+ return ["-i", file_name]