Skip to content

Commit

Permalink
Decorate wrappers with functools.wraps
Browse files Browse the repository at this point in the history
Fixes missing documentation in decorated handlers

Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
  • Loading branch information
r4rdsn committed Nov 4, 2019
1 parent 0dfcf2f commit 8b8dc1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/handlers/escrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import asyncio
import typing
from decimal import Decimal
from functools import wraps
from time import time

from aiogram import types
Expand Down Expand Up @@ -84,6 +85,7 @@ def escrow_callback_handler(*args, state=any_state, **kwargs):
def decorator(
handler: typing.Callable[[types.CallbackQuery, EscrowOffer], typing.Any]
):
@wraps(handler)
@dp.callback_query_handler(*args, state=state, **kwargs)
async def wrapper(call: types.CallbackQuery):
offer_id = call.data.split()[1]
Expand All @@ -108,6 +110,7 @@ def escrow_message_handler(*args, **kwargs):
def decorator(
handler: typing.Callable[[types.Message, FSMContext, EscrowOffer], typing.Any]
):
@wraps(handler)
@private_handler(*args, **kwargs)
async def wrapper(message: types.Message, state: FSMContext):
offer = await database.escrow.find_one(
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""Handlers for showing orders and reacting to query buttons attached to them."""
import typing
from decimal import Decimal
from functools import wraps
from time import time

import pymongo
Expand Down Expand Up @@ -54,6 +55,7 @@ def order_handler(
Add order of ``OrderType`` to arguments of ``handler``.
"""

@wraps(handler)
async def decorator(call: types.CallbackQuery):
order_id = call.data.split()[1]
order = await database.orders.find_one({'_id': ObjectId(order_id)})
Expand Down

0 comments on commit 8b8dc1a

Please sign in to comment.