aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2017-11-10 15:41:56 -0500
committerMike Frysinger <vapier@google.com>2017-11-10 15:41:56 -0500
commit2ef213ca32302bff97839cee7d58942f8bd244eb (patch)
tree3c4acd7c6776efce6987960bd8431ffb339bb508
parent23e637629cd1be38b999fc0577a08cbe612e207f (diff)
downloadrepohooks-2ef213ca32302bff97839cee7d58942f8bd244eb.tar.gz
address lint warnings after pylint upgrade
Newer pylint 1.6.5 emits warnings not seen with older versions. Tweak the code to get lint clean again. Bug: None Test: ./tools/pylint.py no longer complains Change-Id: Ib2f620ea4c60357430779c42b16d26a3b2ef2ca7
-rwxr-xr-xpre-upload.py3
-rw-r--r--rh/config.py1
-rwxr-xr-xrh/config_unittest.py3
-rw-r--r--rh/git.py1
-rw-r--r--rh/hooks.py1
-rwxr-xr-xrh/hooks_unittest.py6
-rwxr-xr-xrh/shell_unittest.py3
-rw-r--r--rh/terminal.py1
-rw-r--r--rh/utils.py4
-rwxr-xr-xtools/clang-format.py3
-rwxr-xr-xtools/google-java-format.py3
11 files changed, 28 insertions, 1 deletions
diff --git a/pre-upload.py b/pre-upload.py
index fe4cdd8..86f6da0 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -37,6 +37,9 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# We have to import our local modules after the sys.path tweak. We can't use
+# relative imports because this is an executable program, not a module.
+# pylint: disable=wrong-import-position
import rh
import rh.results
import rh.config
diff --git a/rh/config.py b/rh/config.py
index 6a149d7..61f2ef0 100644
--- a/rh/config.py
+++ b/rh/config.py
@@ -28,6 +28,7 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# pylint: disable=wrong-import-position
import rh.hooks
import rh.shell
diff --git a/rh/config_unittest.py b/rh/config_unittest.py
index 9547b74..55d08e9 100755
--- a/rh/config_unittest.py
+++ b/rh/config_unittest.py
@@ -29,6 +29,9 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# We have to import our local modules after the sys.path tweak. We can't use
+# relative imports because this is an executable program, not a module.
+# pylint: disable=wrong-import-position
import rh.hooks
import rh.config
diff --git a/rh/git.py b/rh/git.py
index 8cf2557..fb3f0f4 100644
--- a/rh/git.py
+++ b/rh/git.py
@@ -26,6 +26,7 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# pylint: disable=wrong-import-position
import rh.utils
diff --git a/rh/hooks.py b/rh/hooks.py
index 5d60428..c0071ae 100644
--- a/rh/hooks.py
+++ b/rh/hooks.py
@@ -28,6 +28,7 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# pylint: disable=wrong-import-position
import rh.results
import rh.git
import rh.utils
diff --git a/rh/hooks_unittest.py b/rh/hooks_unittest.py
index ec4d0b3..38a7fc9 100755
--- a/rh/hooks_unittest.py
+++ b/rh/hooks_unittest.py
@@ -18,16 +18,20 @@
from __future__ import print_function
-import mock
import os
import sys
import unittest
+import mock
+
_path = os.path.realpath(__file__ + '/../..')
if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# We have to import our local modules after the sys.path tweak. We can't use
+# relative imports because this is an executable program, not a module.
+# pylint: disable=wrong-import-position
import rh
import rh.hooks
import rh.config
diff --git a/rh/shell_unittest.py b/rh/shell_unittest.py
index bd98ec1..7fc0f91 100755
--- a/rh/shell_unittest.py
+++ b/rh/shell_unittest.py
@@ -28,6 +28,9 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# We have to import our local modules after the sys.path tweak. We can't use
+# relative imports because this is an executable program, not a module.
+# pylint: disable=wrong-import-position
import rh.shell
diff --git a/rh/terminal.py b/rh/terminal.py
index 9eda0ec..686a7ca 100644
--- a/rh/terminal.py
+++ b/rh/terminal.py
@@ -28,6 +28,7 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# pylint: disable=wrong-import-position
import rh.shell
diff --git a/rh/utils.py b/rh/utils.py
index d892358..5328ea7 100644
--- a/rh/utils.py
+++ b/rh/utils.py
@@ -31,6 +31,7 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# pylint: disable=wrong-import-position
import rh.shell
import rh.signals
@@ -340,6 +341,8 @@ def run_command(cmd, error_message=None, redirect_stdout=False,
# Note that tempfiles must be unbuffered else attempts to read
# what a separate process did to that file can result in a bad
# view of the file.
+ # The Popen API accepts either an int or a file handle for stdout/stderr.
+ # pylint: disable=redefined-variable-type
if log_stdout_to_file:
stdout = open(log_stdout_to_file, 'w+')
elif stdout_to_pipe:
@@ -351,6 +354,7 @@ def run_command(cmd, error_message=None, redirect_stdout=False,
stderr = subprocess.STDOUT
elif redirect_stderr:
stderr = _get_tempfile()
+ # pylint: enable=redefined-variable-type
# If subprocesses have direct access to stdout or stderr, they can bypass
# our buffers, so we need to flush to ensure that output is not interleaved.
diff --git a/tools/clang-format.py b/tools/clang-format.py
index 998eb49..55b3f3b 100755
--- a/tools/clang-format.py
+++ b/tools/clang-format.py
@@ -27,6 +27,9 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# We have to import our local modules after the sys.path tweak. We can't use
+# relative imports because this is an executable program, not a module.
+# pylint: disable=wrong-import-position
import rh.shell
import rh.utils
diff --git a/tools/google-java-format.py b/tools/google-java-format.py
index 6796cfc..3e88358 100755
--- a/tools/google-java-format.py
+++ b/tools/google-java-format.py
@@ -28,6 +28,9 @@ if sys.path[0] != _path:
sys.path.insert(0, _path)
del _path
+# We have to import our local modules after the sys.path tweak. We can't use
+# relative imports because this is an executable program, not a module.
+# pylint: disable=wrong-import-position
import rh.shell
import rh.utils