diff --git a/AUTHORS.rst b/AUTHORS.rst index c947fd9f48e..942a0e8d31e 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 4615a6e525a..17dc933662e 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 10133b3eedb..f228d4023da 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 cfe485a61f8..224694a63b4 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 @@ def from_update(cls, update: object, dispatcher: 'Dispatcher') -> 'CustomContext 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 4e5f62efb5b..853b4481460 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 aef62fe485c..9459758e314 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 deb74afc61a..9e20ba43733 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 e6954b7a1d6..2be175028dd 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 08504a6cd87..a05497cbfea 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 5cbb8dfb1df..5bfd90ae4e9 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 a3799d207ec..717227b0677 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 2276238e413..159bf375d89 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 e00e2fc3da6..6d5f662116c 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 21bfc1ecde7..8a8591997a8 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 a619a795083..60a746029cb 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 e9a2cc47a95..7981e601890 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 f7521c56e77..ecb78d09fb8 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 fed61b3d6de..09e7e3a7c90 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 9643f30abec..1c72fbeb79a 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 0e8db82761e..890191f38ba 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 d2ed9eff05a..672cebd7250 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-2021 @@ -194,7 +195,7 @@ def _log(func: Any): # type: ignore[no-untyped-def] # skipcq: PY-D0003 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) @@ -333,7 +334,7 @@ def bot(self) -> User: 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 @@ -1970,7 +1971,7 @@ def send_chat_action( 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']]] @@ -2027,7 +2028,7 @@ def _effective_inline_results( # pylint: disable=R0201 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 @@ -2035,7 +2036,7 @@ def _insert_defaults_for_ilq_results( # pylint: disable=R0201 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: @@ -3451,7 +3452,7 @@ def send_invoice( ) @_log - def answer_shipping_query( # pylint: disable=C0103 + def answer_shipping_query( # pylint: disable=invalid-name self, shipping_query_id: str, ok: bool, @@ -3520,7 +3521,7 @@ def answer_shipping_query( # pylint: disable=C0103 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, @@ -3562,7 +3563,7 @@ def answer_pre_checkout_query( # pylint: disable=C0103 """ 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 ' @@ -4672,7 +4673,7 @@ def send_poll( 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 c5e2275644e..95e032baa3f 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-2021 diff --git a/telegram/botcommandscope.py b/telegram/botcommandscope.py index 2d2a0419d39..7137a5acc96 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 8552658f03f..9a485453def 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 @@ def __init__( **_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 e4ec6f734c1..29ff66c05f1 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-2021 @@ -207,7 +207,7 @@ def __init__( **_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 @@ -270,7 +270,7 @@ def de_json(cls, data: Optional[JSONDict], bot: 'Bot') -> Optional['Chat']: 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) @@ -1324,7 +1324,7 @@ def send_poll( 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 18b2600fd24..aaf19feec60 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-2021 diff --git a/telegram/choseninlineresult.py b/telegram/choseninlineresult.py index f4ac36a6a5e..c993b07f7e0 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-2021 diff --git a/telegram/dice.py b/telegram/dice.py index 2f4a302cd0b..3e7aa392d1f 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-2021 diff --git a/telegram/error.py b/telegram/error.py index 48f50e56d14..431de67fcf8 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 c78307eff64..8d907d45b16 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 @@ def replace_bot(cls, obj: object) -> object: 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 @@ def insert_bot(self, obj: object) -> object: """ 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 d89fe5cce0d..eac0ad0cc31 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 @@ def from_update( 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 5152a2557bf..3429409f664 100644 --- a/telegram/ext/callbackdatacache.py +++ b/telegram/ext/callbackdatacache.py @@ -43,7 +43,7 @@ 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 badf7331a7a..24565d2438e 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 794afca19f9..0ce21e25b14 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 @@ def _schedule_job( ) 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 138ff27e4e5..b772b49326c 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 7eeb336d6a5..1f1bd6ca95c 100644 --- a/telegram/ext/dispatcher.py +++ b/telegram/ext/dispatcher.py @@ -260,7 +260,8 @@ def __init__( # 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) @@ -529,7 +530,8 @@ def add_handler(self, handler: Handler[UT, CCT], group: int = DEFAULT_GROUP) -> """ # 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__}') @@ -629,7 +631,7 @@ def __update_persistence(self, update: object = None) -> None: 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 @@ -709,7 +711,10 @@ def dispatch_error( 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 1429bc64062..5165c5c7370 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-2021 @@ -297,7 +298,7 @@ def get_updates( 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 8abd694ab32..d6c3756c142 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 variable. __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 @@ def name(self) -> Optional[str]: @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 @@ def _merge(base_output: Union[bool, Dict], comp_output: Union[bool, Dict]) -> Da 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 @@ def name(self, name: str) -> NoReturn: 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 @@ def remove_user_ids(self, user_id: SLT[int]) -> None: 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 @@ def remove_bot_ids(self, bot_id: SLT[int]) -> None: 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 @@ def remove_chat_ids(self, chat_id: SLT[int]) -> None: 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 @@ def remove_chat_ids(self, chat_id: SLT[int]) -> None: 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 chats chat ID or username. diff --git a/telegram/ext/typehandler.py b/telegram/ext/typehandler.py index 0d4cd8d7f6f..d3aa812b68a 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 @@ def __init__( 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 @@ def check_update(self, update: object) -> bool: """ 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 2ba48d88b38..ff4be829769 100644 --- a/telegram/ext/updater.py +++ b/telegram/ext/updater.py @@ -158,7 +158,7 @@ def __init__( 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 @@ def _signal_handler(self, signum, frame) -> None: 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 b328c613aa7..8714fc18a63 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 @@ def shutdown(self) -> None: 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 @@ def log_request(self, handler: tornado.web.RequestHandler) -> None: # skipcq: P # 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 @@ def __init__( 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 2c7e95bde02..17fb78b2329 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-2021 diff --git a/telegram/files/inputmedia.py b/telegram/files/inputmedia.py index 54bd840a0bb..6b33d4fcdb3 100644 --- a/telegram/files/inputmedia.py +++ b/telegram/files/inputmedia.py @@ -53,7 +53,7 @@ def to_dict(self) -> JSONDict: 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 87c83175e46..26407689edd 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 de4d845d1be..7ea70fdee4a 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-2021 @@ -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 @@ def __init__( **_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 30068f96267..532a03c347b 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 @@ def to_dict(self) -> JSONDict: """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 3827ae305e0..722be546378 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 42df337c2ee..e19041f5e11 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 5f693aead09..f16b9472fb2 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 ea4be24204a..dec3ebbf5ac 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 425cf7224ea..e5af12f5377 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 4cc543197b5..624dd09aee8 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 2c8fc4b4e74..a18857767be 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 f369bdd4aa5..6669671fc19 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 e34f3b06339..309b0b64ad5 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 964cf12489f..89762e85187 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 42dd75d4bb9..935989e2587 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 fd1834c5549..e3bd625088f 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 f8535b44b1c..d862a5f458c 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 1724aacf959..36ce5e6ef41 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 2591b6361b1..3f415e96b4e 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 991ddf513ac..0b8718e583d 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 ce6b83df289..6bf71ac514c 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 9930f7ab72e..b42db95bec5 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 e7d3fe6b303..a6d58d68abc 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 68b8dc79582..0e4084533c9 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 7dce551fc21..7462923883f 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) 2020-2021 @@ -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 debd6897060..3bf1396b41f 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-2021 diff --git a/telegram/message.py b/telegram/message.py index 7348a7c3881..8a55bb2b688 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-2021 @@ -679,7 +679,7 @@ def effective_attachment( 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: @@ -1525,7 +1525,7 @@ def reply_poll( 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 7f07960e0fa..5948de2ee15 100644 --- a/telegram/messageentity.py +++ b/telegram/messageentity.py @@ -63,7 +63,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 2ecdf2b6af2..8fea526e214 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-2021 diff --git a/telegram/passport/credentials.py b/telegram/passport/credentials.py index 64f9f41b18e..77b69335083 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 b17f5d87f9c..61a3442d544 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 afa22a190c6..97cbc669c17 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 @@ def __init__( 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 f49b9a616c9..d2c36b6da57 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 ba5d3801642..7f73b7f2bc2 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 @@ def __init__( 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 @@ def de_json(cls, data: Optional[JSONDict], bot: 'Bot') -> Optional['PreCheckoutQ 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 9eba5b1522a..6b548d1d0de 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 137e4aaed76..69a981d43f7 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 @@ def de_json(cls, data: Optional[JSONDict], bot: 'Bot') -> Optional['ShippingQuer 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 6b483a77c25..7386339aae4 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-2021 @@ -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 @@ def __init__( 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 ad4d3844ff2..b8c52ae49bf 100644 --- a/telegram/request.py +++ b/telegram/request.py @@ -60,7 +60,7 @@ ) raise -# pylint: disable=C0412 +# pylint: disable=ungrouped-imports from telegram import InputFile from telegram.error import ( TelegramError, @@ -76,7 +76,8 @@ 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 @@ def __init__( 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 @@ def post(self, url: str, data: JSONDict, timeout: float = None) -> Union[JSONDic # 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 21abade3853..264a721bc25 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 cd4861f9fab..150fa5a619e 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-2021 @@ -123,7 +123,7 @@ def __init__( **_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 @@ -1013,7 +1013,7 @@ def send_poll( 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 43acf938d71..c6972c087b5 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 653ace5dcc3..26ca4aa7f24 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.7' -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 b45423a0741..8e95ec4388a 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-2021