diff --git a/.flake8 b/.flake8 index b690bb7e..5e77c826 100644 --- a/.flake8 +++ b/.flake8 @@ -9,4 +9,4 @@ exclude = migrations, max-line-length = 99 -extend-ignore = F401, E402 +extend-ignore = F401, E402, D10 diff --git a/functions/event/extra_features.py b/functions/event/extra_features.py index a5d60fc0..0d9ee78f 100644 --- a/functions/event/extra_features.py +++ b/functions/event/extra_features.py @@ -10,9 +10,7 @@ async def add_events_to_user(call: CallbackQuery, event_id: int) -> None: - """ - Функция, сохраняющая id мероприятий, которые лайкнул пользователь - """ + """Function that stores id's of events liked by a user.""" user = await db_commands.select_user(telegram_id=call.from_user.id) event_list = user.events @@ -23,16 +21,12 @@ async def add_events_to_user(call: CallbackQuery, event_id: int) -> None: async def check_availability_on_event() -> bool: - """ - Функция, которая проверяет наличие свободных мест на мероприятие - """ + """Function that checks the availability of seats for an event.""" ... async def check_event_date(telegram_id: int) -> None: - """ - Функция, которая проверяет - прошло мероприятие или нет - """ + """Function that checks whether an event has passed or not.""" event = await db_commands.select_user_meetings(telegram_id) event_time = event.time_event if event_time is None: @@ -60,9 +54,7 @@ async def check_event_date(telegram_id: int) -> None: async def create_form( form_owner: int, chat_id: int, call: CallbackQuery, view: Union[bool, None] = True ) -> None: - """ - Функция, которая заполняет анкету текстом - """ + """ Function that fills the form with text.""" try: owner = await db_commands.select_user_meetings(telegram_id=form_owner) document = { @@ -89,9 +81,7 @@ async def create_form( async def get_next_random_event_id(telegram_id: int) -> Optional[int]: - """ - Функция, возвращающая случайный id мероприятия, созданного другим пользователем - """ + """Function that returns a random id of an event created by another user.""" event_ids = await db_commands.search_event_forms() other_events_ids = [] diff --git a/functions/main_app/auxiliary_tools.py b/functions/main_app/auxiliary_tools.py index b4f2a27e..56e268cb 100644 --- a/functions/main_app/auxiliary_tools.py +++ b/functions/main_app/auxiliary_tools.py @@ -42,9 +42,7 @@ async def delete_message(message: Message) -> None: async def choice_gender(call: CallbackQuery) -> None: - """ - Функция, сохраняющая в базу пол, который выбрал пользователь - """ + """Function that saves to the database the gender that the user has selected.""" sex_mapping = {"male": "Мужской", "female": "Женский"} selected_sex = sex_mapping.get(call.data) @@ -59,9 +57,7 @@ async def choice_gender(call: CallbackQuery) -> None: async def display_profile(call: CallbackQuery, markup: InlineKeyboardMarkup) -> None: - """ - Функция для отображения профиля пользователя - """ + """Function for displaying the user profile.""" user = await db_commands.select_user(telegram_id=call.from_user.id) count_referrals = await db_commands.count_all_users_kwarg( referrer_id=call.from_user.id @@ -205,9 +201,7 @@ async def finished_registration( async def saving_normal_photo( message: Message, telegram_id: int, file_id: int, state: FSMContext ) -> None: - """ - Функция, сохраняющая фотографию пользователя без цензуры - """ + """Функция, сохраняющая фотографию пользователя без цензуры.""" try: await db_commands.update_user_data(telegram_id=telegram_id, photo_id=file_id) @@ -233,9 +227,7 @@ async def saving_censored_photo( flag: Optional[str] = "registration", markup: Union[InlineKeyboardMarkup, None] = None, ) -> None: - """ - Функция, сохраняющая фотографию пользователя с цензурой - """ + """.Функция, сохраняющая фотографию пользователя с цензурой.""" photo = InputFile(out_path) id_photo = await bot.send_photo( chat_id=telegram_id, @@ -274,9 +266,7 @@ async def saving_censored_photo( async def update_normal_photo( message: Message, telegram_id: int, file_id: int, state: FSMContext, markup ) -> None: - """ - Функция, которая обновляет фотографию пользователя - """ + """Функция, которая обновляет фотографию пользователя.""" try: await db_commands.update_user_data(telegram_id=telegram_id, photo_id=file_id) await message.answer( diff --git a/functions/main_app/determin_location.py b/functions/main_app/determin_location.py index a333a82d..aaee7720 100644 --- a/functions/main_app/determin_location.py +++ b/functions/main_app/determin_location.py @@ -18,10 +18,7 @@ async def update_user_data(self: "Location", message: Message): class Location(AsyncObj): - """ - Класс для определения и сохранения локации пользователя - в различных сценариях. - """ + """Class for defining and saving the user's location in various scenarios.""" async def __ainit__( self, message: Message, strategy: Type[UserDataUpdateStrategy] diff --git a/keyboards/inline/calendar.py b/keyboards/inline/calendar.py index 17316e2f..aad0a022 100644 --- a/keyboards/inline/calendar.py +++ b/keyboards/inline/calendar.py @@ -41,7 +41,8 @@ async def start_calendar( self, year: int = datetime.now().year, month: int = datetime.now().month ) -> InlineKeyboardMarkup: """ - Creates an inline keyboard with the provided year and month + Create an inline keyboard with the provided year and month. + :param int year: Year to use in the calendar, if None the current year is used. :param int month: Month to use in the calendar, if None the current month is used. :return: Returns InlineKeyboardMarkup object with the calendar. @@ -119,8 +120,11 @@ async def process_selection( self, query: CallbackQuery, data: CallbackData ) -> tuple: """ - Process the callback_query. This method generates a new calendar if forward or - backward is pressed. This method should be called inside a CallbackQueryHandler. + Process the callback_query. + + This method generates a new calendar if forward or backward is pressed. + This method should be called inside a CallbackQueryHandler. + :param query: callback_query, as provided by the CallbackQueryHandler :param data: callback_data, dictionary, set by calendar_callback :return: Returns a tuple (Boolean,datetime), indicating if a date is selected diff --git a/utils/db_api/db_commands.py b/utils/db_api/db_commands.py index b860482c..48d6e13a 100644 --- a/utils/db_api/db_commands.py +++ b/utils/db_api/db_commands.py @@ -232,9 +232,7 @@ def select_setting_tech_work(): @sync_to_async def check_returned_event_id(telegram_id: int, id_of_events_seen: int) -> bool: - """ - Функция, проверяющая, был ли ранее возвращен данный event_id для данного telegram_id - """ + """Function that checks if the given event_id was previously returned for the given telegram_id.""" returned_event = User.objects.filter(telegram_id=telegram_id).first() event_list = returned_event.id_of_events_seen @@ -243,9 +241,7 @@ def check_returned_event_id(telegram_id: int, id_of_events_seen: int) -> bool: @sync_to_async def add_returned_event_id(telegram_id: int, id_of_events_seen: int): - """ - Функция, добавляющая возвращенный event_id для данного telegram_id в базу данных - """ + """Function that adds the returned event_id for the given telegram_id to the database.""" returned_event, created = User.objects.get_or_create(telegram_id=telegram_id) returned_event.id_of_events_seen.append(id_of_events_seen) returned_event.save() diff --git a/utils/misc/AsyncObj.py b/utils/misc/AsyncObj.py index 1fd7a277..c9d2a07e 100644 --- a/utils/misc/AsyncObj.py +++ b/utils/misc/AsyncObj.py @@ -5,17 +5,19 @@ class AsyncObj: def __init__(self, *args, **kwargs): """ - Standard constructor used for arguments pass - Do not override. Use __ainit__ instead + Init. + + Standard constructor used for arguments pass. + Do not override. Use __ainit__ instead. """ self.__stored_args = args, kwargs self.async_initialized = False async def __ainit__(self, *args, **kwargs) -> None: - """Async constructor, you should implement this""" + """Async constructor, you should implement this.""" async def __initobj(self) -> "AsyncObj": - """Crutch used for __await__ after spawning""" + """Crutch used for __await__ after spawning.""" assert not self.async_initialized self.async_initialized = True # pass the parameters to __ainit__ that passed to __init__ diff --git a/utils/misc/profanityFilter.py b/utils/misc/profanityFilter.py index 0850bfd6..85ab7ee9 100644 --- a/utils/misc/profanityFilter.py +++ b/utils/misc/profanityFilter.py @@ -3,7 +3,9 @@ def censored_message(message) -> str: """ - This function working only with english words + Get censored message. + + This function only works with English words. """ censored_text = profanity.censor(message) return censored_text diff --git a/utils/misc/throttling.py b/utils/misc/throttling.py index 3a677e1e..52dc5425 100644 --- a/utils/misc/throttling.py +++ b/utils/misc/throttling.py @@ -1,5 +1,7 @@ def rate_limit(limit: int, key=None): """ + Rate limit decorator. + Decorator for configuring rate limit and key in different functions. :param limit: diff --git a/utils/yoomoney/types/account_info.py b/utils/yoomoney/types/account_info.py index 4ad2d27d..ec9272ec 100644 --- a/utils/yoomoney/types/account_info.py +++ b/utils/yoomoney/types/account_info.py @@ -17,7 +17,8 @@ class LinkedCard(BaseModel): class AccountInfo(BaseModel): """ - Получение информации о состоянии счета пользователя + Получение информации о состоянии счета пользователя. + https://yoomoney.ru/docs/wallet/user-account/account-info """ diff --git a/utils/yoomoney/types/operation_details.py b/utils/yoomoney/types/operation_details.py index 82b27bce..571a1916 100644 --- a/utils/yoomoney/types/operation_details.py +++ b/utils/yoomoney/types/operation_details.py @@ -6,7 +6,8 @@ class OperationDetails(BaseModel): """ - Детальная информация об операции из истории + Детальная информация об операции из истории. + https://yoomoney.ru/docs/wallet/user-account/operation-details """ diff --git a/utils/yoomoney/types/operation_history.py b/utils/yoomoney/types/operation_history.py index fa80497c..116c7567 100644 --- a/utils/yoomoney/types/operation_history.py +++ b/utils/yoomoney/types/operation_history.py @@ -6,7 +6,8 @@ class Operation(BaseModel): """ - Описание платежной операции + Описание платежной операции. + https://yoomoney.ru/docs/wallet/user-account/operation-history#response-operation """ diff --git a/utils/yoomoney/wallet.py b/utils/yoomoney/wallet.py index ec27207b..5f5d7b32 100644 --- a/utils/yoomoney/wallet.py +++ b/utils/yoomoney/wallet.py @@ -31,6 +31,7 @@ async def get_operation_history( ) -> list[Operation, ...]: """ Получение последних 30 операций. + На 10.03.2023 API yoomoney напросто игнорирует указанные в документации параметры https://yoomoney.ru/docs/payment-buttons/using-api/forms?lang=ru#parameters