diff --git a/AUTHORS.rst b/AUTHORS.rst index c947fd9f4..942a0e8d3 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -91,6 +91,7 @@ The following wonderful people contributed directly or indirectly to this projec - `Patrick Hofmann `_ - `Paul Larsen `_ - `Pieter Schutz `_ +- `Piraty `_ - `Poolitzer `_ - `Pranjalya Tiwari `_ - `Rahiel Kasim `_ diff --git a/examples/arbitrarycallbackdatabot.py b/examples/arbitrarycallbackdatabot.py index 4615a6e52..17dc93366 100644 --- a/examples/arbitrarycallbackdatabot.py +++ b/examples/arbitrarycallbackdatabot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """This example showcases how PTBs "arbitrary callback data" feature can be used. diff --git a/examples/chatmemberbot.py b/examples/chatmemberbot.py index 10133b3ee..f228d4023 100644 --- a/examples/chatmemberbot.py +++ b/examples/chatmemberbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/contexttypesbot.py b/examples/contexttypesbot.py index cfe485a61..224694a63 100644 --- a/examples/contexttypesbot.py +++ b/examples/contexttypesbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ @@ -66,7 +66,8 @@ class CustomContext(CallbackContext[dict, ChatData, dict]): context = super().from_update(update, dispatcher) if context.chat_data and isinstance(update, Update) and update.effective_message: - context._message_id = update.effective_message.message_id # pylint: disable=W0212 + # pylint: disable=protected-access + context._message_id = update.effective_message.message_id # Remember to return the object return context diff --git a/examples/conversationbot.py b/examples/conversationbot.py index 4e5f62efb..853b44814 100644 --- a/examples/conversationbot.py +++ b/examples/conversationbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/conversationbot2.py b/examples/conversationbot2.py index aef62fe48..9459758e3 100644 --- a/examples/conversationbot2.py +++ b/examples/conversationbot2.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/deeplinking.py b/examples/deeplinking.py index deb74afc6..9e20ba437 100644 --- a/examples/deeplinking.py +++ b/examples/deeplinking.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """Bot that explains Telegram's "Deep Linking Parameters" functionality. diff --git a/examples/echobot.py b/examples/echobot.py index e6954b7a1..2be175028 100644 --- a/examples/echobot.py +++ b/examples/echobot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/errorhandlerbot.py b/examples/errorhandlerbot.py index 08504a6cd..a05497cbf 100644 --- a/examples/errorhandlerbot.py +++ b/examples/errorhandlerbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """This is a very simple example on how one could implement a custom error handler.""" diff --git a/examples/inlinebot.py b/examples/inlinebot.py index 5cbb8dfb1..5bfd90ae4 100644 --- a/examples/inlinebot.py +++ b/examples/inlinebot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/inlinekeyboard.py b/examples/inlinekeyboard.py index a3799d207..717227b06 100644 --- a/examples/inlinekeyboard.py +++ b/examples/inlinekeyboard.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/inlinekeyboard2.py b/examples/inlinekeyboard2.py index 2276238e4..159bf375d 100644 --- a/examples/inlinekeyboard2.py +++ b/examples/inlinekeyboard2.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """Simple inline keyboard bot with multiple CallbackQueryHandlers. diff --git a/examples/nestedconversationbot.py b/examples/nestedconversationbot.py index e00e2fc3d..6d5f66211 100644 --- a/examples/nestedconversationbot.py +++ b/examples/nestedconversationbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/passportbot.py b/examples/passportbot.py index 21bfc1ecd..8a8591997 100644 --- a/examples/passportbot.py +++ b/examples/passportbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/paymentbot.py b/examples/paymentbot.py index a619a7950..60a746029 100644 --- a/examples/paymentbot.py +++ b/examples/paymentbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """Basic example for a bot that can receive payment from user.""" diff --git a/examples/persistentconversationbot.py b/examples/persistentconversationbot.py index e9a2cc47a..7981e6018 100644 --- a/examples/persistentconversationbot.py +++ b/examples/persistentconversationbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/pollbot.py b/examples/pollbot.py index f7521c56e..ecb78d09f 100644 --- a/examples/pollbot.py +++ b/examples/pollbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/rawapibot.py b/examples/rawapibot.py index fed61b3d6..09e7e3a7c 100644 --- a/examples/rawapibot.py +++ b/examples/rawapibot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=W0603 +# pylint: disable=global-statement """Simple Bot to reply to Telegram messages. This is built on the API wrapper, see echobot.py to see the same example built diff --git a/examples/timerbot.py b/examples/timerbot.py index 9643f30ab..1c72fbeb7 100644 --- a/examples/timerbot.py +++ b/examples/timerbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=C0116,W0613 +# pylint: disable=missing-function-docstring, unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/telegram/__main__.py b/telegram/__main__.py index 2e7a7de1d..f6025d6db 100644 --- a/telegram/__main__.py +++ b/telegram/__main__.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=C0114 +# pylint: disable=missing-module-docstring import subprocess import sys from typing import Optional diff --git a/telegram/bot.py b/telegram/bot.py index 7c8d013bd..3d8fea019 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -1,5 +1,6 @@ #!/usr/bin/env python -# pylint: disable=E0611,E0213,E1102,E1101,R0913,R0904 +# pylint: disable=no-name-in-module, no-self-argument, not-callable, no-member, too-many-arguments +# pylint: disable=too-many-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -194,7 +195,7 @@ class Bot(TelegramObject): logger = logging.getLogger(func.__module__) @functools.wraps(func) - def decorator(*args, **kwargs): # type: ignore[no-untyped-def] # pylint: disable=W0613 + def decorator(*args, **kwargs): # type: ignore[no-untyped-def] logger.debug('Entering: %s', func.__name__) result = func(*args, **kwargs) logger.debug(result) @@ -337,7 +338,7 @@ class Bot(TelegramObject): return self._bot @property - def id(self) -> int: # pylint: disable=C0103 + def id(self) -> int: # pylint: disable=invalid-name """:obj:`int`: Unique identifier for this bot.""" return self.bot.id @@ -2087,7 +2088,7 @@ class Bot(TelegramObject): return result # type: ignore[return-value] - def _effective_inline_results( # pylint: disable=R0201 + def _effective_inline_results( # pylint: disable=no-self-use self, results: Union[ Sequence['InlineQueryResult'], Callable[[int], Optional[Sequence['InlineQueryResult']]] @@ -2144,7 +2145,7 @@ class Bot(TelegramObject): return effective_results, next_offset @no_type_check # mypy doesn't play too well with hasattr - def _insert_defaults_for_ilq_results( # pylint: disable=R0201 + def _insert_defaults_for_ilq_results( # pylint: disable=no-self-use self, res: 'InlineQueryResult' ) -> None: """The reason why this method exists is similar to the description of _insert_defaults @@ -2152,7 +2153,7 @@ class Bot(TelegramObject): DEFAULT_NONE to NONE *before* calling to_dict() makes it way easier to drop None entries from the json data. """ - # pylint: disable=W0212 + # pylint: disable=protected-access if hasattr(res, 'parse_mode'): res.parse_mode = DefaultValue.get_value(res.parse_mode) if hasattr(res, 'input_message_content') and res.input_message_content: @@ -3651,7 +3652,7 @@ class Bot(TelegramObject): ) @_log - def answer_shipping_query( # pylint: disable=C0103 + def answer_shipping_query( # pylint: disable=invalid-name self, shipping_query_id: str, ok: bool, @@ -3720,7 +3721,7 @@ class Bot(TelegramObject): return result # type: ignore[return-value] @_log - def answer_pre_checkout_query( # pylint: disable=C0103 + def answer_pre_checkout_query( # pylint: disable=invalid-name self, pre_checkout_query_id: str, ok: bool, @@ -3762,7 +3763,7 @@ class Bot(TelegramObject): """ ok = bool(ok) - if not (ok ^ (error_message is not None)): # pylint: disable=C0325 + if not (ok ^ (error_message is not None)): # pylint: disable=superfluous-parens raise TelegramError( 'answerPreCheckoutQuery: If ok is True, there should ' 'not be error_message; if ok is False, error_message ' @@ -5016,7 +5017,7 @@ class Bot(TelegramObject): question: str, options: List[str], is_anonymous: bool = True, - type: str = Poll.REGULAR, # pylint: disable=W0622 + type: str = Poll.REGULAR, # pylint: disable=redefined-builtin allows_multiple_answers: bool = False, correct_option_id: int = None, is_closed: bool = None, diff --git a/telegram/botcommand.py b/telegram/botcommand.py index cf919c038..68539ad4b 100644 --- a/telegram/botcommand.py +++ b/telegram/botcommand.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 diff --git a/telegram/botcommandscope.py b/telegram/botcommandscope.py index 8ae36cf55..43e868ded 100644 --- a/telegram/botcommandscope.py +++ b/telegram/botcommandscope.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=W0622 +# pylint: disable=redefined-builtin """This module contains objects representing Telegram bot command scopes.""" from typing import Any, Union, Optional, TYPE_CHECKING, Dict, Type diff --git a/telegram/callbackquery.py b/telegram/callbackquery.py index e74025e4c..f337ad871 100644 --- a/telegram/callbackquery.py +++ b/telegram/callbackquery.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=W0622 +# pylint: disable=redefined-builtin """This module contains an object that represents a Telegram CallbackQuery""" from typing import TYPE_CHECKING, Any, List, Optional, Union, Tuple, ClassVar @@ -105,7 +105,7 @@ class CallbackQuery(TelegramObject): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin from_user: User, chat_instance: str, message: Message = None, @@ -116,7 +116,7 @@ class CallbackQuery(TelegramObject): **_kwargs: Any, ): # Required - self.id = id # pylint: disable=C0103 + self.id = id # pylint: disable=invalid-name self.from_user = from_user self.chat_instance = chat_instance # Optionals diff --git a/telegram/chat.py b/telegram/chat.py index 5340f94a1..de5f4fb0d 100644 --- a/telegram/chat.py +++ b/telegram/chat.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=W0622 +# pylint: disable=redefined-builtin # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -229,7 +229,7 @@ class Chat(TelegramObject): **_kwargs: Any, ): # Required - self.id = int(id) # pylint: disable=C0103 + self.id = int(id) # pylint: disable=invalid-name self.type = type # Optionals self.title = title @@ -294,7 +294,7 @@ class Chat(TelegramObject): return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) - from telegram import Message # pylint: disable=C0415 + from telegram import Message # pylint: disable=import-outside-toplevel data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot) data['permissions'] = ChatPermissions.de_json(data.get('permissions'), bot) @@ -1472,7 +1472,7 @@ class Chat(TelegramObject): options: List[str], is_anonymous: bool = True, # We use constant.POLL_REGULAR instead of Poll.REGULAR here to avoid circular imports - type: str = constants.POLL_REGULAR, # pylint: disable=W0622 + type: str = constants.POLL_REGULAR, # pylint: disable=redefined-builtin allows_multiple_answers: bool = False, correct_option_id: int = None, is_closed: bool = None, diff --git a/telegram/chataction.py b/telegram/chataction.py index af5d65561..61afc91bb 100644 --- a/telegram/chataction.py +++ b/telegram/chataction.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 diff --git a/telegram/choseninlineresult.py b/telegram/choseninlineresult.py index 9f9134676..5be9b15ae 100644 --- a/telegram/choseninlineresult.py +++ b/telegram/choseninlineresult.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0902,R0913 +# pylint: disable=too-many-instance-attributes, too-many-arguments # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 diff --git a/telegram/dice.py b/telegram/dice.py index b71e153b2..135f2b877 100644 --- a/telegram/dice.py +++ b/telegram/dice.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 diff --git a/telegram/error.py b/telegram/error.py index 93599c9b8..3ee3770e1 100644 --- a/telegram/error.py +++ b/telegram/error.py @@ -16,7 +16,6 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=C0115 """This module contains an classes that represent Telegram errors.""" from typing import Tuple, Union diff --git a/telegram/ext/basepersistence.py b/telegram/ext/basepersistence.py index 915ff70c6..517297acb 100644 --- a/telegram/ext/basepersistence.py +++ b/telegram/ext/basepersistence.py @@ -113,7 +113,7 @@ class BasePersistence(Generic[UD, CD, BD], ABC): ) def __new__( - cls, *args: object, **kwargs: object # pylint: disable=W0613 + cls, *args: object, **kwargs: object # pylint: disable=unused-argument ) -> 'BasePersistence': """This overrides the get_* and update_* methods to use insert/replace_bot. That has the side effect that we always pass deepcopied data to those methods, so in @@ -209,7 +209,9 @@ class BasePersistence(Generic[UD, CD, BD], ABC): return cls._replace_bot(obj, {}) @classmethod - def _replace_bot(cls, obj: object, memo: Dict[int, object]) -> object: # pylint: disable=R0911 + def _replace_bot( # pylint: disable=too-many-return-statements + cls, obj: object, memo: Dict[int, object] + ) -> object: obj_id = id(obj) if obj_id in memo: return memo[obj_id] @@ -309,7 +311,8 @@ class BasePersistence(Generic[UD, CD, BD], ABC): """ return self._insert_bot(obj, {}) - def _insert_bot(self, obj: object, memo: Dict[int, object]) -> object: # pylint: disable=R0911 + # pylint: disable=too-many-return-statements + def _insert_bot(self, obj: object, memo: Dict[int, object]) -> object: obj_id = id(obj) if obj_id in memo: return memo[obj_id] diff --git a/telegram/ext/callbackcontext.py b/telegram/ext/callbackcontext.py index 73f81d92e..b76b1c2f8 100644 --- a/telegram/ext/callbackcontext.py +++ b/telegram/ext/callbackcontext.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=R0201 +# pylint: disable=no-self-use """This module contains the CallbackContext class.""" from queue import Queue from typing import ( @@ -296,12 +296,12 @@ class CallbackContext(Generic[UD, CD, BD]): if chat: self._chat_id_and_data = ( chat.id, - dispatcher.chat_data[chat.id], # pylint: disable=W0212 + dispatcher.chat_data[chat.id], # pylint: disable=protected-access ) if user: self._user_id_and_data = ( user.id, - dispatcher.user_data[user.id], # pylint: disable=W0212 + dispatcher.user_data[user.id], # pylint: disable=protected-access ) return self diff --git a/telegram/ext/callbackdatacache.py b/telegram/ext/callbackdatacache.py index 010366463..3631bd479 100644 --- a/telegram/ext/callbackdatacache.py +++ b/telegram/ext/callbackdatacache.py @@ -24,7 +24,7 @@ from threading import Lock from typing import Dict, Tuple, Union, Optional, MutableMapping, TYPE_CHECKING, cast from uuid import uuid4 -from cachetools import LRUCache # pylint: disable=E0401 +from cachetools import LRUCache # pylint: disable=import-error from telegram import ( InlineKeyboardMarkup, diff --git a/telegram/ext/contexttypes.py b/telegram/ext/contexttypes.py index ee03037a9..8b905e203 100644 --- a/telegram/ext/contexttypes.py +++ b/telegram/ext/contexttypes.py @@ -16,9 +16,9 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=R0201 +# pylint: disable=no-self-use """This module contains the auxiliary class ContextTypes.""" -from typing import Type, Generic, overload, Dict # pylint: disable=W0611 +from typing import Type, Generic, overload, Dict # pylint: disable=unused-import from telegram.ext.callbackcontext import CallbackContext from telegram.ext.utils.types import CCT, UD, CD, BD diff --git a/telegram/ext/conversationhandler.py b/telegram/ext/conversationhandler.py index 30d96400a..f3a41618d 100644 --- a/telegram/ext/conversationhandler.py +++ b/telegram/ext/conversationhandler.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=R0201 +# pylint: disable=no-self-use """This module contains the ConversationHandler.""" import logging @@ -212,7 +212,7 @@ class ConversationHandler(Handler[Update, CCT]): WAITING: ClassVar[int] = -3 """:obj:`int`: Used as a constant to handle state when a conversation is still waiting on the previous ``@run_sync`` decorated running handler to finish.""" - # pylint: disable=W0231 + # pylint: disable=super-init-not-called def __init__( self, entry_points: List[Handler[Update, CCT]], @@ -511,7 +511,8 @@ class ConversationHandler(Handler[Update, CCT]): ) self.logger.exception("%s", exc) - def check_update(self, update: object) -> CheckUpdateType: # pylint: disable=R0911 + # pylint: disable=too-many-return-statements + def check_update(self, update: object) -> CheckUpdateType: """ Determines whether an update should be handled by this conversationhandler, and if so in which state the conversation currently is. diff --git a/telegram/ext/defaults.py b/telegram/ext/defaults.py index 2b30b3d43..2506e62ca 100644 --- a/telegram/ext/defaults.py +++ b/telegram/ext/defaults.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=R0201 +# pylint: disable=no-self-use """This module contains the class Defaults, which allows to pass default values to Updater.""" from typing import NoReturn, Optional, Dict, Any diff --git a/telegram/ext/dispatcher.py b/telegram/ext/dispatcher.py index b88fa6ebb..3715dacd8 100644 --- a/telegram/ext/dispatcher.py +++ b/telegram/ext/dispatcher.py @@ -259,7 +259,8 @@ class Dispatcher(Generic[CCT, UD, CD, BD]): # For backward compatibility, we allow a "singleton" mode for the dispatcher. When there's # only one instance of Dispatcher, it will be possible to use the `run_async` decorator. with self.__singleton_lock: - if self.__singleton_semaphore.acquire(blocking=False): # pylint: disable=R1732 + # pylint: disable=consider-using-with + if self.__singleton_semaphore.acquire(blocking=False): self._set_singleton(self) else: self._set_singleton(None) @@ -528,7 +529,8 @@ class Dispatcher(Generic[CCT, UD, CD, BD]): """ # Unfortunately due to circular imports this has to be here - from .conversationhandler import ConversationHandler # pylint: disable=C0415 + # pylint: disable=import-outside-toplevel + from .conversationhandler import ConversationHandler if not isinstance(handler, Handler): raise TypeError(f'handler is not an instance of {Handler.__name__}') @@ -628,7 +630,7 @@ class Dispatcher(Generic[CCT, UD, CD, BD]): def add_error_handler( self, callback: Callable[[object, CCT], None], - run_async: Union[bool, DefaultValue] = DEFAULT_FALSE, # pylint: disable=W0621 + run_async: Union[bool, DefaultValue] = DEFAULT_FALSE, ) -> None: """Registers an error handler in the Dispatcher. This handler will receive every error which happens in your bot. See the docs of :meth:`dispatch_error` for more details on how @@ -708,7 +710,10 @@ class Dispatcher(Generic[CCT, UD, CD, BD]): async_kwargs = None if not promise else promise.kwargs if self.error_handlers: - for callback, run_async in self.error_handlers.items(): # pylint: disable=W0621 + for ( + callback, + run_async, + ) in self.error_handlers.items(): # pylint: disable=redefined-outer-name context = self.context_types.context.from_error( update=update, error=error, diff --git a/telegram/ext/extbot.py b/telegram/ext/extbot.py index c43672847..270079e96 100644 --- a/telegram/ext/extbot.py +++ b/telegram/ext/extbot.py @@ -1,5 +1,6 @@ #!/usr/bin/env python -# pylint: disable=E0611,E0213,E1102,C0103,E1101,R0913,R0904 +# pylint: disable=no-name-in-module, no-self-argument, not-callable, invalid-name, no-member +# pylint: disable=too-many-arguments, too-many-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -299,7 +300,7 @@ class ExtBot(telegram.bot.Bot): return updates - def _effective_inline_results( # pylint: disable=R0201 + def _effective_inline_results( # pylint: disable=no-self-use self, results: Union[ Sequence['InlineQueryResult'], Callable[[int], Optional[Sequence['InlineQueryResult']]] diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index e1cfc23e2..7de86934b 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=C0112, C0103, W0221 +# pylint: disable=empty-docstring, invalid-name, arguments-differ """This module contains the Filters for use with the MessageHandler class.""" import re @@ -112,7 +112,8 @@ class BaseFilter(ABC): __slots__ = ('_name', '_data_filter') - def __new__(cls, *args: object, **kwargs: object) -> 'BaseFilter': # pylint: disable=W0613 + # pylint: disable=unused-argument + def __new__(cls, *args: object, **kwargs: object) -> 'BaseFilter': # We do this here instead of in a __init__ so filter don't have to call __init__ or super() instance = super().__new__(cls) instance._name = None @@ -150,7 +151,7 @@ class BaseFilter(ABC): @name.setter def name(self, name: Optional[str]) -> None: - self._name = name # pylint: disable=E0237 + self._name = name # pylint: disable=assigning-non-slot def __repr__(self) -> str: # We do this here instead of in a __init__ so filter don't have to call __init__ or super() @@ -299,7 +300,8 @@ class MergedFilter(UpdateFilter): base[k] = comp_value return base - def filter(self, update: Update) -> Union[bool, DataDict]: # pylint: disable=R0911 + # pylint: disable=too-many-return-statements + def filter(self, update: Update) -> Union[bool, DataDict]: base_output = self.base_filter(update) # We need to check if the filters are data filters and if so return the merged data. # If it's not a data filter or an or_filter but no matches return bool @@ -1523,7 +1525,7 @@ officedocument.wordprocessingml.document")``. raise RuntimeError(f'Cannot set name for Filters.{self.__class__.__name__}') class user(_ChatUserBaseFilter): - # pylint: disable=W0235 + # pylint: disable=useless-super-delegation """Filters messages to allow only those which are from specified user ID(s) or username(s). @@ -1624,7 +1626,7 @@ officedocument.wordprocessingml.document")``. return super().remove_chat_ids(user_id) class via_bot(_ChatUserBaseFilter): - # pylint: disable=W0235 + # pylint: disable=useless-super-delegation """Filters messages to allow only those which are from specified via_bot ID(s) or username(s). @@ -1726,7 +1728,7 @@ officedocument.wordprocessingml.document")``. return super().remove_chat_ids(bot_id) class chat(_ChatUserBaseFilter): - # pylint: disable=W0235 + # pylint: disable=useless-super-delegation """Filters messages to allow only those which are from a specified chat ID or username. Examples: @@ -1809,7 +1811,7 @@ officedocument.wordprocessingml.document")``. return super().remove_chat_ids(chat_id) class forwarded_from(_ChatUserBaseFilter): - # pylint: disable=W0235 + # pylint: disable=useless-super-delegation """Filters messages to allow only those which are forwarded from the specified chat ID(s) or username(s) based on :attr:`telegram.Message.forward_from` and :attr:`telegram.Message.forward_from_chat`. @@ -1902,7 +1904,7 @@ officedocument.wordprocessingml.document")``. return super().remove_chat_ids(chat_id) class sender_chat(_ChatUserBaseFilter): - # pylint: disable=W0235 + # pylint: disable=useless-super-delegation """Filters messages to allow only those which are from a specified sender chat's chat ID or username. diff --git a/telegram/ext/typehandler.py b/telegram/ext/typehandler.py index 97c540aa9..a27441baf 100644 --- a/telegram/ext/typehandler.py +++ b/telegram/ext/typehandler.py @@ -61,7 +61,7 @@ class TypeHandler(Handler[UT, CCT]): def __init__( self, - type: Type[UT], # pylint: disable=W0622 + type: Type[UT], # pylint: disable=redefined-builtin callback: Callable[[UT, CCT], RT], strict: bool = False, run_async: Union[bool, DefaultValue] = DEFAULT_FALSE, @@ -70,8 +70,8 @@ class TypeHandler(Handler[UT, CCT]): callback, run_async=run_async, ) - self.type = type # pylint: disable=E0237 - self.strict = strict # pylint: disable=E0237 + self.type = type # pylint: disable=assigning-non-slot + self.strict = strict # pylint: disable=assigning-non-slot def check_update(self, update: object) -> bool: """Determines whether an update should be passed to this handlers :attr:`callback`. @@ -85,4 +85,4 @@ class TypeHandler(Handler[UT, CCT]): """ if not self.strict: return isinstance(update, self.type) - return type(update) is self.type # pylint: disable=C0123 + return type(update) is self.type # pylint: disable=unidiomatic-typecheck diff --git a/telegram/ext/updater.py b/telegram/ext/updater.py index 5e161403c..7bc936274 100644 --- a/telegram/ext/updater.py +++ b/telegram/ext/updater.py @@ -158,7 +158,7 @@ class Updater(Generic[CCT, UD, CD, BD]): private_key_password: bytes = None, user_sig_handler: Callable = None, request_kwargs: Dict[str, Any] = None, - persistence: 'BasePersistence' = None, # pylint: disable=E0601 + persistence: 'BasePersistence' = None, # pylint: disable=used-before-assignment defaults: 'Defaults' = None, base_file_url: str = None, arbitrary_callback_data: Union[DefaultValue, bool, int, None] = DEFAULT_FALSE, @@ -810,7 +810,7 @@ class Updater(Generic[CCT, UD, CD, BD]): self.user_sig_handler(signum, frame) else: self.logger.warning('Exiting immediately!') - # pylint: disable=C0415,W0212 + # pylint: disable=import-outside-toplevel, protected-access import os os._exit(1) diff --git a/telegram/ext/utils/webhookhandler.py b/telegram/ext/utils/webhookhandler.py index fb69856b8..acaa6cf73 100644 --- a/telegram/ext/utils/webhookhandler.py +++ b/telegram/ext/utils/webhookhandler.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=C0114 +# pylint: disable=missing-module-docstring import logging from queue import Queue @@ -88,7 +88,8 @@ class WebhookServer: return self.loop.add_callback(self.loop.stop) # type: ignore - def handle_error(self, request: object, client_address: str) -> None: # pylint: disable=W0613 + # pylint: disable=unused-argument + def handle_error(self, request: object, client_address: str) -> None: """Handle an error gracefully.""" self.logger.debug( 'Exception happened during processing of request from %s', @@ -108,7 +109,7 @@ class WebhookAppClass(tornado.web.Application): # WebhookHandler, process webhook calls -# pylint: disable=W0223 +# pylint: disable=abstract-method class WebhookHandler(tornado.web.RequestHandler): SUPPORTED_METHODS = ["POST"] # type: ignore @@ -122,7 +123,7 @@ class WebhookHandler(tornado.web.RequestHandler): self.logger = logging.getLogger(__name__) def initialize(self, bot: 'Bot', update_queue: Queue) -> None: - # pylint: disable=W0201 + # pylint: disable=attribute-defined-outside-init self.bot = bot self.update_queue = update_queue diff --git a/telegram/files/inputfile.py b/telegram/files/inputfile.py index 16dcd118a..a4595bb61 100644 --- a/telegram/files/inputfile.py +++ b/telegram/files/inputfile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=W0622,E0611 +# pylint: disable=redefined-builtin, no-name-in-module # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 diff --git a/telegram/files/inputmedia.py b/telegram/files/inputmedia.py index ee6598a72..e96ab7f1b 100644 --- a/telegram/files/inputmedia.py +++ b/telegram/files/inputmedia.py @@ -53,7 +53,7 @@ class InputMedia(TelegramObject): if self.caption_entities: data['caption_entities'] = [ - ce.to_dict() for ce in self.caption_entities # pylint: disable=E1133 + ce.to_dict() for ce in self.caption_entities # pylint: disable=not-an-iterable ] return data diff --git a/telegram/helpers.py b/telegram/helpers.py index 87c83175e..26407689e 100644 --- a/telegram/helpers.py +++ b/telegram/helpers.py @@ -104,7 +104,7 @@ def effective_message_type(entity: Union['Message', 'Update']) -> Optional[str]: """ # Importing on file-level yields cyclic Import Errors - from telegram import Message, Update # pylint: disable=C0415 + from telegram import Message, Update # pylint: disable=import-outside-toplevel if isinstance(entity, Message): message = entity diff --git a/telegram/inline/inlinequery.py b/telegram/inline/inlinequery.py index 24c5323bc..58afb2c6a 100644 --- a/telegram/inline/inlinequery.py +++ b/telegram/inline/inlinequery.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0902,R0913 +# pylint: disable=too-many-instance-attributes, too-many-arguments # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -75,7 +75,7 @@ class InlineQuery(TelegramObject): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin from_user: User, query: str, offset: str, @@ -85,7 +85,7 @@ class InlineQuery(TelegramObject): **_kwargs: Any, ): # Required - self.id = id # pylint: disable=C0103 + self.id = id # pylint: disable=invalid-name self.from_user = from_user self.query = query self.offset = offset diff --git a/telegram/inline/inlinequeryresult.py b/telegram/inline/inlinequeryresult.py index 9566f707a..83354c4ac 100644 --- a/telegram/inline/inlinequeryresult.py +++ b/telegram/inline/inlinequeryresult.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=W0622 +# pylint: disable=redefined-builtin """This module contains the classes that represent Telegram InlineQueryResult.""" from typing import Any @@ -51,7 +51,7 @@ class InlineQueryResult(TelegramObject): def __init__(self, type: str, id: str, **_kwargs: Any): # Required self.type = str(type) - self.id = str(id) # pylint: disable=C0103 + self.id = str(id) # pylint: disable=invalid-name self._id_attrs = (self.id,) @@ -59,7 +59,7 @@ class InlineQueryResult(TelegramObject): """See :meth:`telegram.TelegramObject.to_dict`.""" data = super().to_dict() - # pylint: disable=E1101 + # pylint: disable=no-member if ( hasattr(self, 'caption_entities') and self.caption_entities # type: ignore[attr-defined] diff --git a/telegram/inline/inlinequeryresultarticle.py b/telegram/inline/inlinequeryresultarticle.py index ecc975cc3..9071733c3 100644 --- a/telegram/inline/inlinequeryresultarticle.py +++ b/telegram/inline/inlinequeryresultarticle.py @@ -77,7 +77,7 @@ class InlineQueryResultArticle(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin title: str, input_message_content: 'InputMessageContent', reply_markup: 'ReplyMarkup' = None, diff --git a/telegram/inline/inlinequeryresultaudio.py b/telegram/inline/inlinequeryresultaudio.py index 41d856a81..8620ba519 100644 --- a/telegram/inline/inlinequeryresultaudio.py +++ b/telegram/inline/inlinequeryresultaudio.py @@ -88,7 +88,7 @@ class InlineQueryResultAudio(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin audio_url: str, title: str, performer: str = None, diff --git a/telegram/inline/inlinequeryresultcachedaudio.py b/telegram/inline/inlinequeryresultcachedaudio.py index d4f015f07..5ac874acd 100644 --- a/telegram/inline/inlinequeryresultcachedaudio.py +++ b/telegram/inline/inlinequeryresultcachedaudio.py @@ -79,7 +79,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin audio_file_id: str, caption: str = None, reply_markup: 'ReplyMarkup' = None, diff --git a/telegram/inline/inlinequeryresultcacheddocument.py b/telegram/inline/inlinequeryresultcacheddocument.py index 9e68d00cd..ef83599ac 100644 --- a/telegram/inline/inlinequeryresultcacheddocument.py +++ b/telegram/inline/inlinequeryresultcacheddocument.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=W0622 +# pylint: disable=redefined-builtin """This module contains the classes that represent Telegram InlineQueryResultCachedDocument.""" from typing import TYPE_CHECKING, Any, Union, Tuple, List @@ -88,7 +88,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin title: str, document_file_id: str, description: str = None, diff --git a/telegram/inline/inlinequeryresultcachedgif.py b/telegram/inline/inlinequeryresultcachedgif.py index b8afa6791..d6aac9b2f 100644 --- a/telegram/inline/inlinequeryresultcachedgif.py +++ b/telegram/inline/inlinequeryresultcachedgif.py @@ -85,7 +85,7 @@ class InlineQueryResultCachedGif(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin gif_file_id: str, title: str = None, caption: str = None, diff --git a/telegram/inline/inlinequeryresultcachedmpeg4gif.py b/telegram/inline/inlinequeryresultcachedmpeg4gif.py index e45f5faff..65457fd9b 100644 --- a/telegram/inline/inlinequeryresultcachedmpeg4gif.py +++ b/telegram/inline/inlinequeryresultcachedmpeg4gif.py @@ -85,7 +85,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin mpeg4_file_id: str, title: str = None, caption: str = None, diff --git a/telegram/inline/inlinequeryresultcachedphoto.py b/telegram/inline/inlinequeryresultcachedphoto.py index 33a14f9ac..a0158be94 100644 --- a/telegram/inline/inlinequeryresultcachedphoto.py +++ b/telegram/inline/inlinequeryresultcachedphoto.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=W0622 +# pylint: disable=redefined-builtin """This module contains the classes that represent Telegram InlineQueryResultPhoto""" from typing import TYPE_CHECKING, Any, Union, Tuple, List @@ -89,7 +89,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin photo_file_id: str, title: str = None, description: str = None, diff --git a/telegram/inline/inlinequeryresultcachedsticker.py b/telegram/inline/inlinequeryresultcachedsticker.py index 0425fa5bb..904560150 100644 --- a/telegram/inline/inlinequeryresultcachedsticker.py +++ b/telegram/inline/inlinequeryresultcachedsticker.py @@ -56,7 +56,7 @@ class InlineQueryResultCachedSticker(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin sticker_file_id: str, reply_markup: 'ReplyMarkup' = None, input_message_content: 'InputMessageContent' = None, diff --git a/telegram/inline/inlinequeryresultcachedvideo.py b/telegram/inline/inlinequeryresultcachedvideo.py index 59c546d08..42d3666bf 100644 --- a/telegram/inline/inlinequeryresultcachedvideo.py +++ b/telegram/inline/inlinequeryresultcachedvideo.py @@ -88,7 +88,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin video_file_id: str, title: str, description: str = None, diff --git a/telegram/inline/inlinequeryresultcachedvoice.py b/telegram/inline/inlinequeryresultcachedvoice.py index 329e99090..8a054a1ac 100644 --- a/telegram/inline/inlinequeryresultcachedvoice.py +++ b/telegram/inline/inlinequeryresultcachedvoice.py @@ -82,7 +82,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin voice_file_id: str, title: str, caption: str = None, diff --git a/telegram/inline/inlinequeryresultcontact.py b/telegram/inline/inlinequeryresultcontact.py index df4f6c980..71f79b4fa 100644 --- a/telegram/inline/inlinequeryresultcontact.py +++ b/telegram/inline/inlinequeryresultcontact.py @@ -80,7 +80,7 @@ class InlineQueryResultContact(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin phone_number: str, first_name: str, last_name: str = None, diff --git a/telegram/inline/inlinequeryresultdocument.py b/telegram/inline/inlinequeryresultdocument.py index 9ef24a5f3..fa66ef49a 100644 --- a/telegram/inline/inlinequeryresultdocument.py +++ b/telegram/inline/inlinequeryresultdocument.py @@ -102,7 +102,7 @@ class InlineQueryResultDocument(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin document_url: str, title: str, mime_type: str, diff --git a/telegram/inline/inlinequeryresultgame.py b/telegram/inline/inlinequeryresultgame.py index 02e4a7dd4..367cd1e93 100644 --- a/telegram/inline/inlinequeryresultgame.py +++ b/telegram/inline/inlinequeryresultgame.py @@ -49,14 +49,14 @@ class InlineQueryResultGame(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin game_short_name: str, reply_markup: 'ReplyMarkup' = None, **_kwargs: Any, ): # Required super().__init__('game', id) - self.id = id # pylint: disable=W0622 + self.id = id # pylint: disable=redefined-builtin self.game_short_name = game_short_name self.reply_markup = reply_markup diff --git a/telegram/inline/inlinequeryresultgif.py b/telegram/inline/inlinequeryresultgif.py index 1ce4614cf..caf793d86 100644 --- a/telegram/inline/inlinequeryresultgif.py +++ b/telegram/inline/inlinequeryresultgif.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=W0622 +# pylint: disable=redefined-builtin """This module contains the classes that represent Telegram InlineQueryResultGif.""" from typing import TYPE_CHECKING, Any, Union, Tuple, List @@ -103,7 +103,7 @@ class InlineQueryResultGif(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin gif_url: str, thumb_url: str, gif_width: int = None, diff --git a/telegram/inline/inlinequeryresultlocation.py b/telegram/inline/inlinequeryresultlocation.py index e55d90bfc..6e7be66b2 100644 --- a/telegram/inline/inlinequeryresultlocation.py +++ b/telegram/inline/inlinequeryresultlocation.py @@ -96,7 +96,7 @@ class InlineQueryResultLocation(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin latitude: float, longitude: float, title: str, diff --git a/telegram/inline/inlinequeryresultmpeg4gif.py b/telegram/inline/inlinequeryresultmpeg4gif.py index a57272aaf..2c8745a0e 100644 --- a/telegram/inline/inlinequeryresultmpeg4gif.py +++ b/telegram/inline/inlinequeryresultmpeg4gif.py @@ -102,7 +102,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin mpeg4_url: str, thumb_url: str, mpeg4_width: int = None, diff --git a/telegram/inline/inlinequeryresultphoto.py b/telegram/inline/inlinequeryresultphoto.py index 0f5be4150..19f6f4240 100644 --- a/telegram/inline/inlinequeryresultphoto.py +++ b/telegram/inline/inlinequeryresultphoto.py @@ -98,7 +98,7 @@ class InlineQueryResultPhoto(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin photo_url: str, thumb_url: str, photo_width: int = None, diff --git a/telegram/inline/inlinequeryresultvenue.py b/telegram/inline/inlinequeryresultvenue.py index 4a64a1068..6470ee9c3 100644 --- a/telegram/inline/inlinequeryresultvenue.py +++ b/telegram/inline/inlinequeryresultvenue.py @@ -97,7 +97,7 @@ class InlineQueryResultVenue(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin latitude: float, longitude: float, title: str, diff --git a/telegram/inline/inlinequeryresultvideo.py b/telegram/inline/inlinequeryresultvideo.py index 4a0b4c595..5ca5c6033 100644 --- a/telegram/inline/inlinequeryresultvideo.py +++ b/telegram/inline/inlinequeryresultvideo.py @@ -110,7 +110,7 @@ class InlineQueryResultVideo(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin video_url: str, mime_type: str, thumb_url: str, diff --git a/telegram/inline/inlinequeryresultvoice.py b/telegram/inline/inlinequeryresultvoice.py index 32e626841..88d79b7a1 100644 --- a/telegram/inline/inlinequeryresultvoice.py +++ b/telegram/inline/inlinequeryresultvoice.py @@ -86,7 +86,7 @@ class InlineQueryResultVoice(InlineQueryResult): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin voice_url: str, title: str, voice_duration: int = None, diff --git a/telegram/keyboardbuttonpolltype.py b/telegram/keyboardbuttonpolltype.py index ca6c503ae..772e5f030 100644 --- a/telegram/keyboardbuttonpolltype.py +++ b/telegram/keyboardbuttonpolltype.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -39,7 +39,7 @@ class KeyboardButtonPollType(TelegramObject): __slots__ = ('type',) - def __init__(self, type: str = None, **_kwargs: Any): # pylint: disable=W0622 + def __init__(self, type: str = None, **_kwargs: Any): # pylint: disable=redefined-builtin self.type = type self._id_attrs = (self.type,) diff --git a/telegram/loginurl.py b/telegram/loginurl.py index d014f2674..0c6e799cd 100644 --- a/telegram/loginurl.py +++ b/telegram/loginurl.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 diff --git a/telegram/message.py b/telegram/message.py index 714958fbe..1a5ce48c2 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0902,R0913 +# pylint: disable=too-many-instance-attributes, too-many-arguments # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -705,7 +705,7 @@ class Message(TelegramObject): return self._effective_attachment # type: ignore - def __getitem__(self, item: str) -> Any: # pylint: disable=R1710 + def __getitem__(self, item: str) -> Any: # pylint: disable=inconsistent-return-statements return self.chat.id if item == 'chat_id' else super().__getitem__(item) def to_dict(self) -> JSONDict: @@ -1583,7 +1583,7 @@ class Message(TelegramObject): question: str, options: List[str], is_anonymous: bool = True, - type: str = Poll.REGULAR, # pylint: disable=W0622 + type: str = Poll.REGULAR, # pylint: disable=redefined-builtin allows_multiple_answers: bool = False, correct_option_id: int = None, is_closed: bool = None, diff --git a/telegram/messageentity.py b/telegram/messageentity.py index b96a2726d..dabede9d2 100644 --- a/telegram/messageentity.py +++ b/telegram/messageentity.py @@ -64,7 +64,7 @@ class MessageEntity(TelegramObject): def __init__( self, - type: str, # pylint: disable=W0622 + type: str, # pylint: disable=redefined-builtin offset: int, length: int, url: str = None, diff --git a/telegram/parsemode.py b/telegram/parsemode.py index 1047a0a01..3c3cdf26c 100644 --- a/telegram/parsemode.py +++ b/telegram/parsemode.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 diff --git a/telegram/passport/credentials.py b/telegram/passport/credentials.py index 95de18e24..3461a7505 100644 --- a/telegram/passport/credentials.py +++ b/telegram/passport/credentials.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=C0114, W0622 +# pylint: disable=missing-module-docstring, redefined-builtin try: import ujson as json except ImportError: diff --git a/telegram/passport/data.py b/telegram/passport/data.py index e1d38b536..03c297b01 100644 --- a/telegram/passport/data.py +++ b/telegram/passport/data.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=C0114 +# pylint: disable=missing-module-docstring from typing import TYPE_CHECKING, Any from telegram import TelegramObject diff --git a/telegram/passport/encryptedpassportelement.py b/telegram/passport/encryptedpassportelement.py index 68f73c064..18d39d0d2 100644 --- a/telegram/passport/encryptedpassportelement.py +++ b/telegram/passport/encryptedpassportelement.py @@ -134,8 +134,8 @@ class EncryptedPassportElement(TelegramObject): def __init__( self, - type: str, # pylint: disable=W0622 - hash: str, # pylint: disable=W0622 + type: str, # pylint: disable=redefined-builtin + hash: str, # pylint: disable=redefined-builtin data: PersonalDetails = None, phone_number: str = None, email: str = None, @@ -145,7 +145,7 @@ class EncryptedPassportElement(TelegramObject): selfie: PassportFile = None, translation: List[PassportFile] = None, bot: 'Bot' = None, - credentials: 'Credentials' = None, # pylint: disable=W0613 + credentials: 'Credentials' = None, # pylint: disable=unused-argument **_kwargs: Any, ): # Required diff --git a/telegram/passport/passportelementerrors.py b/telegram/passport/passportelementerrors.py index 9740fafd4..bff320fa5 100644 --- a/telegram/passport/passportelementerrors.py +++ b/telegram/passport/passportelementerrors.py @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=W0622 +# pylint: disable=redefined-builtin """This module contains the classes that represent Telegram PassportElementError.""" from typing import Any diff --git a/telegram/payment/precheckoutquery.py b/telegram/payment/precheckoutquery.py index 86efc9154..a9ccd4676 100644 --- a/telegram/payment/precheckoutquery.py +++ b/telegram/payment/precheckoutquery.py @@ -80,7 +80,7 @@ class PreCheckoutQuery(TelegramObject): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin from_user: User, currency: str, total_amount: int, @@ -90,7 +90,7 @@ class PreCheckoutQuery(TelegramObject): bot: 'Bot' = None, **_kwargs: Any, ): - self.id = id # pylint: disable=C0103 + self.id = id # pylint: disable=invalid-name self.from_user = from_user self.currency = currency self.total_amount = total_amount @@ -115,7 +115,7 @@ class PreCheckoutQuery(TelegramObject): return cls(bot=bot, **data) - def answer( # pylint: disable=C0103 + def answer( # pylint: disable=invalid-name self, ok: bool, error_message: str = None, diff --git a/telegram/payment/shippingoption.py b/telegram/payment/shippingoption.py index b0a9ccef5..1a66a4807 100644 --- a/telegram/payment/shippingoption.py +++ b/telegram/payment/shippingoption.py @@ -50,12 +50,12 @@ class ShippingOption(TelegramObject): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin title: str, prices: List['LabeledPrice'], **_kwargs: Any, ): - self.id = id # pylint: disable=C0103 + self.id = id # pylint: disable=invalid-name self.title = title self.prices = prices diff --git a/telegram/payment/shippingquery.py b/telegram/payment/shippingquery.py index 1a326df86..c447aec5f 100644 --- a/telegram/payment/shippingquery.py +++ b/telegram/payment/shippingquery.py @@ -58,14 +58,14 @@ class ShippingQuery(TelegramObject): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin from_user: User, invoice_payload: str, shipping_address: ShippingAddress, bot: 'Bot' = None, **_kwargs: Any, ): - self.id = id # pylint: disable=C0103 + self.id = id # pylint: disable=invalid-name self.from_user = from_user self.invoice_payload = invoice_payload self.shipping_address = shipping_address @@ -87,7 +87,7 @@ class ShippingQuery(TelegramObject): return cls(bot=bot, **data) - def answer( # pylint: disable=C0103 + def answer( # pylint: disable=invalid-name self, ok: bool, shipping_options: List[ShippingOption] = None, diff --git a/telegram/poll.py b/telegram/poll.py index 89488bfa1..49e1cad2e 100644 --- a/telegram/poll.py +++ b/telegram/poll.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -168,13 +168,13 @@ class Poll(TelegramObject): def __init__( self, - id: str, # pylint: disable=W0622 + id: str, # pylint: disable=redefined-builtin question: str, options: List[PollOption], total_voter_count: int, is_closed: bool, is_anonymous: bool, - type: str, # pylint: disable=W0622 + type: str, # pylint: disable=redefined-builtin allows_multiple_answers: bool, correct_option_id: int = None, explanation: str = None, @@ -183,7 +183,7 @@ class Poll(TelegramObject): close_date: datetime.datetime = None, **_kwargs: Any, ): - self.id = id # pylint: disable=C0103 + self.id = id # pylint: disable=invalid-name self.question = question self.options = options self.total_voter_count = total_voter_count diff --git a/telegram/request.py b/telegram/request.py index 2c5375012..f13241c3a 100644 --- a/telegram/request.py +++ b/telegram/request.py @@ -60,7 +60,7 @@ except ImportError: # pragma: no cover ) raise -# pylint: disable=C0412 +# pylint: disable=ungrouped-imports from telegram import InputFile from telegram.error import ( TelegramError, @@ -76,7 +76,8 @@ from telegram.error import ( from telegram.utils.types import JSONDict -def _render_part(self: RequestField, name: str, value: str) -> str: # pylint: disable=W0613 +# pylint: disable=unused-argument +def _render_part(self: RequestField, name: str, value: str) -> str: r""" Monkey patch urllib3.urllib3.fields.RequestField to make it *not* support RFC2231 compliant Content-Disposition headers since telegram servers don't understand it. Instead just escape @@ -88,7 +89,7 @@ def _render_part(self: RequestField, name: str, value: str) -> str: # pylint: d return f'{name}="{value}"' -RequestField._render_part = _render_part # type: ignore # pylint: disable=W0212 +RequestField._render_part = _render_part # type: ignore # pylint: disable=protected-access logging.getLogger('telegram.vendor.ptb_urllib3.urllib3').setLevel(logging.WARNING) @@ -181,7 +182,7 @@ class Request: kwargs.update(urllib3_proxy_kwargs) if proxy_url.startswith('socks'): try: - # pylint: disable=C0415 + # pylint: disable=import-outside-toplevel from telegram.vendor.ptb_urllib3.urllib3.contrib.socks import SOCKSProxyManager except ImportError as exc: raise RuntimeError('PySocks is missing') from exc @@ -315,7 +316,7 @@ class Request: # Are we uploading files? files = False - # pylint: disable=R1702 + # pylint: disable=too-many-nested-blocks for key, val in data.copy().items(): if isinstance(val, InputFile): # Convert the InputFile to urllib3 field format diff --git a/telegram/telegramobject.py b/telegram/telegramobject.py index c3560929d..1d86aad62 100644 --- a/telegram/telegramobject.py +++ b/telegram/telegramobject.py @@ -45,7 +45,8 @@ class TelegramObject: # Only instance variables should be added to __slots__. __slots__ = ('_id_attrs',) - def __new__(cls, *args: object, **kwargs: object) -> 'TelegramObject': # pylint: disable=W0613 + # pylint: disable=unused-argument + def __new__(cls, *args: object, **kwargs: object) -> 'TelegramObject': # We add _id_attrs in __new__ instead of __init__ since we want to add this to the slots # w/o calling __init__ in all of the subclasses. This is what we also do in BaseFilter. instance = super().__new__(cls) diff --git a/telegram/user.py b/telegram/user.py index b510047c5..b1b86bbf7 100644 --- a/telegram/user.py +++ b/telegram/user.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=W0622 +# pylint: disable=redefined-builtin # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022 @@ -124,7 +124,7 @@ class User(TelegramObject): **_kwargs: Any, ): # Required - self.id = int(id) # pylint: disable=C0103 + self.id = int(id) # pylint: disable=invalid-name self.first_name = first_name self.is_bot = is_bot # Optionals @@ -1062,7 +1062,7 @@ class User(TelegramObject): options: List[str], is_anonymous: bool = True, # We use constant.POLL_REGULAR instead of Poll.REGULAR here to avoid circular imports - type: str = constants.POLL_REGULAR, # pylint: disable=W0622 + type: str = constants.POLL_REGULAR, # pylint: disable=redefined-builtin allows_multiple_answers: bool = False, correct_option_id: int = None, is_closed: bool = None, diff --git a/telegram/utils/files.py b/telegram/utils/files.py index 43acf938d..c6972c087 100644 --- a/telegram/utils/files.py +++ b/telegram/utils/files.py @@ -87,7 +87,7 @@ def parse_file_input( :attr:`file_input`, in case it's no valid file input. """ # Importing on file-level yields cyclic Import Errors - from telegram import InputFile # pylint: disable=C0415 + from telegram import InputFile # pylint: disable=import-outside-toplevel if isinstance(file_input, str) and file_input.startswith('file://'): return file_input diff --git a/telegram/version.py b/telegram/version.py index f831eee6a..db4fa89e9 100644 --- a/telegram/version.py +++ b/telegram/version.py @@ -16,9 +16,9 @@ # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. -# pylint: disable=C0114 +# pylint: disable=missing-module-docstring from telegram import constants __version__ = '13.11' -bot_api_version = constants.BOT_API_VERSION # pylint: disable=C0103 +bot_api_version = constants.BOT_API_VERSION # pylint: disable=invalid-name diff --git a/telegram/voicechat.py b/telegram/voicechat.py index fcc2a0a11..b2d3f8125 100644 --- a/telegram/voicechat.py +++ b/telegram/voicechat.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=R0903 +# pylint: disable=too-few-public-methods # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2022