mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-27 08:50:38 +01:00
[pre-commit.ci] pre-commit autoupdate (#3967)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
This commit is contained in:
parent
da3bc6974a
commit
dd9af64a5c
8 changed files with 33 additions and 21 deletions
|
@ -6,7 +6,7 @@ ci:
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 23.9.1
|
rev: 23.10.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args:
|
args:
|
||||||
|
@ -17,7 +17,7 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
- repo: https://github.com/PyCQA/pylint
|
- repo: https://github.com/PyCQA/pylint
|
||||||
rev: v3.0.0
|
rev: v3.0.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
files: ^(telegram|examples)/.*\.py$
|
files: ^(telegram|examples)/.*\.py$
|
||||||
|
@ -35,7 +35,7 @@ repos:
|
||||||
- aiolimiter~=1.1.0
|
- aiolimiter~=1.1.0
|
||||||
- . # this basically does `pip install -e .`
|
- . # this basically does `pip install -e .`
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v1.5.1
|
rev: v1.6.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
name: mypy-ptb
|
name: mypy-ptb
|
||||||
|
@ -62,7 +62,7 @@ repos:
|
||||||
- cachetools~=5.3.2
|
- cachetools~=5.3.2
|
||||||
- . # this basically does `pip install -e .`
|
- . # this basically does `pip install -e .`
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.13.0
|
rev: v3.15.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
files: ^(telegram|examples|tests|docs)/.*\.py$
|
files: ^(telegram|examples|tests|docs)/.*\.py$
|
||||||
|
@ -77,7 +77,7 @@ repos:
|
||||||
- --diff
|
- --diff
|
||||||
- --check
|
- --check
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: 'v0.0.292'
|
rev: 'v0.1.5'
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
name: ruff
|
name: ruff
|
||||||
|
|
|
@ -55,7 +55,10 @@ class MenuButton(TelegramObject):
|
||||||
__slots__ = ("type",)
|
__slots__ = ("type",)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, type: str, *, api_kwargs: Optional[JSONDict] = None # skipcq: PYL-W0622
|
self,
|
||||||
|
type: str, # skipcq: PYL-W0622
|
||||||
|
*,
|
||||||
|
api_kwargs: Optional[JSONDict] = None,
|
||||||
): # pylint: disable=redefined-builtin
|
): # pylint: disable=redefined-builtin
|
||||||
super().__init__(api_kwargs=api_kwargs)
|
super().__init__(api_kwargs=api_kwargs)
|
||||||
self.type: str = type
|
self.type: str = type
|
||||||
|
|
|
@ -471,7 +471,11 @@ 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: Optional[JSONDict] = None # skipcq: PYL-W0622
|
self,
|
||||||
|
hash: str, # skipcq: PYL-W0622
|
||||||
|
secret: str,
|
||||||
|
*,
|
||||||
|
api_kwargs: Optional[JSONDict] = None,
|
||||||
):
|
):
|
||||||
super().__init__(api_kwargs=api_kwargs)
|
super().__init__(api_kwargs=api_kwargs)
|
||||||
with self._unfrozen():
|
with self._unfrozen():
|
||||||
|
|
|
@ -1086,7 +1086,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
|
||||||
return await asyncio.create_task(coroutine)
|
return await asyncio.create_task(coroutine)
|
||||||
# If user uses generator in python 3.12+, Exception will happen and we cannot do
|
# If user uses generator in python 3.12+, Exception will happen and we cannot do
|
||||||
# anything about it. (hence the type ignore if mypy is run on python 3.12-)
|
# anything about it. (hence the type ignore if mypy is run on python 3.12-)
|
||||||
return await coroutine # type: ignore
|
return await coroutine # type: ignore[misc]
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
if isinstance(exception, ApplicationHandlerStop):
|
if isinstance(exception, ApplicationHandlerStop):
|
||||||
warn(
|
warn(
|
||||||
|
@ -1367,7 +1367,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
|
||||||
chat_id (:obj:`int`): The chat id to delete. The entry will be deleted even if it is
|
chat_id (:obj:`int`): The chat id to delete. The entry will be deleted even if it is
|
||||||
not empty.
|
not empty.
|
||||||
"""
|
"""
|
||||||
self._chat_data.pop(chat_id, None) # type: ignore[arg-type]
|
self._chat_data.pop(chat_id, None)
|
||||||
self._chat_ids_to_be_deleted_in_persistence.add(chat_id)
|
self._chat_ids_to_be_deleted_in_persistence.add(chat_id)
|
||||||
|
|
||||||
def drop_user_data(self, user_id: int) -> None:
|
def drop_user_data(self, user_id: int) -> None:
|
||||||
|
@ -1386,7 +1386,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica
|
||||||
user_id (:obj:`int`): The user id to delete. The entry will be deleted even if it is
|
user_id (:obj:`int`): The user id to delete. The entry will be deleted even if it is
|
||||||
not empty.
|
not empty.
|
||||||
"""
|
"""
|
||||||
self._user_data.pop(user_id, None) # type: ignore[arg-type]
|
self._user_data.pop(user_id, None)
|
||||||
self._user_ids_to_be_deleted_in_persistence.add(user_id)
|
self._user_ids_to_be_deleted_in_persistence.add(user_id)
|
||||||
|
|
||||||
def migrate_chat_data(
|
def migrate_chat_data(
|
||||||
|
|
|
@ -51,6 +51,7 @@ from telegram.request._httpxrequest import HTTPXRequest
|
||||||
from telegram.warnings import PTBDeprecationWarning
|
from telegram.warnings import PTBDeprecationWarning
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from telegram import Update
|
||||||
from telegram.ext import BasePersistence, BaseRateLimiter, CallbackContext, Defaults
|
from telegram.ext import BasePersistence, BaseRateLimiter, CallbackContext, Defaults
|
||||||
from telegram.ext._utils.types import RLARGS
|
from telegram.ext._utils.types import RLARGS
|
||||||
|
|
||||||
|
@ -197,7 +198,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
|
||||||
self._arbitrary_callback_data: Union[DefaultValue[bool], int] = DEFAULT_FALSE
|
self._arbitrary_callback_data: Union[DefaultValue[bool], int] = DEFAULT_FALSE
|
||||||
self._local_mode: DVType[bool] = DEFAULT_FALSE
|
self._local_mode: DVType[bool] = DEFAULT_FALSE
|
||||||
self._bot: DVInput[Bot] = DEFAULT_NONE
|
self._bot: DVInput[Bot] = DEFAULT_NONE
|
||||||
self._update_queue: DVType[Queue] = DefaultValue(Queue())
|
self._update_queue: DVType[Queue[Union[Update, object]]] = DefaultValue(Queue())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._job_queue: ODVInput[JobQueue] = DefaultValue(JobQueue())
|
self._job_queue: ODVInput[JobQueue] = DefaultValue(JobQueue())
|
||||||
|
@ -271,7 +272,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
|
||||||
arbitrary_callback_data=DefaultValue.get_value(self._arbitrary_callback_data),
|
arbitrary_callback_data=DefaultValue.get_value(self._arbitrary_callback_data),
|
||||||
request=self._build_request(get_updates=False),
|
request=self._build_request(get_updates=False),
|
||||||
get_updates_request=self._build_request(get_updates=True),
|
get_updates_request=self._build_request(get_updates=True),
|
||||||
rate_limiter=DefaultValue.get_value(self._rate_limiter),
|
rate_limiter=DefaultValue.get_value(self._rate_limiter), # type: ignore[arg-type]
|
||||||
local_mode=DefaultValue.get_value(self._local_mode),
|
local_mode=DefaultValue.get_value(self._local_mode),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -316,7 +317,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
|
||||||
|
|
||||||
application: Application[
|
application: Application[
|
||||||
BT, CCT, UD, CD, BD, JQ
|
BT, CCT, UD, CD, BD, JQ
|
||||||
] = DefaultValue.get_value( # pylint: disable=not-callable
|
] = DefaultValue.get_value( # type: ignore[operator] # pylint: disable=not-callable
|
||||||
self._application_class
|
self._application_class
|
||||||
)(
|
)(
|
||||||
bot=bot,
|
bot=bot,
|
||||||
|
@ -324,7 +325,7 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
|
||||||
updater=updater,
|
updater=updater,
|
||||||
update_processor=self._update_processor,
|
update_processor=self._update_processor,
|
||||||
job_queue=job_queue,
|
job_queue=job_queue,
|
||||||
persistence=persistence,
|
persistence=persistence, # type: ignore[arg-type]
|
||||||
context_types=DefaultValue.get_value(self._context_types),
|
context_types=DefaultValue.get_value(self._context_types),
|
||||||
post_init=self._post_init,
|
post_init=self._post_init,
|
||||||
post_shutdown=self._post_shutdown,
|
post_shutdown=self._post_shutdown,
|
||||||
|
@ -333,12 +334,12 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
|
||||||
)
|
)
|
||||||
|
|
||||||
if job_queue is not None:
|
if job_queue is not None:
|
||||||
job_queue.set_application(application) # type: ignore[arg-type]
|
job_queue.set_application(application) # type: ignore[arg-type, union-attr]
|
||||||
|
|
||||||
if persistence is not None:
|
if persistence is not None:
|
||||||
# This raises an exception if persistence.store_data.callback_data is True
|
# This raises an exception if persistence.store_data.callback_data is True
|
||||||
# but self.bot is not an instance of ExtBot - so no need to check that later on
|
# but self.bot is not an instance of ExtBot - so no need to check that later on
|
||||||
persistence.set_bot(bot)
|
persistence.set_bot(bot) # type: ignore[union-attr]
|
||||||
|
|
||||||
return application
|
return application
|
||||||
|
|
||||||
|
|
|
@ -236,11 +236,13 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
|
||||||
await self.application.persistence.refresh_bot_data(self.bot_data)
|
await self.application.persistence.refresh_bot_data(self.bot_data)
|
||||||
if self.application.persistence.store_data.chat_data and self._chat_id is not None:
|
if self.application.persistence.store_data.chat_data and self._chat_id is not None:
|
||||||
await self.application.persistence.refresh_chat_data(
|
await self.application.persistence.refresh_chat_data(
|
||||||
chat_id=self._chat_id, chat_data=self.chat_data # type: ignore[arg-type]
|
chat_id=self._chat_id,
|
||||||
|
chat_data=self.chat_data, # type: ignore[arg-type]
|
||||||
)
|
)
|
||||||
if self.application.persistence.store_data.user_data and self._user_id is not None:
|
if self.application.persistence.store_data.user_data and self._user_id is not None:
|
||||||
await self.application.persistence.refresh_user_data(
|
await self.application.persistence.refresh_user_data(
|
||||||
user_id=self._user_id, user_data=self.user_data # type: ignore[arg-type]
|
user_id=self._user_id,
|
||||||
|
user_data=self.user_data, # type: ignore[arg-type]
|
||||||
)
|
)
|
||||||
|
|
||||||
def drop_callback_data(self, callback_query: CallbackQuery) -> None:
|
def drop_callback_data(self, callback_query: CallbackQuery) -> None:
|
||||||
|
|
|
@ -492,7 +492,7 @@ class PicklePersistence(BasePersistence[UD, CD, BD]):
|
||||||
"""
|
"""
|
||||||
if self.chat_data is None:
|
if self.chat_data is None:
|
||||||
return
|
return
|
||||||
self.chat_data.pop(chat_id, None) # type: ignore[arg-type]
|
self.chat_data.pop(chat_id, None)
|
||||||
|
|
||||||
if not self.on_flush:
|
if not self.on_flush:
|
||||||
if not self.single_file:
|
if not self.single_file:
|
||||||
|
@ -511,7 +511,7 @@ class PicklePersistence(BasePersistence[UD, CD, BD]):
|
||||||
"""
|
"""
|
||||||
if self.user_data is None:
|
if self.user_data is None:
|
||||||
return
|
return
|
||||||
self.user_data.pop(user_id, None) # type: ignore[arg-type]
|
self.user_data.pop(user_id, None)
|
||||||
|
|
||||||
if not self.on_flush:
|
if not self.on_flush:
|
||||||
if not self.single_file:
|
if not self.single_file:
|
||||||
|
|
|
@ -99,7 +99,9 @@ class TrackingDict(UserDict, Generic[_KT, _VT]):
|
||||||
# Mypy seems a bit inconsistent about what it wants as types for `default` and return value
|
# Mypy seems a bit inconsistent about what it wants as types for `default` and return value
|
||||||
# so we just ignore a bit
|
# so we just ignore a bit
|
||||||
def pop( # type: ignore[override]
|
def pop( # type: ignore[override]
|
||||||
self, key: _KT, default: _VT = DEFAULT_NONE # type: ignore[assignment]
|
self,
|
||||||
|
key: _KT,
|
||||||
|
default: _VT = DEFAULT_NONE, # type: ignore[assignment]
|
||||||
) -> _VT:
|
) -> _VT:
|
||||||
if key in self:
|
if key in self:
|
||||||
self.__track_write(key)
|
self.__track_write(key)
|
||||||
|
|
Loading…
Add table
Reference in a new issue