THRIFT-3691 Run flake8 Python style check on Travis-CI
Client: Build (Python)
Patch: Nobuaki Sukegawa

This closes #907
diff --git a/test/crossrunner/__init__.py b/test/crossrunner/__init__.py
index 49025ed..9d0b83a 100644
--- a/test/crossrunner/__init__.py
+++ b/test/crossrunner/__init__.py
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-from .test import test_name
-from .collect import collect_cross_tests, collect_feature_tests
-from .run import TestDispatcher
-from .report import generate_known_failures, load_known_failures
+from .test import test_name  # noqa
+from .collect import collect_cross_tests, collect_feature_tests  # noqa
+from .run import TestDispatcher  # noqa
+from .report import generate_known_failures, load_known_failures  # noqa
diff --git a/test/crossrunner/run.py b/test/crossrunner/run.py
index 3f9aaa4..f522bb1 100644
--- a/test/crossrunner/run.py
+++ b/test/crossrunner/run.py
@@ -37,6 +37,10 @@
 RESULT_TIMEOUT = 128
 RESULT_ERROR = 64
 
+# globals
+ports = None
+stop = None
+
 
 class ExecutionContext(object):
     def __init__(self, cmd, cwd, env, report):
diff --git a/test/crossrunner/setup.cfg b/test/crossrunner/setup.cfg
new file mode 100644
index 0000000..7da1f96
--- /dev/null
+++ b/test/crossrunner/setup.cfg
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 100
diff --git a/test/features/container_limit.py b/test/features/container_limit.py
index beed0c5..a16e364 100644
--- a/test/features/container_limit.py
+++ b/test/features/container_limit.py
@@ -4,7 +4,7 @@
 import sys
 
 from util import add_common_args, init_protocol
-from local_thrift import thrift
+from local_thrift import thrift  # noqa
 from thrift.Thrift import TMessageType, TType
 
 
diff --git a/test/features/setup.cfg b/test/features/setup.cfg
new file mode 100644
index 0000000..7da1f96
--- /dev/null
+++ b/test/features/setup.cfg
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 100
diff --git a/test/features/string_limit.py b/test/features/string_limit.py
index 3c68b3e..695d965 100644
--- a/test/features/string_limit.py
+++ b/test/features/string_limit.py
@@ -4,7 +4,7 @@
 import sys
 
 from util import add_common_args, init_protocol
-from local_thrift import thrift
+from local_thrift import thrift  # noqa
 from thrift.Thrift import TMessageType, TType
 
 
diff --git a/test/features/theader_binary.py b/test/features/theader_binary.py
index 02e010b..451399a 100644
--- a/test/features/theader_binary.py
+++ b/test/features/theader_binary.py
@@ -5,7 +5,7 @@
 import sys
 
 from util import add_common_args
-from local_thrift import thrift
+from local_thrift import thrift  # noqa
 from thrift.Thrift import TMessageType, TType
 from thrift.transport.TSocket import TSocket
 from thrift.transport.TTransport import TBufferedTransport, TFramedTransport
diff --git a/test/features/util.py b/test/features/util.py
index e4997d0..3abbbbd 100644
--- a/test/features/util.py
+++ b/test/features/util.py
@@ -1,7 +1,7 @@
 import argparse
 import socket
 
-from local_thrift import thrift
+from local_thrift import thrift  # noqa
 from thrift.transport.TSocket import TSocket
 from thrift.transport.TTransport import TBufferedTransport, TFramedTransport
 from thrift.transport.THttpClient import THttpClient
diff --git a/test/py.tornado/setup.cfg b/test/py.tornado/setup.cfg
new file mode 100644
index 0000000..ae587c4
--- /dev/null
+++ b/test/py.tornado/setup.cfg
@@ -0,0 +1,3 @@
+[flake8]
+ignore = E402
+max-line-length = 100
diff --git a/test/py.tornado/test_suite.py b/test/py.tornado/test_suite.py
index b9ce781..32d1c2e 100755
--- a/test/py.tornado/test_suite.py
+++ b/test/py.tornado/test_suite.py
@@ -44,7 +44,7 @@
 from thrift.transport.TTransport import TTransportException
 
 from ThriftTest import ThriftTest
