mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 06:25:12 +01:00
Drop Usage of DeepSource (#4100)
This commit is contained in:
parent
c23eb8ec08
commit
baa01596c3
26 changed files with 45 additions and 68 deletions
|
@ -1,20 +0,0 @@
|
|||
version = 1
|
||||
|
||||
test_patterns = ["tests/**"]
|
||||
|
||||
exclude_patterns = [
|
||||
"tests/**",
|
||||
"docs/**",
|
||||
"setup.py",
|
||||
"setup-raw.py"
|
||||
]
|
||||
|
||||
[[analyzers]]
|
||||
name = "python"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
runtime_version = "3.x.x"
|
||||
max_line_length = 99
|
||||
skip_doc_coverage = ["module", "magic", "init", "nonpublic"]
|
||||
cyclomatic_complexity_threshold = "high"
|
|
@ -36,7 +36,7 @@ LINE_NUMBERS = {}
|
|||
def _git_branch() -> str:
|
||||
"""Get's the current git sha if available or fall back to `master`"""
|
||||
try:
|
||||
output = subprocess.check_output( # skipcq: BAN-B607
|
||||
output = subprocess.check_output(
|
||||
["git", "describe", "--tags", "--always"], stderr=subprocess.STDOUT
|
||||
)
|
||||
return output.decode().strip()
|
||||
|
|
|
@ -27,7 +27,7 @@ from .constants import BOT_API_VERSION
|
|||
|
||||
def _git_revision() -> Optional[str]:
|
||||
try:
|
||||
output = subprocess.check_output( # skipcq: BAN-B607
|
||||
output = subprocess.check_output(
|
||||
["git", "describe", "--long", "--tags"], stderr=subprocess.STDOUT
|
||||
)
|
||||
except (subprocess.SubprocessError, OSError):
|
||||
|
@ -35,7 +35,7 @@ def _git_revision() -> Optional[str]:
|
|||
return output.decode().strip()
|
||||
|
||||
|
||||
def print_ver_info() -> None: # skipcq: PY-D0003
|
||||
def print_ver_info() -> None:
|
||||
"""Prints version information for python-telegram-bot, the Bot API and Python."""
|
||||
git_revision = _git_revision()
|
||||
print(f"python-telegram-bot {telegram_ver}" + (f" ({git_revision})" if git_revision else ""))
|
||||
|
@ -44,7 +44,7 @@ def print_ver_info() -> None: # skipcq: PY-D0003
|
|||
print(f"Python {sys_version}")
|
||||
|
||||
|
||||
def main() -> None: # skipcq: PY-D0003
|
||||
def main() -> None:
|
||||
"""Prints version information for python-telegram-bot, the Bot API and Python."""
|
||||
print_ver_info()
|
||||
|
||||
|
|
|
@ -532,7 +532,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
|
|||
async def decorator(self: "Bot", *args: Any, **kwargs: Any) -> Any:
|
||||
# pylint: disable=protected-access
|
||||
self._LOGGER.debug("Entering: %s", func.__name__)
|
||||
result = await func(self, *args, **kwargs) # skipcq: PYL-E1102
|
||||
result = await func(self, *args, **kwargs)
|
||||
self._LOGGER.debug(result)
|
||||
self._LOGGER.debug("Exiting: %s", func.__name__)
|
||||
return result
|
||||
|
@ -554,7 +554,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
|
|||
local_mode=self._local_mode,
|
||||
)
|
||||
|
||||
def _insert_defaults(self, data: Dict[str, object]) -> None: # skipcq: PYL-R0201
|
||||
def _insert_defaults(self, data: Dict[str, object]) -> None:
|
||||
"""This method is here to make ext.Defaults work. Because we need to be able to tell
|
||||
e.g. `send_message(chat_id, text)` from `send_message(chat_id, text, parse_mode=None)`, the
|
||||
default values for `parse_mode` etc are not `None` but `DEFAULT_NONE`. While this *could*
|
||||
|
@ -2667,7 +2667,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
|
|||
api_kwargs=api_kwargs,
|
||||
)
|
||||
|
||||
def _effective_inline_results( # skipcq: PYL-R0201
|
||||
def _effective_inline_results(
|
||||
self,
|
||||
results: Union[
|
||||
Sequence["InlineQueryResult"], Callable[[int], Optional[Sequence["InlineQueryResult"]]]
|
||||
|
@ -5511,7 +5511,6 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]):
|
|||
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
) -> Tuple[Sticker, ...]:
|
||||
# skipcq: FLK-D207
|
||||
"""
|
||||
Use this method to get information about emoji stickers by their identifiers.
|
||||
|
||||
|
@ -7904,7 +7903,7 @@ CUSTOM_EMOJI_IDENTIFIER_LIMIT` custom emoji identifiers can be specified.
|
|||
bot=self,
|
||||
)
|
||||
|
||||
def to_dict(self, recursive: bool = True) -> JSONDict: # skipcq: PYL-W0613
|
||||
def to_dict(self, recursive: bool = True) -> JSONDict:
|
||||
"""See :meth:`telegram.TelegramObject.to_dict`."""
|
||||
data: JSONDict = {"id": self.id, "username": self.username, "first_name": self.first_name}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class Dice(TelegramObject):
|
|||
|
||||
self._freeze()
|
||||
|
||||
DICE: Final[str] = constants.DiceEmoji.DICE # skipcq: PTC-W0052
|
||||
DICE: Final[str] = constants.DiceEmoji.DICE
|
||||
""":const:`telegram.constants.DiceEmoji.DICE`"""
|
||||
DARTS: Final[str] = constants.DiceEmoji.DARTS
|
||||
""":const:`telegram.constants.DiceEmoji.DARTS`"""
|
||||
|
|
|
@ -53,7 +53,7 @@ class KeyboardButtonPollType(TelegramObject):
|
|||
self,
|
||||
type: Optional[str] = None, # pylint: disable=redefined-builtin
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None, # skipcq: PYL-W0622
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
self.type: Optional[str] = enum.get_member(PollType, type, type)
|
||||
|
|
|
@ -69,7 +69,7 @@ class KeyboardButtonRequestUser(TelegramObject):
|
|||
user_is_bot: Optional[bool] = None,
|
||||
user_is_premium: Optional[bool] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None, # skipcq: PYL-W0622
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
# Required
|
||||
|
@ -164,7 +164,7 @@ class KeyboardButtonRequestChat(TelegramObject):
|
|||
bot_administrator_rights: Optional[ChatAdministratorRights] = None,
|
||||
bot_is_member: Optional[bool] = None,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None, # skipcq: PYL-W0622
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
):
|
||||
super().__init__(api_kwargs=api_kwargs)
|
||||
# required
|
||||
|
|
|
@ -57,7 +57,7 @@ class MenuButton(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
type: str, # skipcq: PYL-W0622
|
||||
type: str,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
): # pylint: disable=redefined-builtin
|
||||
|
|
|
@ -47,7 +47,7 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
@no_type_check
|
||||
def decrypt(secret, hash, data): # skipcq: PYL-W0622
|
||||
def decrypt(secret, hash, data):
|
||||
"""
|
||||
Decrypt per telegram docs at https://core.telegram.org/passport.
|
||||
|
||||
|
@ -96,7 +96,7 @@ def decrypt(secret, hash, data): # skipcq: PYL-W0622
|
|||
|
||||
|
||||
@no_type_check
|
||||
def decrypt_json(secret, hash, data): # skipcq: PYL-W0622
|
||||
def decrypt_json(secret, hash, data):
|
||||
"""Decrypts data using secret and hash and then decodes utf-8 string and loads json"""
|
||||
return json.loads(decrypt(secret, hash, data).decode("utf-8"))
|
||||
|
||||
|
@ -140,7 +140,7 @@ class EncryptedCredentials(TelegramObject):
|
|||
def __init__(
|
||||
self,
|
||||
data: str,
|
||||
hash: str, # skipcq: PYL-W0622
|
||||
hash: str,
|
||||
secret: str,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
|
@ -472,7 +472,7 @@ class _CredentialsBase(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
hash: str, # skipcq: PYL-W0622
|
||||
hash: str,
|
||||
secret: str,
|
||||
*,
|
||||
api_kwargs: Optional[JSONDict] = None,
|
||||
|
|
|
@ -27,7 +27,7 @@ Warning:
|
|||
user. Changes to this module are not considered breaking changes and may not be documented in
|
||||
the changelog.
|
||||
"""
|
||||
import datetime as dtm # skipcq: PYL-W0406
|
||||
import datetime as dtm
|
||||
import time
|
||||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Warning:
|
|||
user. Changes to this module are not considered breaking changes and may not be documented in
|
||||
the changelog.
|
||||
"""
|
||||
import enum as _enum # skipcq: PYL-R0201
|
||||
import enum as _enum
|
||||
import sys
|
||||
from typing import Type, TypeVar, Union
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Warning:
|
|||
user. Changes to this module are not considered breaking changes and may not be documented in
|
||||
the changelog.
|
||||
"""
|
||||
import warnings # skipcq: PYL-R0201
|
||||
import warnings
|
||||
from typing import Type
|
||||
|
||||
from telegram.warnings import PTBUserWarning
|
||||
|
|
|
@ -208,7 +208,7 @@ class AIORateLimiter(BaseRateLimiter[int]):
|
|||
callback: Callable[..., Coroutine[Any, Any, Union[bool, JSONDict, List[JSONDict]]]],
|
||||
args: Any,
|
||||
kwargs: Dict[str, Any],
|
||||
endpoint: str, # skipcq: PYL-W0613
|
||||
endpoint: str,
|
||||
data: Dict[str, Any],
|
||||
rate_limit_args: Optional[int],
|
||||
) -> Union[bool, JSONDict, List[JSONDict]]:
|
||||
|
|
|
@ -25,7 +25,7 @@ from telegram.ext._extbot import ExtBot
|
|||
from telegram.ext._utils.types import BD, CD, UD, CDCData, ConversationDict, ConversationKey
|
||||
|
||||
|
||||
class PersistenceInput(NamedTuple): # skipcq: PYL-E0239
|
||||
class PersistenceInput(NamedTuple):
|
||||
"""Convenience wrapper to group boolean input for the :paramref:`~BasePersistence.store_data`
|
||||
parameter for :class:`BasePersistence`.
|
||||
|
||||
|
|
|
@ -159,8 +159,8 @@ class CallbackQueryHandler(BaseHandler[Update, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: Update, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: Update,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Union[bool, Match[str]],
|
||||
) -> None:
|
||||
"""Add the result of ``re.match(pattern, update.callback_query.data)`` to
|
||||
|
|
|
@ -109,8 +109,8 @@ class ChosenInlineResultHandler(BaseHandler[Update, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: Update, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: Update,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Union[bool, Match[str]],
|
||||
) -> None:
|
||||
"""This function adds the matched regex pattern result to
|
||||
|
|
|
@ -207,8 +207,8 @@ class CommandHandler(BaseHandler[Update, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: Update, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: Update,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
|
||||
) -> None:
|
||||
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single
|
||||
|
|
|
@ -130,8 +130,8 @@ class InlineQueryHandler(BaseHandler[Update, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: Update, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: Update,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Optional[Union[bool, Match[str]]],
|
||||
) -> None:
|
||||
"""Add the result of ``re.match(pattern, update.inline_query.query)`` to
|
||||
|
|
|
@ -102,8 +102,8 @@ class MessageHandler(BaseHandler[Update, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: Update, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: Update,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Optional[Union[bool, Dict[str, object]]],
|
||||
) -> None:
|
||||
"""Adds possible output of data filters to the :class:`CallbackContext`."""
|
||||
|
|
|
@ -171,8 +171,8 @@ class PrefixHandler(BaseHandler[Update, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: Update, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: Update,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
|
||||
) -> None:
|
||||
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single
|
||||
|
|
|
@ -98,8 +98,8 @@ class StringCommandHandler(BaseHandler[str, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: str, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: str,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Optional[List[str]],
|
||||
) -> None:
|
||||
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single
|
||||
|
|
|
@ -103,8 +103,8 @@ class StringRegexHandler(BaseHandler[str, CCT]):
|
|||
def collect_additional_context(
|
||||
self,
|
||||
context: CCT,
|
||||
update: str, # skipcq: BAN-B301
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]", # skipcq: BAN-B301
|
||||
update: str,
|
||||
application: "Application[Any, CCT, Any, Any, Any, Any]",
|
||||
check_result: Optional[Match[str]],
|
||||
) -> None:
|
||||
"""Add the result of ``re.match(pattern, update)`` to :attr:`CallbackContext.matches` as
|
||||
|
|
|
@ -816,7 +816,7 @@ class Job(Generic[CCT]):
|
|||
self._removed = False
|
||||
self._enabled = False
|
||||
|
||||
self._job = cast("APSJob", None) # skipcq: PTC-W0052
|
||||
self._job = cast("APSJob", None)
|
||||
|
||||
def __getattr__(self, item: str) -> object:
|
||||
"""Overrides :py:meth:`object.__getattr__` to get specific attribute of the
|
||||
|
|
|
@ -74,7 +74,7 @@ class _BotPickler(pickle.Pickler):
|
|||
self._bot = bot
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def reducer_override( # skipcq: PYL-R0201
|
||||
def reducer_override(
|
||||
self, obj: TelegramObj
|
||||
) -> Tuple[Callable, Tuple[Type[TelegramObj], dict]]:
|
||||
"""
|
||||
|
|
|
@ -138,8 +138,8 @@ class TelegramHandler(tornado.web.RequestHandler):
|
|||
"""Initialize for each request - that's the interface provided by tornado"""
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.bot = bot
|
||||
self.update_queue = update_queue # skipcq: PYL-W0201
|
||||
self.secret_token = secret_token # skipcq: PYL-W0201
|
||||
self.update_queue = update_queue
|
||||
self.secret_token = secret_token
|
||||
if secret_token:
|
||||
_LOGGER.debug(
|
||||
"The webhook server has a secret token, expecting it in incoming requests now"
|
||||
|
|
|
@ -256,9 +256,7 @@ class BaseFilter:
|
|||
def name(self, name: str) -> None:
|
||||
self._name = name
|
||||
|
||||
def check_update( # skipcq: PYL-R0201
|
||||
self, update: Update
|
||||
) -> Optional[Union[bool, FilterDataDict]]:
|
||||
def check_update(self, update: Update) -> Optional[Union[bool, FilterDataDict]]:
|
||||
"""Checks if the specified update should be handled by this filter.
|
||||
|
||||
Args:
|
||||
|
@ -1121,7 +1119,7 @@ class Dice(_Dice):
|
|||
def __init__(self, values: SCT[int]):
|
||||
super().__init__(values, emoji=DiceEmojiEnum.DICE)
|
||||
|
||||
DICE = _Dice(emoji=DiceEmojiEnum.DICE) # skipcq: PTC-W0052
|
||||
DICE = _Dice(emoji=DiceEmojiEnum.DICE)
|
||||
"""Dice messages with the emoji 🎲. Matches any dice value."""
|
||||
|
||||
class Football(_Dice):
|
||||
|
@ -1294,7 +1292,7 @@ class Document:
|
|||
__slots__ = ("mimetype",)
|
||||
|
||||
def __init__(self, mimetype: str):
|
||||
self.mimetype: str = mimetype # skipcq: PTC-W0052
|
||||
self.mimetype: str = mimetype
|
||||
super().__init__(name=f"filters.Document.MimeType('{self.mimetype}')")
|
||||
|
||||
def filter(self, message: Message) -> bool:
|
||||
|
|
Loading…
Reference in a new issue