utils: docstring arrangements

This commit is contained in:
Luna 2019-03-20 17:27:35 -03:00
parent c07a1e28bd
commit b0f881f422
1 changed files with 5 additions and 2 deletions

View File

@ -39,6 +39,7 @@ async def async_map(function, iterable: Iterable) -> list:
async def task_wrapper(name: str, coro):
"""Wrap a given coroutine in a task."""
try:
await coro
except asyncio.CancelledError:
@ -136,7 +137,10 @@ def mmh3(inp_str: str, seed: int = 0):
class LitecordJSONEncoder(JSONEncoder):
"""Custom JSON encoder for Litecord."""
def default(self, value: Any):
"""By default, this will try to get the to_json attribute of a given
value being JSON encoded."""
try:
return value.to_json
except AttributeError:
@ -144,8 +148,7 @@ class LitecordJSONEncoder(JSONEncoder):
async def pg_set_json(con):
"""Set JSON and JSONB codecs for an
asyncpg connection."""
"""Set JSON and JSONB codecs for an asyncpg connection."""
await con.set_type_codec(
'json',
encoder=lambda v: json.dumps(v, cls=LitecordJSONEncoder),