You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by kl...@apache.org on 2018/07/13 20:56:31 UTC

[2/5] mesos git commit: Fixed linting errors that appear with the recently updated pylint.

Fixed linting errors that appear with the recently updated pylint.

As part of this, we needed to remove some unnecessary delegate to
'super' calls that are legal in python2 but not in python3. That said,
they are also unnecessary in python2 so we remove them in both cases.

Specifically, we previously used to override 'main()' in our Python and
JS linters with:

    def main(self, modified_files):
        super(PyLinter, self).main(modified_files)

    def main(self, modified_files):
        super(JsLinter, self).main(modified_files)

However, in python3 this gives us linting errors because such a
delegation is unecessary. Just using the 'main()' function from the base
class is sufficient.

Review: http://reviews.apache.org/r/67910/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6936fb55
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6936fb55
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6936fb55

Branch: refs/heads/master
Commit: 6936fb553b463b99bf4bc07de9067dd9ca16457a
Parents: 4a02bbc
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Fri Jul 13 22:21:00 2018 +0200
Committer: Kevin Klues <kl...@gmail.com>
Committed: Fri Jul 13 22:41:25 2018 +0200

----------------------------------------------------------------------
 support/mesos-style.py         | 15 ++++++---------
 support/python3/mesos-style.py |  6 ------
 2 files changed, 6 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6936fb55/support/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/mesos-style.py b/support/mesos-style.py
index 27ed553..5591be0 100755
--- a/support/mesos-style.py
+++ b/support/mesos-style.py
@@ -188,7 +188,7 @@ class LinterBase(object):
 
         # If file paths are specified, check all file paths that are
         # candidates; else check all candidates.
-        file_paths = modified_files if len(modified_files) > 0 else candidates
+        file_paths = modified_files if modified_files else candidates
 
         # Compute the set intersect of the input file paths and candidates.
         # This represents the reduced set of candidates to run lint on.
@@ -198,7 +198,10 @@ class LinterBase(object):
             candidates_set)
 
         if filtered_candidates_set:
-            plural = '' if len(filtered_candidates_set) == 1 else 's'
+            if len(filtered_candidates_set) == 1:
+                plural = ''
+            else:
+                plural = 's'
             print 'Checking {num_files} {linter} file{plural}'.format(
                 num_files=len(filtered_candidates_set),
                 linter=self.linter_type,
@@ -340,9 +343,6 @@ class JsLinter(LinterBase):
 
         return num_errors
 
-    def main(self, modified_files):
-        return super(JsLinter, self).main(modified_files)
-
 
 class PyLinter(LinterBase):
     """The linter for Python files, uses pylint."""
@@ -406,7 +406,7 @@ class PyLinter(LinterBase):
         filtered_source_files = self.filter_source_files(
             source_dir, source_files)
 
-        if len(filtered_source_files) == 0:
+        if not filtered_source_files:
             return 0
 
         if source_dir in self.source_dirs_to_lint_with_tox:
@@ -442,9 +442,6 @@ class PyLinter(LinterBase):
 
         return num_errors
 
-    def main(self, modified_files):
-        return super(PyLinter, self).main(modified_files)
-
 
 def should_build_virtualenv(modified_files):
     """

http://git-wip-us.apache.org/repos/asf/mesos/blob/6936fb55/support/python3/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/python3/mesos-style.py b/support/python3/mesos-style.py
index 350ef90..09e26a8 100755
--- a/support/python3/mesos-style.py
+++ b/support/python3/mesos-style.py
@@ -344,9 +344,6 @@ class JsLinter(LinterBase):
 
         return num_errors
 
-    def main(self, modified_files):
-        return super(JsLinter, self).main(modified_files)
-
 
 class PyLinter(LinterBase):
     """The linter for Python files, uses pylint."""
@@ -445,9 +442,6 @@ class PyLinter(LinterBase):
 
         return num_errors
 
-    def main(self, modified_files):
-        return super(PyLinter, self).main(modified_files)
-
 
 def should_build_virtualenv(modified_files):
     """