Use Error Messages for Pylint Instead of Codes (#2700)

This commit is contained in:
Piraty 2021-10-08 06:17:00 +00:00 committed by Hinrich Mahler
parent 99581abe05
commit edb30cf342
85 changed files with 170 additions and 153 deletions

View file

@ -91,6 +91,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Patrick Hofmann <https://github.com/PH89>`_ - `Patrick Hofmann <https://github.com/PH89>`_
- `Paul Larsen <https://github.com/PaulSonOfLars>`_ - `Paul Larsen <https://github.com/PaulSonOfLars>`_
- `Pieter Schutz <https://github.com/eldinnie>`_ - `Pieter Schutz <https://github.com/eldinnie>`_
- `Piraty <https://github.com/piraty>`_
- `Poolitzer <https://github.com/Poolitzer>`_ - `Poolitzer <https://github.com/Poolitzer>`_
- `Pranjalya Tiwari <https://github.com/Pranjalya>`_ - `Pranjalya Tiwari <https://github.com/Pranjalya>`_
- `Rahiel Kasim <https://github.com/rahiel>`_ - `Rahiel Kasim <https://github.com/rahiel>`_

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
"""This example showcases how PTBs "arbitrary callback data" feature can be used. """This example showcases how PTBs "arbitrary callback data" feature can be used.

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 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) context = super().from_update(update, dispatcher)
if context.chat_data and isinstance(update, Update) and update.effective_message: 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 # Remember to return the object
return context return context

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
"""Bot that explains Telegram's "Deep Linking Parameters" functionality. """Bot that explains Telegram's "Deep Linking Parameters" functionality.

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 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.""" """This is a very simple example on how one could implement a custom error handler."""

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
"""Simple inline keyboard bot with multiple CallbackQueryHandlers. """Simple inline keyboard bot with multiple CallbackQueryHandlers.

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
"""Basic example for a bot that can receive payment from user.""" """Basic example for a bot that can receive payment from user."""

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# pylint: disable=W0603 # pylint: disable=global-statement
"""Simple Bot to reply to Telegram messages. """Simple Bot to reply to Telegram messages.
This is built on the API wrapper, see echobot.py to see the same example built This is built on the API wrapper, see echobot.py to see the same example built

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=C0114 # pylint: disable=missing-module-docstring
import subprocess import subprocess
import sys import sys
from typing import Optional from typing import Optional

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -194,7 +195,7 @@ class Bot(TelegramObject):
logger = logging.getLogger(func.__module__) logger = logging.getLogger(func.__module__)
@functools.wraps(func) @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__) logger.debug('Entering: %s', func.__name__)
result = func(*args, **kwargs) result = func(*args, **kwargs)
logger.debug(result) logger.debug(result)
@ -337,7 +338,7 @@ class Bot(TelegramObject):
return self._bot return self._bot
@property @property
def id(self) -> int: # pylint: disable=C0103 def id(self) -> int: # pylint: disable=invalid-name
""":obj:`int`: Unique identifier for this bot.""" """:obj:`int`: Unique identifier for this bot."""
return self.bot.id return self.bot.id
@ -2087,7 +2088,7 @@ class Bot(TelegramObject):
return result # type: ignore[return-value] return result # type: ignore[return-value]
def _effective_inline_results( # pylint: disable=R0201 def _effective_inline_results( # pylint: disable=no-self-use
self, self,
results: Union[ results: Union[
Sequence['InlineQueryResult'], Callable[[int], Optional[Sequence['InlineQueryResult']]] Sequence['InlineQueryResult'], Callable[[int], Optional[Sequence['InlineQueryResult']]]
@ -2144,7 +2145,7 @@ class Bot(TelegramObject):
return effective_results, next_offset return effective_results, next_offset
@no_type_check # mypy doesn't play too well with hasattr @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' self, res: 'InlineQueryResult'
) -> None: ) -> None:
"""The reason why this method exists is similar to the description of _insert_defaults """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 DEFAULT_NONE to NONE *before* calling to_dict() makes it way easier to drop None entries
from the json data. from the json data.
""" """
# pylint: disable=W0212 # pylint: disable=protected-access
if hasattr(res, 'parse_mode'): if hasattr(res, 'parse_mode'):
res.parse_mode = DefaultValue.get_value(res.parse_mode) res.parse_mode = DefaultValue.get_value(res.parse_mode)
if hasattr(res, 'input_message_content') and res.input_message_content: if hasattr(res, 'input_message_content') and res.input_message_content:
@ -3651,7 +3652,7 @@ class Bot(TelegramObject):
) )
@_log @_log
def answer_shipping_query( # pylint: disable=C0103 def answer_shipping_query( # pylint: disable=invalid-name
self, self,
shipping_query_id: str, shipping_query_id: str,
ok: bool, ok: bool,
@ -3720,7 +3721,7 @@ class Bot(TelegramObject):
return result # type: ignore[return-value] return result # type: ignore[return-value]
@_log @_log
def answer_pre_checkout_query( # pylint: disable=C0103 def answer_pre_checkout_query( # pylint: disable=invalid-name
self, self,
pre_checkout_query_id: str, pre_checkout_query_id: str,
ok: bool, ok: bool,
@ -3762,7 +3763,7 @@ class Bot(TelegramObject):
""" """
ok = bool(ok) 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( raise TelegramError(
'answerPreCheckoutQuery: If ok is True, there should ' 'answerPreCheckoutQuery: If ok is True, there should '
'not be error_message; if ok is False, error_message ' 'not be error_message; if ok is False, error_message '
@ -5016,7 +5017,7 @@ class Bot(TelegramObject):
question: str, question: str,
options: List[str], options: List[str],
is_anonymous: bool = True, is_anonymous: bool = True,
type: str = Poll.REGULAR, # pylint: disable=W0622 type: str = Poll.REGULAR, # pylint: disable=redefined-builtin
allows_multiple_answers: bool = False, allows_multiple_answers: bool = False,
correct_option_id: int = None, correct_option_id: int = None,
is_closed: bool = None, is_closed: bool = None,

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains objects representing Telegram bot command scopes."""
from typing import Any, Union, Optional, TYPE_CHECKING, Dict, Type from typing import Any, Union, Optional, TYPE_CHECKING, Dict, Type

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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""" """This module contains an object that represents a Telegram CallbackQuery"""
from typing import TYPE_CHECKING, Any, List, Optional, Union, Tuple, ClassVar from typing import TYPE_CHECKING, Any, List, Optional, Union, Tuple, ClassVar
@ -105,7 +105,7 @@ class CallbackQuery(TelegramObject):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
from_user: User, from_user: User,
chat_instance: str, chat_instance: str,
message: Message = None, message: Message = None,
@ -116,7 +116,7 @@ class CallbackQuery(TelegramObject):
**_kwargs: Any, **_kwargs: Any,
): ):
# Required # Required
self.id = id # pylint: disable=C0103 self.id = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user = from_user
self.chat_instance = chat_instance self.chat_instance = chat_instance
# Optionals # Optionals

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# pylint: disable=W0622 # pylint: disable=redefined-builtin
# #
# A library that provides a Python interface to the Telegram Bot API # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -229,7 +229,7 @@ class Chat(TelegramObject):
**_kwargs: Any, **_kwargs: Any,
): ):
# Required # Required
self.id = int(id) # pylint: disable=C0103 self.id = int(id) # pylint: disable=invalid-name
self.type = type self.type = type
# Optionals # Optionals
self.title = title self.title = title
@ -294,7 +294,7 @@ class Chat(TelegramObject):
return None return None
data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) 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['pinned_message'] = Message.de_json(data.get('pinned_message'), bot)
data['permissions'] = ChatPermissions.de_json(data.get('permissions'), bot) data['permissions'] = ChatPermissions.de_json(data.get('permissions'), bot)
@ -1472,7 +1472,7 @@ class Chat(TelegramObject):
options: List[str], options: List[str],
is_anonymous: bool = True, is_anonymous: bool = True,
# We use constant.POLL_REGULAR instead of Poll.REGULAR here to avoid circular imports # 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, allows_multiple_answers: bool = False,
correct_option_id: int = None, correct_option_id: int = None,
is_closed: bool = None, is_closed: bool = None,

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022

View file

@ -16,7 +16,6 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=C0115
"""This module contains an classes that represent Telegram errors.""" """This module contains an classes that represent Telegram errors."""
from typing import Tuple, Union from typing import Tuple, Union

View file

@ -113,7 +113,7 @@ class BasePersistence(Generic[UD, CD, BD], ABC):
) )
def __new__( def __new__(
cls, *args: object, **kwargs: object # pylint: disable=W0613 cls, *args: object, **kwargs: object # pylint: disable=unused-argument
) -> 'BasePersistence': ) -> 'BasePersistence':
"""This overrides the get_* and update_* methods to use insert/replace_bot. """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 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, {}) return cls._replace_bot(obj, {})
@classmethod @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) obj_id = id(obj)
if obj_id in memo: if obj_id in memo:
return memo[obj_id] return memo[obj_id]
@ -309,7 +311,8 @@ class BasePersistence(Generic[UD, CD, BD], ABC):
""" """
return self._insert_bot(obj, {}) 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) obj_id = id(obj)
if obj_id in memo: if obj_id in memo:
return memo[obj_id] return memo[obj_id]

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the CallbackContext class."""
from queue import Queue from queue import Queue
from typing import ( from typing import (
@ -296,12 +296,12 @@ class CallbackContext(Generic[UD, CD, BD]):
if chat: if chat:
self._chat_id_and_data = ( self._chat_id_and_data = (
chat.id, chat.id,
dispatcher.chat_data[chat.id], # pylint: disable=W0212 dispatcher.chat_data[chat.id], # pylint: disable=protected-access
) )
if user: if user:
self._user_id_and_data = ( self._user_id_and_data = (
user.id, user.id,
dispatcher.user_data[user.id], # pylint: disable=W0212 dispatcher.user_data[user.id], # pylint: disable=protected-access
) )
return self return self

View file

@ -24,7 +24,7 @@ from threading import Lock
from typing import Dict, Tuple, Union, Optional, MutableMapping, TYPE_CHECKING, cast from typing import Dict, Tuple, Union, Optional, MutableMapping, TYPE_CHECKING, cast
from uuid import uuid4 from uuid import uuid4
from cachetools import LRUCache # pylint: disable=E0401 from cachetools import LRUCache # pylint: disable=import-error
from telegram import ( from telegram import (
InlineKeyboardMarkup, InlineKeyboardMarkup,

View file

@ -16,9 +16,9 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """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.callbackcontext import CallbackContext
from telegram.ext.utils.types import CCT, UD, CD, BD from telegram.ext.utils.types import CCT, UD, CD, BD

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the ConversationHandler."""
import logging import logging
@ -212,7 +212,7 @@ class ConversationHandler(Handler[Update, CCT]):
WAITING: ClassVar[int] = -3 WAITING: ClassVar[int] = -3
""":obj:`int`: Used as a constant to handle state when a conversation is still waiting on the """: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.""" previous ``@run_sync`` decorated running handler to finish."""
# pylint: disable=W0231 # pylint: disable=super-init-not-called
def __init__( def __init__(
self, self,
entry_points: List[Handler[Update, CCT]], entry_points: List[Handler[Update, CCT]],
@ -511,7 +511,8 @@ class ConversationHandler(Handler[Update, CCT]):
) )
self.logger.exception("%s", exc) 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 Determines whether an update should be handled by this conversationhandler, and if so in
which state the conversation currently is. which state the conversation currently is.

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the class Defaults, which allows to pass default values to Updater."""
from typing import NoReturn, Optional, Dict, Any from typing import NoReturn, Optional, Dict, Any

View file

@ -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 # 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. # only one instance of Dispatcher, it will be possible to use the `run_async` decorator.
with self.__singleton_lock: 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) self._set_singleton(self)
else: else:
self._set_singleton(None) 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 # 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): if not isinstance(handler, Handler):
raise TypeError(f'handler is not an instance of {Handler.__name__}') 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( def add_error_handler(
self, self,
callback: Callable[[object, CCT], None], callback: Callable[[object, CCT], None],
run_async: Union[bool, DefaultValue] = DEFAULT_FALSE, # pylint: disable=W0621 run_async: Union[bool, DefaultValue] = DEFAULT_FALSE,
) -> None: ) -> None:
"""Registers an error handler in the Dispatcher. This handler will receive every error """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 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 async_kwargs = None if not promise else promise.kwargs
if self.error_handlers: 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( context = self.context_types.context.from_error(
update=update, update=update,
error=error, error=error,

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -299,7 +300,7 @@ class ExtBot(telegram.bot.Bot):
return updates return updates
def _effective_inline_results( # pylint: disable=R0201 def _effective_inline_results( # pylint: disable=no-self-use
self, self,
results: Union[ results: Union[
Sequence['InlineQueryResult'], Callable[[int], Optional[Sequence['InlineQueryResult']]] Sequence['InlineQueryResult'], Callable[[int], Optional[Sequence['InlineQueryResult']]]

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the Filters for use with the MessageHandler class."""
import re import re
@ -112,7 +112,8 @@ class BaseFilter(ABC):
__slots__ = ('_name', '_data_filter') __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() # We do this here instead of in a __init__ so filter don't have to call __init__ or super()
instance = super().__new__(cls) instance = super().__new__(cls)
instance._name = None instance._name = None
@ -150,7 +151,7 @@ class BaseFilter(ABC):
@name.setter @name.setter
def name(self, name: Optional[str]) -> None: 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: def __repr__(self) -> str:
# We do this here instead of in a __init__ so filter don't have to call __init__ or super() # 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 base[k] = comp_value
return base 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) base_output = self.base_filter(update)
# We need to check if the filters are data filters and if so return the merged data. # 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 # 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__}') raise RuntimeError(f'Cannot set name for Filters.{self.__class__.__name__}')
class user(_ChatUserBaseFilter): 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 """Filters messages to allow only those which are from specified user ID(s) or
username(s). username(s).
@ -1624,7 +1626,7 @@ officedocument.wordprocessingml.document")``.
return super().remove_chat_ids(user_id) return super().remove_chat_ids(user_id)
class via_bot(_ChatUserBaseFilter): 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 """Filters messages to allow only those which are from specified via_bot ID(s) or
username(s). username(s).
@ -1726,7 +1728,7 @@ officedocument.wordprocessingml.document")``.
return super().remove_chat_ids(bot_id) return super().remove_chat_ids(bot_id)
class chat(_ChatUserBaseFilter): 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. """Filters messages to allow only those which are from a specified chat ID or username.
Examples: Examples:
@ -1809,7 +1811,7 @@ officedocument.wordprocessingml.document")``.
return super().remove_chat_ids(chat_id) return super().remove_chat_ids(chat_id)
class forwarded_from(_ChatUserBaseFilter): 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) """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 or username(s) based on :attr:`telegram.Message.forward_from` and
:attr:`telegram.Message.forward_from_chat`. :attr:`telegram.Message.forward_from_chat`.
@ -1902,7 +1904,7 @@ officedocument.wordprocessingml.document")``.
return super().remove_chat_ids(chat_id) return super().remove_chat_ids(chat_id)
class sender_chat(_ChatUserBaseFilter): 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 """Filters messages to allow only those which are from a specified sender chat's chat ID or
username. username.

View file

@ -61,7 +61,7 @@ class TypeHandler(Handler[UT, CCT]):
def __init__( def __init__(
self, self,
type: Type[UT], # pylint: disable=W0622 type: Type[UT], # pylint: disable=redefined-builtin
callback: Callable[[UT, CCT], RT], callback: Callable[[UT, CCT], RT],
strict: bool = False, strict: bool = False,
run_async: Union[bool, DefaultValue] = DEFAULT_FALSE, run_async: Union[bool, DefaultValue] = DEFAULT_FALSE,
@ -70,8 +70,8 @@ class TypeHandler(Handler[UT, CCT]):
callback, callback,
run_async=run_async, run_async=run_async,
) )
self.type = type # pylint: disable=E0237 self.type = type # pylint: disable=assigning-non-slot
self.strict = strict # pylint: disable=E0237 self.strict = strict # pylint: disable=assigning-non-slot
def check_update(self, update: object) -> bool: def check_update(self, update: object) -> bool:
"""Determines whether an update should be passed to this handlers :attr:`callback`. """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: if not self.strict:
return isinstance(update, self.type) return isinstance(update, self.type)
return type(update) is self.type # pylint: disable=C0123 return type(update) is self.type # pylint: disable=unidiomatic-typecheck

View file

@ -158,7 +158,7 @@ class Updater(Generic[CCT, UD, CD, BD]):
private_key_password: bytes = None, private_key_password: bytes = None,
user_sig_handler: Callable = None, user_sig_handler: Callable = None,
request_kwargs: Dict[str, Any] = None, request_kwargs: Dict[str, Any] = None,
persistence: 'BasePersistence' = None, # pylint: disable=E0601 persistence: 'BasePersistence' = None, # pylint: disable=used-before-assignment
defaults: 'Defaults' = None, defaults: 'Defaults' = None,
base_file_url: str = None, base_file_url: str = None,
arbitrary_callback_data: Union[DefaultValue, bool, int, None] = DEFAULT_FALSE, 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) self.user_sig_handler(signum, frame)
else: else:
self.logger.warning('Exiting immediately!') self.logger.warning('Exiting immediately!')
# pylint: disable=C0415,W0212 # pylint: disable=import-outside-toplevel, protected-access
import os import os
os._exit(1) os._exit(1)

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=C0114 # pylint: disable=missing-module-docstring
import logging import logging
from queue import Queue from queue import Queue
@ -88,7 +88,8 @@ class WebhookServer:
return return
self.loop.add_callback(self.loop.stop) # type: ignore 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.""" """Handle an error gracefully."""
self.logger.debug( self.logger.debug(
'Exception happened during processing of request from %s', 'Exception happened during processing of request from %s',
@ -108,7 +109,7 @@ class WebhookAppClass(tornado.web.Application):
# WebhookHandler, process webhook calls # WebhookHandler, process webhook calls
# pylint: disable=W0223 # pylint: disable=abstract-method
class WebhookHandler(tornado.web.RequestHandler): class WebhookHandler(tornado.web.RequestHandler):
SUPPORTED_METHODS = ["POST"] # type: ignore SUPPORTED_METHODS = ["POST"] # type: ignore
@ -122,7 +123,7 @@ class WebhookHandler(tornado.web.RequestHandler):
self.logger = logging.getLogger(__name__) self.logger = logging.getLogger(__name__)
def initialize(self, bot: 'Bot', update_queue: Queue) -> None: def initialize(self, bot: 'Bot', update_queue: Queue) -> None:
# pylint: disable=W0201 # pylint: disable=attribute-defined-outside-init
self.bot = bot self.bot = bot
self.update_queue = update_queue self.update_queue = update_queue

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022

View file

@ -53,7 +53,7 @@ class InputMedia(TelegramObject):
if self.caption_entities: if self.caption_entities:
data['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 return data

View file

@ -104,7 +104,7 @@ def effective_message_type(entity: Union['Message', 'Update']) -> Optional[str]:
""" """
# Importing on file-level yields cyclic Import Errors # 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): if isinstance(entity, Message):
message = entity message = entity

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -75,7 +75,7 @@ class InlineQuery(TelegramObject):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
from_user: User, from_user: User,
query: str, query: str,
offset: str, offset: str,
@ -85,7 +85,7 @@ class InlineQuery(TelegramObject):
**_kwargs: Any, **_kwargs: Any,
): ):
# Required # Required
self.id = id # pylint: disable=C0103 self.id = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user = from_user
self.query = query self.query = query
self.offset = offset self.offset = offset

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the classes that represent Telegram InlineQueryResult."""
from typing import Any from typing import Any
@ -51,7 +51,7 @@ class InlineQueryResult(TelegramObject):
def __init__(self, type: str, id: str, **_kwargs: Any): def __init__(self, type: str, id: str, **_kwargs: Any):
# Required # Required
self.type = str(type) self.type = str(type)
self.id = str(id) # pylint: disable=C0103 self.id = str(id) # pylint: disable=invalid-name
self._id_attrs = (self.id,) self._id_attrs = (self.id,)
@ -59,7 +59,7 @@ class InlineQueryResult(TelegramObject):
"""See :meth:`telegram.TelegramObject.to_dict`.""" """See :meth:`telegram.TelegramObject.to_dict`."""
data = super().to_dict() data = super().to_dict()
# pylint: disable=E1101 # pylint: disable=no-member
if ( if (
hasattr(self, 'caption_entities') hasattr(self, 'caption_entities')
and self.caption_entities # type: ignore[attr-defined] and self.caption_entities # type: ignore[attr-defined]

View file

@ -77,7 +77,7 @@ class InlineQueryResultArticle(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
title: str, title: str,
input_message_content: 'InputMessageContent', input_message_content: 'InputMessageContent',
reply_markup: 'ReplyMarkup' = None, reply_markup: 'ReplyMarkup' = None,

View file

@ -88,7 +88,7 @@ class InlineQueryResultAudio(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
audio_url: str, audio_url: str,
title: str, title: str,
performer: str = None, performer: str = None,

View file

@ -79,7 +79,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
audio_file_id: str, audio_file_id: str,
caption: str = None, caption: str = None,
reply_markup: 'ReplyMarkup' = None, reply_markup: 'ReplyMarkup' = None,

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the classes that represent Telegram InlineQueryResultCachedDocument."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List from typing import TYPE_CHECKING, Any, Union, Tuple, List
@ -88,7 +88,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
title: str, title: str,
document_file_id: str, document_file_id: str,
description: str = None, description: str = None,

View file

@ -85,7 +85,7 @@ class InlineQueryResultCachedGif(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
gif_file_id: str, gif_file_id: str,
title: str = None, title: str = None,
caption: str = None, caption: str = None,

View file

@ -85,7 +85,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
mpeg4_file_id: str, mpeg4_file_id: str,
title: str = None, title: str = None,
caption: str = None, caption: str = None,

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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""" """This module contains the classes that represent Telegram InlineQueryResultPhoto"""
from typing import TYPE_CHECKING, Any, Union, Tuple, List from typing import TYPE_CHECKING, Any, Union, Tuple, List
@ -89,7 +89,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
photo_file_id: str, photo_file_id: str,
title: str = None, title: str = None,
description: str = None, description: str = None,

View file

@ -56,7 +56,7 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
sticker_file_id: str, sticker_file_id: str,
reply_markup: 'ReplyMarkup' = None, reply_markup: 'ReplyMarkup' = None,
input_message_content: 'InputMessageContent' = None, input_message_content: 'InputMessageContent' = None,

View file

@ -88,7 +88,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
video_file_id: str, video_file_id: str,
title: str, title: str,
description: str = None, description: str = None,

View file

@ -82,7 +82,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
voice_file_id: str, voice_file_id: str,
title: str, title: str,
caption: str = None, caption: str = None,

View file

@ -80,7 +80,7 @@ class InlineQueryResultContact(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
phone_number: str, phone_number: str,
first_name: str, first_name: str,
last_name: str = None, last_name: str = None,

View file

@ -102,7 +102,7 @@ class InlineQueryResultDocument(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
document_url: str, document_url: str,
title: str, title: str,
mime_type: str, mime_type: str,

View file

@ -49,14 +49,14 @@ class InlineQueryResultGame(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
game_short_name: str, game_short_name: str,
reply_markup: 'ReplyMarkup' = None, reply_markup: 'ReplyMarkup' = None,
**_kwargs: Any, **_kwargs: Any,
): ):
# Required # Required
super().__init__('game', id) 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.game_short_name = game_short_name
self.reply_markup = reply_markup self.reply_markup = reply_markup

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the classes that represent Telegram InlineQueryResultGif."""
from typing import TYPE_CHECKING, Any, Union, Tuple, List from typing import TYPE_CHECKING, Any, Union, Tuple, List
@ -103,7 +103,7 @@ class InlineQueryResultGif(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
gif_url: str, gif_url: str,
thumb_url: str, thumb_url: str,
gif_width: int = None, gif_width: int = None,

View file

@ -96,7 +96,7 @@ class InlineQueryResultLocation(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
latitude: float, latitude: float,
longitude: float, longitude: float,
title: str, title: str,

View file

@ -102,7 +102,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
mpeg4_url: str, mpeg4_url: str,
thumb_url: str, thumb_url: str,
mpeg4_width: int = None, mpeg4_width: int = None,

View file

@ -98,7 +98,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
photo_url: str, photo_url: str,
thumb_url: str, thumb_url: str,
photo_width: int = None, photo_width: int = None,

View file

@ -97,7 +97,7 @@ class InlineQueryResultVenue(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
latitude: float, latitude: float,
longitude: float, longitude: float,
title: str, title: str,

View file

@ -110,7 +110,7 @@ class InlineQueryResultVideo(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
video_url: str, video_url: str,
mime_type: str, mime_type: str,
thumb_url: str, thumb_url: str,

View file

@ -86,7 +86,7 @@ class InlineQueryResultVoice(InlineQueryResult):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
voice_url: str, voice_url: str,
title: str, title: str,
voice_duration: int = None, voice_duration: int = None,

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -39,7 +39,7 @@ class KeyboardButtonPollType(TelegramObject):
__slots__ = ('type',) __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.type = type
self._id_attrs = (self.type,) self._id_attrs = (self.type,)

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -705,7 +705,7 @@ class Message(TelegramObject):
return self._effective_attachment # type: ignore 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) return self.chat.id if item == 'chat_id' else super().__getitem__(item)
def to_dict(self) -> JSONDict: def to_dict(self) -> JSONDict:
@ -1583,7 +1583,7 @@ class Message(TelegramObject):
question: str, question: str,
options: List[str], options: List[str],
is_anonymous: bool = True, is_anonymous: bool = True,
type: str = Poll.REGULAR, # pylint: disable=W0622 type: str = Poll.REGULAR, # pylint: disable=redefined-builtin
allows_multiple_answers: bool = False, allows_multiple_answers: bool = False,
correct_option_id: int = None, correct_option_id: int = None,
is_closed: bool = None, is_closed: bool = None,

View file

@ -64,7 +64,7 @@ class MessageEntity(TelegramObject):
def __init__( def __init__(
self, self,
type: str, # pylint: disable=W0622 type: str, # pylint: disable=redefined-builtin
offset: int, offset: int,
length: int, length: int,
url: str = None, url: str = None,

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=C0114, W0622 # pylint: disable=missing-module-docstring, redefined-builtin
try: try:
import ujson as json import ujson as json
except ImportError: except ImportError:

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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 typing import TYPE_CHECKING, Any
from telegram import TelegramObject from telegram import TelegramObject

View file

@ -134,8 +134,8 @@ class EncryptedPassportElement(TelegramObject):
def __init__( def __init__(
self, self,
type: str, # pylint: disable=W0622 type: str, # pylint: disable=redefined-builtin
hash: str, # pylint: disable=W0622 hash: str, # pylint: disable=redefined-builtin
data: PersonalDetails = None, data: PersonalDetails = None,
phone_number: str = None, phone_number: str = None,
email: str = None, email: str = None,
@ -145,7 +145,7 @@ class EncryptedPassportElement(TelegramObject):
selfie: PassportFile = None, selfie: PassportFile = None,
translation: List[PassportFile] = None, translation: List[PassportFile] = None,
bot: 'Bot' = None, bot: 'Bot' = None,
credentials: 'Credentials' = None, # pylint: disable=W0613 credentials: 'Credentials' = None, # pylint: disable=unused-argument
**_kwargs: Any, **_kwargs: Any,
): ):
# Required # Required

View file

@ -16,7 +16,7 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # 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.""" """This module contains the classes that represent Telegram PassportElementError."""
from typing import Any from typing import Any

View file

@ -80,7 +80,7 @@ class PreCheckoutQuery(TelegramObject):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
from_user: User, from_user: User,
currency: str, currency: str,
total_amount: int, total_amount: int,
@ -90,7 +90,7 @@ class PreCheckoutQuery(TelegramObject):
bot: 'Bot' = None, bot: 'Bot' = None,
**_kwargs: Any, **_kwargs: Any,
): ):
self.id = id # pylint: disable=C0103 self.id = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user = from_user
self.currency = currency self.currency = currency
self.total_amount = total_amount self.total_amount = total_amount
@ -115,7 +115,7 @@ class PreCheckoutQuery(TelegramObject):
return cls(bot=bot, **data) return cls(bot=bot, **data)
def answer( # pylint: disable=C0103 def answer( # pylint: disable=invalid-name
self, self,
ok: bool, ok: bool,
error_message: str = None, error_message: str = None,

View file

@ -50,12 +50,12 @@ class ShippingOption(TelegramObject):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
title: str, title: str,
prices: List['LabeledPrice'], prices: List['LabeledPrice'],
**_kwargs: Any, **_kwargs: Any,
): ):
self.id = id # pylint: disable=C0103 self.id = id # pylint: disable=invalid-name
self.title = title self.title = title
self.prices = prices self.prices = prices

View file

@ -58,14 +58,14 @@ class ShippingQuery(TelegramObject):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
from_user: User, from_user: User,
invoice_payload: str, invoice_payload: str,
shipping_address: ShippingAddress, shipping_address: ShippingAddress,
bot: 'Bot' = None, bot: 'Bot' = None,
**_kwargs: Any, **_kwargs: Any,
): ):
self.id = id # pylint: disable=C0103 self.id = id # pylint: disable=invalid-name
self.from_user = from_user self.from_user = from_user
self.invoice_payload = invoice_payload self.invoice_payload = invoice_payload
self.shipping_address = shipping_address self.shipping_address = shipping_address
@ -87,7 +87,7 @@ class ShippingQuery(TelegramObject):
return cls(bot=bot, **data) return cls(bot=bot, **data)
def answer( # pylint: disable=C0103 def answer( # pylint: disable=invalid-name
self, self,
ok: bool, ok: bool,
shipping_options: List[ShippingOption] = None, shipping_options: List[ShippingOption] = None,

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -168,13 +168,13 @@ class Poll(TelegramObject):
def __init__( def __init__(
self, self,
id: str, # pylint: disable=W0622 id: str, # pylint: disable=redefined-builtin
question: str, question: str,
options: List[PollOption], options: List[PollOption],
total_voter_count: int, total_voter_count: int,
is_closed: bool, is_closed: bool,
is_anonymous: bool, is_anonymous: bool,
type: str, # pylint: disable=W0622 type: str, # pylint: disable=redefined-builtin
allows_multiple_answers: bool, allows_multiple_answers: bool,
correct_option_id: int = None, correct_option_id: int = None,
explanation: str = None, explanation: str = None,
@ -183,7 +183,7 @@ class Poll(TelegramObject):
close_date: datetime.datetime = None, close_date: datetime.datetime = None,
**_kwargs: Any, **_kwargs: Any,
): ):
self.id = id # pylint: disable=C0103 self.id = id # pylint: disable=invalid-name
self.question = question self.question = question
self.options = options self.options = options
self.total_voter_count = total_voter_count self.total_voter_count = total_voter_count

View file

@ -60,7 +60,7 @@ except ImportError: # pragma: no cover
) )
raise raise
# pylint: disable=C0412 # pylint: disable=ungrouped-imports
from telegram import InputFile from telegram import InputFile
from telegram.error import ( from telegram.error import (
TelegramError, TelegramError,
@ -76,7 +76,8 @@ from telegram.error import (
from telegram.utils.types import JSONDict 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""" r"""
Monkey patch urllib3.urllib3.fields.RequestField to make it *not* support RFC2231 compliant 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 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}"' 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) logging.getLogger('telegram.vendor.ptb_urllib3.urllib3').setLevel(logging.WARNING)
@ -181,7 +182,7 @@ class Request:
kwargs.update(urllib3_proxy_kwargs) kwargs.update(urllib3_proxy_kwargs)
if proxy_url.startswith('socks'): if proxy_url.startswith('socks'):
try: try:
# pylint: disable=C0415 # pylint: disable=import-outside-toplevel
from telegram.vendor.ptb_urllib3.urllib3.contrib.socks import SOCKSProxyManager from telegram.vendor.ptb_urllib3.urllib3.contrib.socks import SOCKSProxyManager
except ImportError as exc: except ImportError as exc:
raise RuntimeError('PySocks is missing') from exc raise RuntimeError('PySocks is missing') from exc
@ -315,7 +316,7 @@ class Request:
# Are we uploading files? # Are we uploading files?
files = False files = False
# pylint: disable=R1702 # pylint: disable=too-many-nested-blocks
for key, val in data.copy().items(): for key, val in data.copy().items():
if isinstance(val, InputFile): if isinstance(val, InputFile):
# Convert the InputFile to urllib3 field format # Convert the InputFile to urllib3 field format

View file

@ -45,7 +45,8 @@ class TelegramObject:
# Only instance variables should be added to __slots__. # Only instance variables should be added to __slots__.
__slots__ = ('_id_attrs',) __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 # 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. # w/o calling __init__ in all of the subclasses. This is what we also do in BaseFilter.
instance = super().__new__(cls) instance = super().__new__(cls)

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# pylint: disable=W0622 # pylint: disable=redefined-builtin
# #
# A library that provides a Python interface to the Telegram Bot API # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022
@ -124,7 +124,7 @@ class User(TelegramObject):
**_kwargs: Any, **_kwargs: Any,
): ):
# Required # Required
self.id = int(id) # pylint: disable=C0103 self.id = int(id) # pylint: disable=invalid-name
self.first_name = first_name self.first_name = first_name
self.is_bot = is_bot self.is_bot = is_bot
# Optionals # Optionals
@ -1062,7 +1062,7 @@ class User(TelegramObject):
options: List[str], options: List[str],
is_anonymous: bool = True, is_anonymous: bool = True,
# We use constant.POLL_REGULAR instead of Poll.REGULAR here to avoid circular imports # 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, allows_multiple_answers: bool = False,
correct_option_id: int = None, correct_option_id: int = None,
is_closed: bool = None, is_closed: bool = None,

View file

@ -87,7 +87,7 @@ def parse_file_input(
:attr:`file_input`, in case it's no valid file input. :attr:`file_input`, in case it's no valid file input.
""" """
# Importing on file-level yields cyclic Import Errors # 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://'): if isinstance(file_input, str) and file_input.startswith('file://'):
return file_input return file_input

View file

@ -16,9 +16,9 @@
# #
# You should have received a copy of the GNU Lesser Public License # You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
# pylint: disable=C0114 # pylint: disable=missing-module-docstring
from telegram import constants from telegram import constants
__version__ = '13.11' __version__ = '13.11'
bot_api_version = constants.BOT_API_VERSION # pylint: disable=C0103 bot_api_version = constants.BOT_API_VERSION # pylint: disable=invalid-name

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/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 # A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022 # Copyright (C) 2015-2022