From baa01596c3bc978f396acef65890ea143e505224 Mon Sep 17 00:00:00 2001 From: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 7 Feb 2024 20:45:57 +0100 Subject: [PATCH] Drop Usage of DeepSource (#4100) --- .deepsource.toml | 20 ------------------- docs/auxil/link_code.py | 2 +- telegram/__main__.py | 6 +++--- telegram/_bot.py | 9 ++++----- telegram/_dice.py | 2 +- telegram/_keyboardbuttonpolltype.py | 2 +- telegram/_keyboardbuttonrequest.py | 4 ++-- telegram/_menubutton.py | 2 +- telegram/_passport/credentials.py | 8 ++++---- telegram/_utils/datetime.py | 2 +- telegram/_utils/enum.py | 2 +- telegram/_utils/warnings.py | 2 +- telegram/ext/_aioratelimiter.py | 2 +- telegram/ext/_basepersistence.py | 2 +- .../ext/_handlers/callbackqueryhandler.py | 4 ++-- .../_handlers/choseninlineresulthandler.py | 4 ++-- telegram/ext/_handlers/commandhandler.py | 4 ++-- telegram/ext/_handlers/inlinequeryhandler.py | 4 ++-- telegram/ext/_handlers/messagehandler.py | 4 ++-- telegram/ext/_handlers/prefixhandler.py | 4 ++-- .../ext/_handlers/stringcommandhandler.py | 4 ++-- telegram/ext/_handlers/stringregexhandler.py | 4 ++-- telegram/ext/_jobqueue.py | 2 +- telegram/ext/_picklepersistence.py | 2 +- telegram/ext/_utils/webhookhandler.py | 4 ++-- telegram/ext/filters.py | 8 +++----- 26 files changed, 45 insertions(+), 68 deletions(-) delete mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml deleted file mode 100644 index b46898dc8..000000000 --- a/.deepsource.toml +++ /dev/null @@ -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" diff --git a/docs/auxil/link_code.py b/docs/auxil/link_code.py index dc32f6394..da40cfeb0 100644 --- a/docs/auxil/link_code.py +++ b/docs/auxil/link_code.py @@ -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() diff --git a/telegram/__main__.py b/telegram/__main__.py index bff34c90b..9d64eb116 100644 --- a/telegram/__main__.py +++ b/telegram/__main__.py @@ -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() diff --git a/telegram/_bot.py b/telegram/_bot.py index 13a6f5e31..078587425 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -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} diff --git a/telegram/_dice.py b/telegram/_dice.py index 117282855..43fcbb5fb 100644 --- a/telegram/_dice.py +++ b/telegram/_dice.py @@ -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`""" diff --git a/telegram/_keyboardbuttonpolltype.py b/telegram/_keyboardbuttonpolltype.py index fde806c0a..d5ea851ca 100644 --- a/telegram/_keyboardbuttonpolltype.py +++ b/telegram/_keyboardbuttonpolltype.py @@ -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) diff --git a/telegram/_keyboardbuttonrequest.py b/telegram/_keyboardbuttonrequest.py index d18ed6bd9..64fbac757 100644 --- a/telegram/_keyboardbuttonrequest.py +++ b/telegram/_keyboardbuttonrequest.py @@ -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 diff --git a/telegram/_menubutton.py b/telegram/_menubutton.py index 92a1711b5..26690f8ed 100644 --- a/telegram/_menubutton.py +++ b/telegram/_menubutton.py @@ -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 diff --git a/telegram/_passport/credentials.py b/telegram/_passport/credentials.py index 44bdbb586..8dd124289 100644 --- a/telegram/_passport/credentials.py +++ b/telegram/_passport/credentials.py @@ -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, diff --git a/telegram/_utils/datetime.py b/telegram/_utils/datetime.py index b047842db..70df6b8a6 100644 --- a/telegram/_utils/datetime.py +++ b/telegram/_utils/datetime.py @@ -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 diff --git a/telegram/_utils/enum.py b/telegram/_utils/enum.py index 9353c46d6..8795d97db 100644 --- a/telegram/_utils/enum.py +++ b/telegram/_utils/enum.py @@ -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 diff --git a/telegram/_utils/warnings.py b/telegram/_utils/warnings.py index 4dea5c079..aa9d5e4c5 100644 --- a/telegram/_utils/warnings.py +++ b/telegram/_utils/warnings.py @@ -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 diff --git a/telegram/ext/_aioratelimiter.py b/telegram/ext/_aioratelimiter.py index 6138a53b7..92bc9b7e4 100644 --- a/telegram/ext/_aioratelimiter.py +++ b/telegram/ext/_aioratelimiter.py @@ -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]]: diff --git a/telegram/ext/_basepersistence.py b/telegram/ext/_basepersistence.py index cd8037db1..782c6c7bb 100644 --- a/telegram/ext/_basepersistence.py +++ b/telegram/ext/_basepersistence.py @@ -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`. diff --git a/telegram/ext/_handlers/callbackqueryhandler.py b/telegram/ext/_handlers/callbackqueryhandler.py index 264fc6af7..0ca5068d7 100644 --- a/telegram/ext/_handlers/callbackqueryhandler.py +++ b/telegram/ext/_handlers/callbackqueryhandler.py @@ -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 diff --git a/telegram/ext/_handlers/choseninlineresulthandler.py b/telegram/ext/_handlers/choseninlineresulthandler.py index a63530688..f97c58234 100644 --- a/telegram/ext/_handlers/choseninlineresulthandler.py +++ b/telegram/ext/_handlers/choseninlineresulthandler.py @@ -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 diff --git a/telegram/ext/_handlers/commandhandler.py b/telegram/ext/_handlers/commandhandler.py index 710b38cb9..a6644d39d 100644 --- a/telegram/ext/_handlers/commandhandler.py +++ b/telegram/ext/_handlers/commandhandler.py @@ -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 diff --git a/telegram/ext/_handlers/inlinequeryhandler.py b/telegram/ext/_handlers/inlinequeryhandler.py index 389e6321c..f501fbbee 100644 --- a/telegram/ext/_handlers/inlinequeryhandler.py +++ b/telegram/ext/_handlers/inlinequeryhandler.py @@ -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 diff --git a/telegram/ext/_handlers/messagehandler.py b/telegram/ext/_handlers/messagehandler.py index 148f4949a..15f589165 100644 --- a/telegram/ext/_handlers/messagehandler.py +++ b/telegram/ext/_handlers/messagehandler.py @@ -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`.""" diff --git a/telegram/ext/_handlers/prefixhandler.py b/telegram/ext/_handlers/prefixhandler.py index 05034be6d..e4f2c0e90 100644 --- a/telegram/ext/_handlers/prefixhandler.py +++ b/telegram/ext/_handlers/prefixhandler.py @@ -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 diff --git a/telegram/ext/_handlers/stringcommandhandler.py b/telegram/ext/_handlers/stringcommandhandler.py index 6be9b9a47..ae099566e 100644 --- a/telegram/ext/_handlers/stringcommandhandler.py +++ b/telegram/ext/_handlers/stringcommandhandler.py @@ -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 diff --git a/telegram/ext/_handlers/stringregexhandler.py b/telegram/ext/_handlers/stringregexhandler.py index 11050760c..9a7d51a48 100644 --- a/telegram/ext/_handlers/stringregexhandler.py +++ b/telegram/ext/_handlers/stringregexhandler.py @@ -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 diff --git a/telegram/ext/_jobqueue.py b/telegram/ext/_jobqueue.py index 1b59ebf12..1b358cc27 100644 --- a/telegram/ext/_jobqueue.py +++ b/telegram/ext/_jobqueue.py @@ -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 diff --git a/telegram/ext/_picklepersistence.py b/telegram/ext/_picklepersistence.py index adc70a006..fff11fc6c 100644 --- a/telegram/ext/_picklepersistence.py +++ b/telegram/ext/_picklepersistence.py @@ -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]]: """ diff --git a/telegram/ext/_utils/webhookhandler.py b/telegram/ext/_utils/webhookhandler.py index e6ef539a6..0d16b1005 100644 --- a/telegram/ext/_utils/webhookhandler.py +++ b/telegram/ext/_utils/webhookhandler.py @@ -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" diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index 77a2a979f..43e0beb2d 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -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: