Start using Hacking

Instead of blacklisting Hacking globally,
only blacklist those that currently occur frequently
(for a later followup patch), and fix the rest. In
detail:

H101  Use TODO(NAME)
H201  no 'except:' at least use 'except Exception:'
H231  octal number 022 should be written as 0o22
H401  docstring should not start with a space
H701  Empty localization string

Change-Id: Ib3b3d56b68d1cf15d3b67ac9749fcbdb876dc52a
This commit is contained in:
Dirk Mueller 2013-06-20 20:36:59 +02:00
parent cbc29e43be
commit 8aba2d602e
19 changed files with 31 additions and 31 deletions

View File

@ -101,7 +101,7 @@ class SwiftRecon(object):
self.server_type = 'object'
def _gen_stats(self, stats, name=None):
""" compute various stats from a list of values """
"""Compute various stats from a list of values."""
cstats = [x for x in stats if x is not None]
if len(cstats) > 0:
ret_dict = {'low': min(cstats), 'high': max(cstats),

View File

@ -43,7 +43,7 @@ def main():
try:
os.mkdir(lock_dir)
except OSError as e:
logger.critical(_(str(e)))
logger.critical(str(e))
print str(e)
sys.exit(1)
try:

View File

@ -94,8 +94,8 @@ class AccountReaper(Daemon):
return self.object_ring
def run_forever(self, *args, **kwargs):
"""
Main entry point when running the reaper in its normal daemon mode.
"""Main entry point when running the reaper in normal daemon mode.
This repeatedly calls :func:`reap_once` no quicker than the
configuration interval.
"""

View File

@ -332,7 +332,7 @@ class DatabaseBroker(object):
except sqlite3.DatabaseError:
try:
conn.close()
except:
except Exception:
pass
self.possibly_quarantine(*sys.exc_info())
except (Exception, Timeout):

View File

@ -611,7 +611,7 @@ class Server():
pid = self.spawn(conf_file, **kwargs)
except OSError, e:
if e.errno == errno.ENOENT:
# TODO: should I check if self.cmd exists earlier?
#TODO(clayg): should I check if self.cmd exists earlier?
print _("%s does not exist") % self.cmd
break
pids[pid] = conf_file

View File

@ -178,7 +178,7 @@ class MemcacheRing(object):
server, e, action='connecting', sock=sock)
def _return_conn(self, server, fp, sock):
""" Returns a server connection to the pool """
"""Returns a server connection to the pool."""
self._client_cache[server].append((fp, sock))
def set(self, key, value, serialize=True, timeout=0, time=0,

View File

@ -155,7 +155,7 @@ class KeystoneAuth(object):
def _authorize_cross_tenant(self, user_id, user_name,
tenant_id, tenant_name, roles):
""" Check cross-tenant ACLs
"""Check cross-tenant ACLs.
Match tenant:user, tenant and user could be its id, name or '*'

View File

@ -335,7 +335,7 @@ class FallocateWrapper(object):
"libc. Leaving as a no-op."))
def __call__(self, fd, mode, offset, length):
""" The length parameter must be a ctypes.c_uint64 """
"""The length parameter must be a ctypes.c_uint64."""
if FALLOCATE_RESERVE > 0:
st = os.fstatvfs(fd)
free = st.f_frsize * st.f_bavail - length.value
@ -1020,7 +1020,7 @@ def drop_privileges(user):
except OSError:
pass
os.chdir('/') # in case you need to rmdir on where you started the daemon
os.umask(022) # ensure files are created with the correct privileges
os.umask(0o22) # ensure files are created with the correct privileges
def capture_stdio(logger, **kwargs):

View File

@ -165,11 +165,11 @@ def get_socket(conf, default_port=8080):
if hasattr(socket, 'TCP_KEEPIDLE'):
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 600)
if warn_ssl:
ssl_warning_message = 'WARNING: SSL should only be enabled for ' \
'testing purposes. Use external SSL ' \
'termination for a production deployment.'
ssl_warning_message = _('WARNING: SSL should only be enabled for '
'testing purposes. Use external SSL '
'termination for a production deployment.')
get_logger(conf).warning(ssl_warning_message)
print _(ssl_warning_message)
print(ssl_warning_message)
return sock
@ -224,7 +224,7 @@ def run_server(conf, logger, sock):
pool.waitall()
# TODO: pull more pieces of this to test more
#TODO(clayg): pull more pieces of this to test more
def run_wsgi(conf_path, app_section, *args, **kwargs):
"""
Runs the server using the specified number of workers.

View File

@ -107,7 +107,7 @@ class ObjectUpdater(Daemon):
time.sleep(self.interval - elapsed)
def run_once(self, *args, **kwargs):
"""Run the updater once"""
"""Run the updater once."""
self.logger.info(_('Begin object update single threaded sweep'))
begin = time.time()
self.successes = 0

View File

@ -804,7 +804,7 @@ class ObjectController(Controller):
return conn
elif resp.status == HTTP_INSUFFICIENT_STORAGE:
self.error_limit(node, _('ERROR Insufficient Storage'))
except:
except Exception:
self.exception_occurred(node, _('Object'),
_('Expect: 100-continue on %s') % path)

View File

@ -2,7 +2,7 @@
pep8==1.4.5
pyflakes==0.7.2
flake8==2.0
hacking>=0.5.6,<0.6
coverage
nose
nosexcover

View File

@ -28,7 +28,7 @@ commands =
commands = {posargs}
[flake8]
ignore = H
ignore = H203,H301,H302,H306,H402,H404,H702,H703
builtins = _
exclude = .venv,.tox,dist,doc,test,*egg
show-source = True