-from ThriftTest.ttypes import *
+from ThriftTest.ttypes import Xception, Xtruct
 
 
 class TestHandler(object):
diff --git a/test/py.twisted/setup.cfg b/test/py.twisted/setup.cfg
new file mode 100644
index 0000000..ae587c4
--- /dev/null
+++ b/test/py.twisted/setup.cfg
@@ -0,0 +1,3 @@
+[flake8]
+ignore = E402
+max-line-length = 100
diff --git a/test/py.twisted/test_suite.py b/test/py.twisted/test_suite.py
index 3a59bb1..43149a4 100755
--- a/test/py.twisted/test_suite.py
+++ b/test/py.twisted/test_suite.py
@@ -113,9 +113,8 @@
         self.processor = ThriftTest.Processor(self.handler)
         self.pfactory = TBinaryProtocol.TBinaryProtocolFactory()
 
-        self.server = reactor.listenTCP(0,
-                                        TTwisted.ThriftServerFactory(self.processor,
-                                                                     self.pfactory), interface="127.0.0.1")
+        self.server = reactor.listenTCP(
+            0, TTwisted.ThriftServerFactory(self.processor, self.pfactory), interface="127.0.0.1")
 
         self.portNo = self.server.getHost().port
 
diff --git a/test/py/SerializationTest.py b/test/py/SerializationTest.py
index f4f3a4f..efe3c6d 100755
--- a/test/py/SerializationTest.py
+++ b/test/py/SerializationTest.py
@@ -80,7 +80,7 @@
             vertwo2000=VersioningTestV2(newstruct=Bonk(message='World!', type=314)),
             a_set2500=set(['lazy', 'brown', 'cow']),
             vertwo3000=VersioningTestV2(newset=set([2, 3, 5, 7, 11])),
-            big_numbers=[2**8, 2**16, 2**31 - 1, -(2**31 - 1)]
+            big_numbers=[2 ** 8, 2 ** 16, 2 ** 31 - 1, -(2 ** 31 - 1)]
         )
 
         self.compact_struct = CompactProtoTestStruct(
@@ -160,10 +160,9 @@
             # note, the sets below are sets of chars, since the strings are iterated
             map_int_strset={10: set('abc'), 20: set('def'), 30: set('GHI')},
             map_int_strset_list=[
-            {10: set('abc'), 20: set('def'), 30: set('GHI')},
-            {100: set('lmn'), 200: set('opq'), 300: set('RST')},
-            {1000: set('uvw'), 2000: set('wxy'), 3000: set('XYZ')}
-        ]
+                {10: set('abc'), 20: set('def'), 30: set('GHI')},
+                {100: set('lmn'), 200: set('opq'), 300: set('RST')},
+                {1000: set('uvw'), 2000: set('wxy'), 3000: set('XYZ')}]
         )
 
         self.nested_lists_bonk = NestedListsBonk(
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
index 5de9fa3..18ef66b 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -19,7 +19,6 @@
 # under the License.
 #
 
-import glob
 import os
 import sys
 import time
diff --git a/test/py/TestSyntax.py b/test/py/TestSyntax.py
index c83f40e..dbe7975 100755
--- a/test/py/TestSyntax.py
+++ b/test/py/TestSyntax.py
@@ -20,5 +20,5 @@
 #
 
 # Just import these generated files to make sure they are syntactically valid
-from DebugProtoTest import EmptyService
-from DebugProtoTest import Inherited
+from DebugProtoTest import EmptyService  # noqa
+from DebugProtoTest import Inherited  # noqa
diff --git a/test/py/setup.cfg b/test/py/setup.cfg
new file mode 100644
index 0000000..7da1f96
--- /dev/null
+++ b/test/py/setup.cfg
@@ -0,0 +1,2 @@
+[flake8]
+max-line-length = 100