flake8 pass

- fix test_empty_embed not actually reporting on empty embeds
This commit is contained in:
Luna 2019-10-25 08:06:26 -03:00
parent 1accbba002
commit 0cc1062c52
7 changed files with 16 additions and 17 deletions

View File

@ -64,7 +64,7 @@ async def register():
j = await request.get_json() j = await request.get_json()
if not "password" in j: if "password" not in j:
# we need a password to generate a token. # we need a password to generate a token.
# passwords are optional, so # passwords are optional, so
j["password"] = "default_password" j["password"] = "default_password"

View File

@ -259,7 +259,7 @@ async def patch_me():
user_id, user_id,
) )
if user["email"] is None and not "new_password" in j: if user["email"] is None and "new_password" not in j:
raise BadRequest("missing password", {"password": "Please set a password."}) raise BadRequest("missing password", {"password": "Please set a password."})
if "new_password" in j and j["new_password"]: if "new_password" in j and j["new_password"]:

View File

@ -25,6 +25,10 @@ from logbook import Logger
log = Logger(__name__) log = Logger(__name__)
def _identity(_self, x):
return x
class Dispatcher: class Dispatcher:
"""Pub/Sub backend dispatcher. """Pub/Sub backend dispatcher.
@ -33,9 +37,8 @@ class Dispatcher:
subclasses have them implemented. subclasses have them implemented.
""" """
# the _ parameter is for (self) KEY_TYPE = _identity
KEY_TYPE = lambda _, x: x VAL_TYPE = _identity
VAL_TYPE = lambda _, x: x
def __init__(self, main): def __init__(self, main):
#: main EventDispatcher #: main EventDispatcher

View File

@ -45,7 +45,7 @@ async def task_wrapper(name: str, coro):
await coro await coro
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass
except: except Exception:
log.exception("{} task error", name) log.exception("{} task error", name)

View File

@ -170,7 +170,7 @@ async def apply_migration(app, migration: Migration) -> bool:
log.info("applied {} {}", migration.id, migration.name) log.info("applied {} {}", migration.id, migration.name)
return True return True
except: except Exception:
log.exception("failed to run migration, rollbacking log") log.exception("failed to run migration, rollbacking log")
await _delete_log(app, migration.id) await _delete_log(app, migration.id)

View File

@ -30,20 +30,16 @@ def valid(embed: dict):
try: try:
validate_embed(embed) validate_embed(embed)
return True return True
except: except Exception:
return False return False
def invalid(embed): def invalid(embed):
try: return not valid(embed)
validate_embed(embed)
return False
except:
return True
def test_empty_embed(): def test_empty_embed():
valid({}) assert valid({})
def test_basic_embed(): def test_basic_embed():