Fix DeepSource Issues (#3357)

This commit is contained in:
Harshil 2022-11-11 22:48:42 +05:30 committed by GitHub
parent 1d1d774d9f
commit e1d56178c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 36 additions and 37 deletions

View file

@ -175,7 +175,7 @@ __all__ = ( # Keep this alphabetically ordered
) )
from . import _version from . import _version, constants, error, helpers, request, warnings
from ._bot import Bot from ._bot import Bot
from ._botcommand import BotCommand from ._botcommand import BotCommand
from ._botcommandscope import ( from ._botcommandscope import (
@ -312,6 +312,15 @@ from ._telegramobject import TelegramObject
from ._update import Update from ._update import Update
from ._user import User from ._user import User
from ._userprofilephotos import UserProfilePhotos from ._userprofilephotos import UserProfilePhotos
from ._videochat import (
VideoChatEnded,
VideoChatParticipantsInvited,
VideoChatScheduled,
VideoChatStarted,
)
from ._webappdata import WebAppData
from ._webappinfo import WebAppInfo
from ._webhookinfo import WebhookInfo
#: :obj:`str`: The version of the `python-telegram-bot` library as string. #: :obj:`str`: The version of the `python-telegram-bot` library as string.
#: To get detailed information about the version number, please use :data:`__version_info__` #: To get detailed information about the version number, please use :data:`__version_info__`
@ -335,13 +344,3 @@ __bot_api_version__ = _version.__bot_api_version__
#: #:
#: .. versionadded:: 20.0 #: .. versionadded:: 20.0
__bot_api_version_info__ = _version.__bot_api_version_info__ __bot_api_version_info__ = _version.__bot_api_version_info__
from ._videochat import (
VideoChatEnded,
VideoChatParticipantsInvited,
VideoChatScheduled,
VideoChatStarted,
)
from ._webappdata import WebAppData
from ._webappinfo import WebAppInfo
from ._webhookinfo import WebhookInfo

View file

@ -302,7 +302,7 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
@functools.wraps(func) @functools.wraps(func)
async def decorator(*args, **kwargs): # type: ignore[no-untyped-def] async def decorator(*args, **kwargs): # type: ignore[no-untyped-def]
logger.debug("Entering: %s", func.__name__) logger.debug("Entering: %s", func.__name__)
result = await func(*args, **kwargs) result = await func(*args, **kwargs) # skipcq: PYL-E1102
logger.debug(result) logger.debug(result)
logger.debug("Exiting: %s", func.__name__) logger.debug("Exiting: %s", func.__name__)
return result return result

View file

@ -420,8 +420,8 @@ class _CredentialsBase(TelegramObject):
__slots__ = ("hash", "secret", "file_hash", "data_hash") __slots__ = ("hash", "secret", "file_hash", "data_hash")
def __init__( def __init__(
self, hash: str, secret: str, *, api_kwargs: JSONDict = None self, hash: str, secret: str, *, api_kwargs: JSONDict = None # skipcq: PYL-W0622
): # skipcq: PYL-W0622 ):
super().__init__(api_kwargs=api_kwargs) super().__init__(api_kwargs=api_kwargs)
self.hash = hash self.hash = hash
self.secret = secret self.secret = secret

View file

@ -217,7 +217,7 @@ class TelegramObject:
value = getattr(self, key, None) value = getattr(self, key, None)
if value is not None: if value is not None:
if recursive and hasattr(value, "to_dict"): if recursive and hasattr(value, "to_dict"):
data[key] = value.to_dict(recursive=True) # pylint: disable=no-member data[key] = value.to_dict(recursive=True)
else: else:
data[key] = value data[key] = value
elif not recursive: elif not recursive:

View file

@ -27,7 +27,7 @@ Warning:
user. Changes to this module are not considered breaking changes and may not be documented in user. Changes to this module are not considered breaking changes and may not be documented in
the changelog. the changelog.
""" """
import datetime as dtm import datetime as dtm # skipcq: PYL-W0406
import time import time
from typing import Optional, Union from typing import Optional, Union

View file

@ -23,7 +23,7 @@ Warning:
user. Changes to this module are not considered breaking changes and may not be documented in user. Changes to this module are not considered breaking changes and may not be documented in
the changelog. the changelog.
""" """
import enum as _enum import enum as _enum # skipcq: PYL-R0201
import sys import sys
from typing import Type, TypeVar, Union from typing import Type, TypeVar, Union

View file

@ -25,7 +25,7 @@ Warning:
user. Changes to this module are not considered breaking changes and may not be documented in user. Changes to this module are not considered breaking changes and may not be documented in
the changelog. the changelog.
""" """
import warnings import warnings # skipcq: PYL-R0201
from typing import Type from typing import Type
from telegram.warnings import PTBUserWarning from telegram.warnings import PTBUserWarning

View file

@ -152,8 +152,8 @@ class CallbackQueryHandler(BaseHandler[Update, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: Update, update: Update, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Union[bool, Match], check_result: Union[bool, Match],
) -> None: ) -> None:
"""Add the result of ``re.match(pattern, update.callback_query.data)`` to """Add the result of ``re.match(pattern, update.callback_query.data)`` to

View file

@ -108,8 +108,8 @@ class ChosenInlineResultHandler(BaseHandler[Update, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: Update, update: Update, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Union[bool, Match], check_result: Union[bool, Match],
) -> None: ) -> None:
"""This function adds the matched regex pattern result to """This function adds the matched regex pattern result to

View file

@ -160,8 +160,8 @@ class CommandHandler(BaseHandler[Update, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: Update, update: Update, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]], check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
) -> None: ) -> None:
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single """Add text after the command to :attr:`CallbackContext.args` as list, split on single

View file

@ -125,8 +125,8 @@ class InlineQueryHandler(BaseHandler[Update, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: Update, update: Update, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Optional[Union[bool, Match]], check_result: Optional[Union[bool, Match]],
) -> None: ) -> None:
"""Add the result of ``re.match(pattern, update.inline_query.query)`` to """Add the result of ``re.match(pattern, update.inline_query.query)`` to

View file

@ -100,8 +100,8 @@ class MessageHandler(BaseHandler[Update, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: Update, update: Update, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Optional[Union[bool, Dict[str, object]]], check_result: Optional[Union[bool, Dict[str, object]]],
) -> None: ) -> None:
"""Adds possible output of data filters to the :class:`CallbackContext`.""" """Adds possible output of data filters to the :class:`CallbackContext`."""

View file

@ -172,8 +172,8 @@ class PrefixHandler(BaseHandler[Update, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: Update, update: Update, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]], check_result: Optional[Union[bool, Tuple[List[str], Optional[bool]]]],
) -> None: ) -> None:
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single """Add text after the command to :attr:`CallbackContext.args` as list, split on single

View file

@ -96,8 +96,8 @@ class StringCommandHandler(BaseHandler[str, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: str, update: str, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Optional[List[str]], check_result: Optional[List[str]],
) -> None: ) -> None:
"""Add text after the command to :attr:`CallbackContext.args` as list, split on single """Add text after the command to :attr:`CallbackContext.args` as list, split on single

View file

@ -103,8 +103,8 @@ class StringRegexHandler(BaseHandler[str, CCT]):
def collect_additional_context( def collect_additional_context(
self, self,
context: CCT, context: CCT,
update: str, update: str, # skipcq: BAN-B301
application: "Application", application: "Application", # skipcq: BAN-B301
check_result: Optional[Match], check_result: Optional[Match],
) -> None: ) -> None:
"""Add the result of ``re.match(pattern, update)`` to :attr:`CallbackContext.matches` as """Add the result of ``re.match(pattern, update)`` to :attr:`CallbackContext.matches` as

View file

@ -27,13 +27,13 @@ from pathlib import Path
def test_public_submodules_dunder_all(): def test_public_submodules_dunder_all():
modules_to_search = list(Path("telegram").rglob("*.py")) modules_to_search = list(Path("telegram").rglob("*.py"))
if not modules_to_search:
raise AssertionError("No modules found to search through, please modify this test.")
for mod_path in modules_to_search: for mod_path in modules_to_search:
path = str(mod_path) path = str(mod_path)
folder = mod_path.parent folder = mod_path.parent
if "vendor" in path: # skip anything vendor related
continue
if mod_path.name == "__init__.py" and "_" not in path[:-11]: # init of public submodules if mod_path.name == "__init__.py" and "_" not in path[:-11]: # init of public submodules
mod = load_module(mod_path) mod = load_module(mod_path)
assert hasattr(mod, "__all__"), f"{folder}'s __init__ does not have an __all__!" assert hasattr(mod, "__all__"), f"{folder}'s __init__ does not have an __all__!"