Re-enable flake8

The line in tox.ini "select=H231" did not add H231 to the list of flake8
checks. It made us only run H231.

Remove the H231 line and then fix the flake8 issues. The most
substantial of these was the shadowing of the queue module with local
variables named queue. Made that one import queue as queue_mod because
changing the variable names in the code was yuckier to look at.

Change-Id: I4a26a20889132f7f4525b17392088dda6bd5bbd2
This commit is contained in:
Monty Taylor 2016-11-08 11:57:04 -06:00
parent 55ab77bcb6
commit 616d56bc62
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
6 changed files with 19 additions and 19 deletions

View File

@ -27,9 +27,9 @@ from gear import constants
from gear.acl import ACLError, ACLEntry, ACL # noqa from gear.acl import ACLError, ACLEntry, ACL # noqa
try: try:
import Queue as queue import Queue as queue_mod
except ImportError: except ImportError:
import queue as queue import queue as queue_mod
try: try:
import statsd import statsd
@ -608,8 +608,8 @@ class Packet(object):
if not isinstance(other, Packet): if not isinstance(other, Packet):
return False return False
if (self.code == other.code and if (self.code == other.code and
self.ptype == other.ptype and self.ptype == other.ptype and
self.data == other.data): self.data == other.data):
return True return True
return False return False
@ -1286,7 +1286,7 @@ class BaseClient(BaseClientServer):
except Exception: except Exception:
self.log.exception("Exception while sending packet %s to %s" % self.log.exception("Exception while sending packet %s to %s" %
(packet, connection)) (packet, connection))
# If we can't send the packet, discard the connection # If we can't send the packet, discard the connection
self._lostConnection(connection) self._lostConnection(connection)
raise raise
@ -1718,7 +1718,7 @@ class Worker(BaseClient):
self.functions = {} self.functions = {}
self.job_lock = threading.Lock() self.job_lock = threading.Lock()
self.waiting_for_jobs = 0 self.waiting_for_jobs = 0
self.job_queue = queue.Queue() self.job_queue = queue_mod.Queue()
def __repr__(self): def __repr__(self):
return '<gear.Worker 0x%x>' % id(self) return '<gear.Worker 0x%x>' % id(self)
@ -1885,7 +1885,7 @@ class Worker(BaseClient):
try: try:
job = self.job_queue.get(False) job = self.job_queue.get(False)
except queue.Empty: except queue_mod.Empty:
job = None job = None
if not job: if not job:
@ -2046,7 +2046,7 @@ class BaseJob(object):
def __init__(self, name, arguments, unique=None, handle=None): def __init__(self, name, arguments, unique=None, handle=None):
self.name = convert_to_bytes(name) self.name = convert_to_bytes(name)
if (not isinstance(arguments, bytes) and if (not isinstance(arguments, bytes) and
not isinstance(arguments, bytearray)): not isinstance(arguments, bytearray)):
raise TypeError("arguments must be of type bytes or bytearray") raise TypeError("arguments must be of type bytes or bytearray")
self.arguments = arguments self.arguments = arguments
self.unique = convert_to_bytes(unique) self.unique = convert_to_bytes(unique)
@ -2972,9 +2972,10 @@ class Server(BaseClientServer):
def handleStatus(self, request): def handleStatus(self, request):
functions = self._getFunctionStats() functions = self._getFunctionStats()
for name, values in functions.items(): for name, values in functions.items():
request.connection.sendRaw(("%s\t%s\t%s\t%s\n" % request.connection.sendRaw(
(name.decode('utf-8'), values[0], values[1], ("%s\t%s\t%s\t%s\n" %
values[2])).encode('utf8')) (name.decode('utf-8'), values[0], values[1],
values[2])).encode('utf8'))
request.connection.sendRaw(b'.\n') request.connection.sendRaw(b'.\n')
def handleWorkers(self, request): def handleWorkers(self, request):
@ -2999,7 +3000,7 @@ class Server(BaseClientServer):
for connection in self.active_connections: for connection in self.active_connections:
if connection.state == 'SLEEP': if connection.state == 'SLEEP':
if ((job and job.name in connection.functions) or if ((job and job.name in connection.functions) or
(job is None)): (job is None)):
connection.changeState("AWAKE") connection.changeState("AWAKE")
connection.sendPacket(p) connection.sendPacket(p)

View File

@ -56,8 +56,8 @@ class ACLEntry(object):
:returns: False if any permission is granted, otherwise True. :returns: False if any permission is granted, otherwise True.
""" """
if (self.register is None and if (self.register is None and
self.invoke is None and self.invoke is None and
self.grant is False): self.grant is False):
return True return True
return False return False

View File

@ -66,8 +66,8 @@ support.
parser.add_argument('--keepalive-idle', dest='tcp_keepidle', type=int, parser.add_argument('--keepalive-idle', dest='tcp_keepidle', type=int,
default=7200, action='store', default=7200, action='store',
help='TCP keepalive idle time') help='TCP keepalive idle time')
parser.add_argument('--keepalive-interval', dest='tcp_keepintvl', type=int, parser.add_argument('--keepalive-interval', dest='tcp_keepintvl',
default=75, action='store', type=int, default=75, action='store',
help='TCP keepalive probe interval') help='TCP keepalive probe interval')
parser.add_argument('--keepalive-count', dest='tcp_keepcnt', type=int, parser.add_argument('--keepalive-count', dest='tcp_keepcnt', type=int,
default=9, action='store', default=9, action='store',

View File

@ -41,7 +41,7 @@ types = {
2: 'CANT_DO', 2: 'CANT_DO',
3: 'RESET_ABILITIES', 3: 'RESET_ABILITIES',
4: 'PRE_SLEEP', 4: 'PRE_SLEEP',
#unused # unused
6: 'NOOP', 6: 'NOOP',
7: 'SUBMIT_JOB', 7: 'SUBMIT_JOB',
8: 'JOB_CREATED', 8: 'JOB_CREATED',

View File

@ -62,7 +62,7 @@ class AdminRequestTestCase(tests.BaseTestCase):
def test_partial_packet(self): def test_partial_packet(self):
req = gear.StatusAdminRequest() req = gear.StatusAdminRequest()
for i in range(len(self.response)-len(self.remainder)): for i in range(len(self.response) - len(self.remainder)):
ret = req.isComplete(self.response[:i]) ret = req.isComplete(self.response[:i])
self.assertFalse(ret[0]) self.assertFalse(ret[0])
self.assertIsNone(ret[1]) self.assertIsNone(ret[1])

View File

@ -31,7 +31,6 @@ exclude = .venv,.tox,dist,doc,*.egg
show-source = true show-source = true
# E123, E125, and H ignored intentionally in this code-base # E123, E125, and H ignored intentionally in this code-base
ignore = E123,E125,H ignore = E123,E125,H
select = H231
[testenv:docs] [testenv:docs]
commands = python setup.py build_sphinx commands = python setup.py build_sphinx