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

@ -33,7 +33,7 @@ class EasyEnum(Enum):
class Flags: class Flags:
"""Construct a class that represents a bitfield. """Construct a class that represents a bitfield.
You can use it like this: You can use it like this:
>>> class MyField(Flags): >>> class MyField(Flags):
field_1 = 1 field_1 = 1

View File

@ -25,17 +25,20 @@ 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.
This just declares functions all Dispatcher subclasses This just declares functions all Dispatcher subclasses
can implement. This does not mean all Dispatcher can implement. This does not mean all 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)
@ -201,7 +201,7 @@ def to_update(j: dict, orig: dict, field: str) -> bool:
async def search_result_from_list(rows: List) -> Dict[str, Any]: async def search_result_from_list(rows: List) -> Dict[str, Any]:
"""Generate the end result of the search query, given a list of rows. """Generate the end result of the search query, given a list of rows.
Each row must contain: Each row must contain:
- A bigint on `current_id` - A bigint on `current_id`
- An int (?) on `total_results` - An int (?) on `total_results`

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():