Skip to content

Commit

Permalink
Flake8 tweaks for issue #346
Browse files Browse the repository at this point in the history
- The default flake8 was currently bumped (as we're not pinning a
  specific version in setup.py) and it brought with it a few new style
  checks.

- Fix all instances of E722 (don't use bare except:)

- Ignore E741 (single letter variable names)

- Pin flake8 to this new version in setup.py so we don't hit another
  change
  • Loading branch information
jrgp committed Jan 2, 2018
1 parent f104b1c commit 0517588
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -57,7 +57,7 @@
'pytest==3.0.5',
'pytest-mock==1.5.0',
'pytest-cov',
'flake8',
'flake8==3.5.0',
'tox',
'requests-mock==1.1.0',
],
Expand Down
10 changes: 5 additions & 5 deletions src/iris/api.py
Expand Up @@ -1850,15 +1850,15 @@ def on_post(self, req, resp):
s = socket.create_connection(sender_addr)

# Then try slaves
except:
except Exception:
if self.coordinator:
logger.exception('Failed contacting master (%s). Resorting to slaves.', sender_addr)
for slave_address in self.coordinator.get_current_slaves():
try:
logger.info('Trying slave %s..', slave_address)
s = socket.create_connection(slave_address)
break
except:
except Exception:
logger.exception('Failed reaching slave %s', slave_address)

# If none of that works, bail
Expand Down Expand Up @@ -3646,14 +3646,14 @@ def on_post(self, req, resp, username):
try:
cursor.execute('SELECT `id` FROM `mode` WHERE `name` = %s', params['src_mode'])
src_mode_id = cursor.fetchone()['id']
except:
except Exception:
msg = 'Invalid source mode.'
logger.exception(msg)
raise HTTPBadRequest(msg, msg)
try:
cursor.execute('SELECT `id` FROM `mode` WHERE `name` = %s', params['dst_mode'])
dst_mode_id = cursor.fetchone()['id']
except:
except Exception:
msg = 'Invalid destination mode.'
logger.exception(msg)
raise HTTPBadRequest(msg, msg)
Expand Down Expand Up @@ -3738,7 +3738,7 @@ def on_get(self, req, resp):
try:
with open(self.healthcheck_path) as f:
health = f.readline().strip()
except:
except Exception:
raise HTTPNotFound()
resp.status = HTTP_200
resp.content_type = 'text/plain'
Expand Down
2 changes: 1 addition & 1 deletion src/iris/role_lookup/__init__.py
Expand Up @@ -19,7 +19,7 @@ def get_role_lookups(config):
imported_modules.append(
import_custom_module('iris.role_lookup', m)(config))
logger.info('Loaded lookup modules: %s', m)
except:
except Exception:
logger.exception('Failed to load role lookup module: %s', m)

return imported_modules
2 changes: 1 addition & 1 deletion src/iris/sender/cache.py
Expand Up @@ -447,7 +447,7 @@ def init(api_host, config):
re = iris_client.get('target_roles')
if re.status_code == 200:
break
except:
except Exception:
pass
api_chk_cnt += 1
logger.warning(
Expand Down
2 changes: 1 addition & 1 deletion src/iris/sphinx_extension.py
Expand Up @@ -32,7 +32,7 @@ def get_routes(app):
if handler.__getattribute__('func_name') == 'method_not_allowed':
# method not defined for route
continue
except:
except Exception:
pass
yield method, curr_node.uri_template, handler

Expand Down
4 changes: 2 additions & 2 deletions src/iris/vendors/iris_smtp.py
Expand Up @@ -145,7 +145,7 @@ def send_email(self, message, customizations=None):

try:
conn.quit()
except:
except Exception:
pass

# If we can't send it, try reconnecting and then sending it one more time before
Expand Down Expand Up @@ -180,7 +180,7 @@ def cleanup(self):
logger.info('Trying to quit smtp connection to %s', self.last_conn_server)
try:
self.last_conn.quit()
except:
except Exception:
pass

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -4,7 +4,7 @@ envlist = py27
[flake8]
exclude = .tox,./build
filename = *.py
ignore = E501,E101
ignore = E501,E101,E741

[testenv]
deps =
Expand Down

0 comments on commit 0517588

Please sign in to comment.