Skip to content
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

Drop Usage of DeepSource #4100

Merged
merged 3 commits into from Feb 7, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 0 additions & 20 deletions .deepsource.toml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/auxil/link_code.py
Expand Up @@ -36,7 +36,7 @@
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()
Expand Down
6 changes: 3 additions & 3 deletions telegram/__main__.py
Expand Up @@ -27,15 +27,15 @@

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):
return None
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 ""))
Expand All @@ -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()

Expand Down
9 changes: 4 additions & 5 deletions telegram/_bot.py
Expand Up @@ -532,7 +532,7 @@ def _log(func: Any): # type: ignore[no-untyped-def] # skipcq: PY-D0003
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
Expand All @@ -554,7 +554,7 @@ def _parse_file_input(
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*
Expand Down Expand Up @@ -2667,7 +2667,7 @@ async def send_chat_action(
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"]]]
Expand Down Expand Up @@ -5511,7 +5511,6 @@ async def get_custom_emoji_stickers(
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.

Expand Down Expand Up @@ -7904,7 +7903,7 @@ async def get_my_name(
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}

Expand Down
2 changes: 1 addition & 1 deletion telegram/_dice.py
Expand Up @@ -98,7 +98,7 @@ def __init__(self, value: int, emoji: str, *, api_kwargs: Optional[JSONDict] = N

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`"""
Expand Down
2 changes: 1 addition & 1 deletion telegram/_keyboardbuttonpolltype.py
Expand Up @@ -53,7 +53,7 @@ def __init__(
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)
Expand Down
4 changes: 2 additions & 2 deletions telegram/_keyboardbuttonrequest.py
Expand Up @@ -69,7 +69,7 @@ def __init__(
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
Expand Down Expand Up @@ -164,7 +164,7 @@ def __init__(
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
Expand Down
2 changes: 1 addition & 1 deletion telegram/_menubutton.py
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions telegram/_passport/credentials.py
Expand Up @@ -47,7 +47,7 @@


@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.

Expand Down Expand Up @@ -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"))

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -472,7 +472,7 @@ class _CredentialsBase(TelegramObject):

def __init__(
self,
hash: str, # skipcq: PYL-W0622
hash: str,
secret: str,
*,
api_kwargs: Optional[JSONDict] = None,
Expand Down
2 changes: 1 addition & 1 deletion telegram/_utils/datetime.py
Expand Up @@ -27,7 +27,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion telegram/_utils/enum.py
Expand Up @@ -23,7 +23,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion telegram/_utils/warnings.py
Expand Up @@ -25,7 +25,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion telegram/ext/_aioratelimiter.py
Expand Up @@ -208,7 +208,7 @@ async def process_request(
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]]:
Expand Down
2 changes: 1 addition & 1 deletion telegram/ext/_basepersistence.py
Expand Up @@ -25,7 +25,7 @@
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`.

Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/callbackqueryhandler.py
Expand Up @@ -159,8 +159,8 @@ def check_update(self, update: object) -> Optional[Union[bool, object]]:
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
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/choseninlineresulthandler.py
Expand Up @@ -109,8 +109,8 @@ def check_update(self, update: object) -> Optional[Union[bool, object]]:
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
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/commandhandler.py
Expand Up @@ -207,8 +207,8 @@ def check_update(
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
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/inlinequeryhandler.py
Expand Up @@ -130,8 +130,8 @@ def check_update(self, update: object) -> Optional[Union[bool, Match[str]]]:
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
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/messagehandler.py
Expand Up @@ -102,8 +102,8 @@ def check_update(self, update: object) -> Optional[Union[bool, Dict[str, List[An
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`."""
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/prefixhandler.py
Expand Up @@ -171,8 +171,8 @@ def check_update(
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
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/stringcommandhandler.py
Expand Up @@ -98,8 +98,8 @@ def check_update(self, update: object) -> Optional[List[str]]:
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
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_handlers/stringregexhandler.py
Expand Up @@ -103,8 +103,8 @@ def check_update(self, update: object) -> Optional[Match[str]]:
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
Expand Down
2 changes: 1 addition & 1 deletion telegram/ext/_jobqueue.py
Expand Up @@ -816,7 +816,7 @@ def __init__(
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
Expand Down
2 changes: 1 addition & 1 deletion telegram/ext/_picklepersistence.py
Expand Up @@ -74,7 +74,7 @@ def __init__(self, bot: Bot, *args: Any, **kwargs: Any):
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]]:
"""
Expand Down
4 changes: 2 additions & 2 deletions telegram/ext/_utils/webhookhandler.py
Expand Up @@ -138,8 +138,8 @@ def initialize(self, bot: "Bot", update_queue: asyncio.Queue, secret_token: str)
"""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"
Expand Down
8 changes: 3 additions & 5 deletions telegram/ext/filters.py
Expand Up @@ -256,9 +256,7 @@ def name(self) -> str:
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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -1294,7 +1292,7 @@ class MimeType(MessageFilter):
__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:
Expand Down