Skip to content

change pylint error codes to messages #2700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Patrick Hofmann <https://github.com/PH89>`_
- `Paul Larsen <https://github.com/PaulSonOfLars>`_
- `Pieter Schutz <https://github.com/eldinnie>`_
- `Piraty <https://github.com/piraty>`_
- `Poolitzer <https://github.com/Poolitzer>`_
- `Pranjalya Tiwari <https://github.com/Pranjalya>`_
- `Rahiel Kasim <https://github.com/rahiel>`_
Expand Down
2 changes: 1 addition & 1 deletion examples/arbitrarycallbackdatabot.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/chatmemberbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
5 changes: 3 additions & 2 deletions examples/contexttypesbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/conversationbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/conversationbot2.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/deeplinking.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/echobot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/errorhandlerbot.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion examples/inlinebot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/inlinekeyboard.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/inlinekeyboard2.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/nestedconversationbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/passportbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/paymentbot.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion examples/persistentconversationbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/pollbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/rawapibot.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/timerbot.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Expand Down
2 changes: 1 addition & 1 deletion telegram/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions telegram/bot.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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']]]
Expand Down Expand Up @@ -2027,15 +2028,15 @@ 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
The reason why we do this in rather than in _insert_defaults is because converting
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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 '
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion telegram/botcommand.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion telegram/botcommandscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions telegram/callbackquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions telegram/chat.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion telegram/chataction.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion telegram/choseninlineresult.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion telegram/dice.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion telegram/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions telegram/ext/basepersistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy