From f77f4b0cf7629766be0b4eb4c7288109c16a291c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 9 Sep 2023 23:12:30 +0200 Subject: [PATCH] `pre-commit` autoupdate (#3876) 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> --- .pre-commit-config.yaml | 6 +++--- examples/arbitrarycallbackdatabot.py | 2 +- examples/chatmemberbot.py | 2 +- examples/contexttypesbot.py | 2 +- examples/conversationbot.py | 2 +- examples/conversationbot2.py | 2 +- examples/deeplinking.py | 2 +- examples/echobot.py | 2 +- examples/errorhandlerbot.py | 2 +- examples/inlinebot.py | 2 +- examples/inlinekeyboard.py | 2 +- examples/inlinekeyboard2.py | 2 +- examples/nestedconversationbot.py | 2 +- examples/passportbot.py | 2 +- examples/paymentbot.py | 2 +- examples/persistentconversationbot.py | 2 +- examples/pollbot.py | 2 +- examples/rawapibot.py | 1 - examples/timerbot.py | 2 +- examples/webappbot.py | 2 +- setup.cfg | 2 +- telegram/_bot.py | 6 +++--- telegram/_callbackquery.py | 2 +- telegram/_chat.py | 2 +- telegram/_inline/inlinequery.py | 2 +- telegram/_inline/inlinequeryresult.py | 2 +- telegram/_message.py | 2 +- telegram/_payment/precheckoutquery.py | 4 ++-- telegram/_payment/shippingoption.py | 2 +- telegram/_payment/shippingquery.py | 4 ++-- telegram/_poll.py | 2 +- telegram/_user.py | 2 +- telegram/_utils/datetime.py | 9 ++++----- telegram/ext/_application.py | 2 +- telegram/ext/_jobqueue.py | 4 ++-- telegram/ext/_updater.py | 2 +- telegram/warnings.py | 3 +-- 37 files changed, 46 insertions(+), 49 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1d509405c..8aa85c5a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/PyCQA/pylint - rev: v3.0.0a6 + rev: v3.0.0a7 hooks: - id: pylint files: ^(telegram|examples)/.*\.py$ @@ -35,7 +35,7 @@ repos: - aiolimiter~=1.1.0 - . # this basically does `pip install -e .` - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.5.1 hooks: - id: mypy name: mypy-ptb @@ -77,7 +77,7 @@ repos: - --diff - --check - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.0.281' + rev: 'v0.0.287' hooks: - id: ruff name: ruff diff --git a/examples/arbitrarycallbackdatabot.py b/examples/arbitrarycallbackdatabot.py index b6cab3e4d..cf3d46fa9 100644 --- a/examples/arbitrarycallbackdatabot.py +++ b/examples/arbitrarycallbackdatabot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """This example showcases how PTBs "arbitrary callback data" feature can be used. diff --git a/examples/chatmemberbot.py b/examples/chatmemberbot.py index ec3851539..dd299b73a 100644 --- a/examples/chatmemberbot.py +++ b/examples/chatmemberbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/contexttypesbot.py b/examples/contexttypesbot.py index 0d3870d37..890aebf45 100644 --- a/examples/contexttypesbot.py +++ b/examples/contexttypesbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/conversationbot.py b/examples/conversationbot.py index 9f3b3e110..751f48f74 100644 --- a/examples/conversationbot.py +++ b/examples/conversationbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/conversationbot2.py b/examples/conversationbot2.py index 8d7af9045..6a5e54a8e 100644 --- a/examples/conversationbot2.py +++ b/examples/conversationbot2.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/deeplinking.py b/examples/deeplinking.py index 1262491d9..b744f028b 100644 --- a/examples/deeplinking.py +++ b/examples/deeplinking.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """Bot that explains Telegram's "Deep Linking Parameters" functionality. diff --git a/examples/echobot.py b/examples/echobot.py index 63dfb1dcc..b2ccdc139 100644 --- a/examples/echobot.py +++ b/examples/echobot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/errorhandlerbot.py b/examples/errorhandlerbot.py index 89a6a2e72..fa692850f 100644 --- a/examples/errorhandlerbot.py +++ b/examples/errorhandlerbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """This is a very simple example on how one could implement a custom error handler.""" diff --git a/examples/inlinebot.py b/examples/inlinebot.py index 9cd9e050c..566cfe14b 100644 --- a/examples/inlinebot.py +++ b/examples/inlinebot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/inlinekeyboard.py b/examples/inlinekeyboard.py index f1a8cf0df..ee82c4e81 100644 --- a/examples/inlinekeyboard.py +++ b/examples/inlinekeyboard.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/inlinekeyboard2.py b/examples/inlinekeyboard2.py index cab151b70..639fde4dd 100644 --- a/examples/inlinekeyboard2.py +++ b/examples/inlinekeyboard2.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """Simple inline keyboard bot with multiple CallbackQueryHandlers. diff --git a/examples/nestedconversationbot.py b/examples/nestedconversationbot.py index 74cb553f0..918f0becf 100644 --- a/examples/nestedconversationbot.py +++ b/examples/nestedconversationbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/passportbot.py b/examples/passportbot.py index 8d3c440ec..e6d783240 100644 --- a/examples/passportbot.py +++ b/examples/passportbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/paymentbot.py b/examples/paymentbot.py index 0ec7fa466..a18ee6c28 100644 --- a/examples/paymentbot.py +++ b/examples/paymentbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """Basic example for a bot that can receive payment from user.""" diff --git a/examples/persistentconversationbot.py b/examples/persistentconversationbot.py index 6ace99b18..bdc9c1c50 100644 --- a/examples/persistentconversationbot.py +++ b/examples/persistentconversationbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/pollbot.py b/examples/pollbot.py index d0f4d3b80..71446e9a8 100644 --- a/examples/pollbot.py +++ b/examples/pollbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/rawapibot.py b/examples/rawapibot.py index 50aeb83b2..b6a70fc3d 100644 --- a/examples/rawapibot.py +++ b/examples/rawapibot.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# pylint: disable=import-error """Simple Bot to reply to Telegram messages. This is built on the API wrapper, see echobot.py to see the same example built diff --git a/examples/timerbot.py b/examples/timerbot.py index a046e5409..462780b13 100644 --- a/examples/timerbot.py +++ b/examples/timerbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument, import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/examples/webappbot.py b/examples/webappbot.py index caec94efe..cf8df2364 100644 --- a/examples/webappbot.py +++ b/examples/webappbot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# pylint: disable=unused-argument,import-error +# pylint: disable=unused-argument # This program is dedicated to the public domain under the CC0 license. """ diff --git a/setup.cfg b/setup.cfg index 75d7008b7..b1d2672e1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,7 +19,7 @@ exclude = setup.py, setup-raw.py docs/source/conf.py disable = duplicate-code,too-many-arguments,too-many-public-methods,too-few-public-methods, broad-except,too-many-instance-attributes,fixme,missing-function-docstring, missing-class-docstring,too-many-locals,too-many-lines,too-many-branches, - too-many-statements + too-many-statements, cyclic-import enable=useless-suppression ; Warns about unused pylint ignores exclude-protected=_unfrozen diff --git a/telegram/_bot.py b/telegram/_bot.py index b64768409..34263fd94 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -668,7 +668,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): return self._bot_user @property - def id(self) -> int: # pylint: disable=invalid-name + def id(self) -> int: """:obj:`int`: Unique identifier for this bot. Shortcut for the corresponding attribute of :attr:`bot`. """ @@ -4317,7 +4317,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): ) @_log - async def answer_shipping_query( # pylint: disable=invalid-name + async def answer_shipping_query( self, shipping_query_id: str, ok: bool, @@ -4376,7 +4376,7 @@ class Bot(TelegramObject, AsyncContextManager["Bot"]): ) @_log - async def answer_pre_checkout_query( # pylint: disable=invalid-name + async def answer_pre_checkout_query( self, pre_checkout_query_id: str, ok: bool, diff --git a/telegram/_callbackquery.py b/telegram/_callbackquery.py index d2c242e3d..926cf08c2 100644 --- a/telegram/_callbackquery.py +++ b/telegram/_callbackquery.py @@ -127,7 +127,7 @@ class CallbackQuery(TelegramObject): ): super().__init__(api_kwargs=api_kwargs) # Required - self.id: str = id # pylint: disable=invalid-name + self.id: str = id self.from_user: User = from_user self.chat_instance: str = chat_instance # Optionals diff --git a/telegram/_chat.py b/telegram/_chat.py index a45b295cc..c122fd314 100644 --- a/telegram/_chat.py +++ b/telegram/_chat.py @@ -374,7 +374,7 @@ class Chat(TelegramObject): ): super().__init__(api_kwargs=api_kwargs) # Required - self.id: int = id # pylint: disable=invalid-name + self.id: int = id self.type: str = enum.get_member(constants.ChatType, type, type) # Optionals self.title: Optional[str] = title diff --git a/telegram/_inline/inlinequery.py b/telegram/_inline/inlinequery.py index 63a73b8ac..3b38b37fe 100644 --- a/telegram/_inline/inlinequery.py +++ b/telegram/_inline/inlinequery.py @@ -111,7 +111,7 @@ class InlineQuery(TelegramObject): ): super().__init__(api_kwargs=api_kwargs) # Required - self.id: str = id # pylint: disable=invalid-name + self.id: str = id self.from_user: User = from_user self.query: str = query self.offset: str = offset diff --git a/telegram/_inline/inlinequeryresult.py b/telegram/_inline/inlinequeryresult.py index a40387be3..634067e81 100644 --- a/telegram/_inline/inlinequeryresult.py +++ b/telegram/_inline/inlinequeryresult.py @@ -60,7 +60,7 @@ class InlineQueryResult(TelegramObject): # Required self.type: str = type - self.id: str = str(id) # pylint: disable=invalid-name + self.id: str = str(id) self._id_attrs = (self.id,) diff --git a/telegram/_message.py b/telegram/_message.py index 40ed17f79..80f4098a8 100644 --- a/telegram/_message.py +++ b/telegram/_message.py @@ -854,7 +854,7 @@ class Message(TelegramObject): return self.chat.id @property - def id(self) -> int: # pylint: disable=invalid-name + def id(self) -> int: """ :obj:`int`: Shortcut for :attr:`message_id`. diff --git a/telegram/_payment/precheckoutquery.py b/telegram/_payment/precheckoutquery.py index a6b152812..168c23a56 100644 --- a/telegram/_payment/precheckoutquery.py +++ b/telegram/_payment/precheckoutquery.py @@ -95,7 +95,7 @@ class PreCheckoutQuery(TelegramObject): api_kwargs: Optional[JSONDict] = None, ): super().__init__(api_kwargs=api_kwargs) - self.id: str = id # pylint: disable=invalid-name + self.id: str = id self.from_user: User = from_user self.currency: str = currency self.total_amount: int = total_amount @@ -120,7 +120,7 @@ class PreCheckoutQuery(TelegramObject): return super().de_json(data=data, bot=bot) - async def answer( # pylint: disable=invalid-name + async def answer( self, ok: bool, error_message: Optional[str] = None, diff --git a/telegram/_payment/shippingoption.py b/telegram/_payment/shippingoption.py index 2fea44460..d98908907 100644 --- a/telegram/_payment/shippingoption.py +++ b/telegram/_payment/shippingoption.py @@ -66,7 +66,7 @@ class ShippingOption(TelegramObject): ): super().__init__(api_kwargs=api_kwargs) - self.id: str = id # pylint: disable=invalid-name + self.id: str = id self.title: str = title self.prices: Tuple[LabeledPrice, ...] = parse_sequence_arg(prices) diff --git a/telegram/_payment/shippingquery.py b/telegram/_payment/shippingquery.py index 85e94170d..dbe6130b6 100644 --- a/telegram/_payment/shippingquery.py +++ b/telegram/_payment/shippingquery.py @@ -67,7 +67,7 @@ class ShippingQuery(TelegramObject): api_kwargs: Optional[JSONDict] = None, ): super().__init__(api_kwargs=api_kwargs) - self.id: str = id # pylint: disable=invalid-name + self.id: str = id self.from_user: User = from_user self.invoice_payload: str = invoice_payload self.shipping_address: ShippingAddress = shipping_address @@ -89,7 +89,7 @@ class ShippingQuery(TelegramObject): return super().de_json(data=data, bot=bot) - async def answer( # pylint: disable=invalid-name + async def answer( self, ok: bool, shipping_options: Optional[Sequence[ShippingOption]] = None, diff --git a/telegram/_poll.py b/telegram/_poll.py index b33331076..ce2c41c7c 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -302,7 +302,7 @@ class Poll(TelegramObject): api_kwargs: Optional[JSONDict] = None, ): super().__init__(api_kwargs=api_kwargs) - self.id: str = id # pylint: disable=invalid-name + self.id: str = id self.question: str = question self.options: Tuple[PollOption, ...] = parse_sequence_arg(options) self.total_voter_count: int = total_voter_count diff --git a/telegram/_user.py b/telegram/_user.py index 20e777ecc..8055c6b83 100644 --- a/telegram/_user.py +++ b/telegram/_user.py @@ -153,7 +153,7 @@ class User(TelegramObject): ): super().__init__(api_kwargs=api_kwargs) # Required - self.id: int = id # pylint: disable=invalid-name + self.id: int = id self.first_name: str = first_name self.is_bot: bool = is_bot # Optionals diff --git a/telegram/_utils/datetime.py b/telegram/_utils/datetime.py index d8a6e3dda..b047842db 100644 --- a/telegram/_utils/datetime.py +++ b/telegram/_utils/datetime.py @@ -53,7 +53,7 @@ def _localize(datetime: dtm.datetime, tzinfo: dtm.tzinfo) -> dtm.datetime: def to_float_timestamp( - time_object: Union[int, float, dtm.timedelta, dtm.datetime, dtm.time], + time_object: Union[float, dtm.timedelta, dtm.datetime, dtm.time], reference_timestamp: Optional[float] = None, tzinfo: Optional[dtm.tzinfo] = None, ) -> float: @@ -65,12 +65,11 @@ def to_float_timestamp( to be in UTC, if ``bot`` is not passed or ``bot.defaults`` is :obj:`None`. Args: - time_object (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta` | \ + time_object (:obj:`float` | :obj:`datetime.timedelta` | \ :obj:`datetime.datetime` | :obj:`datetime.time`): Time value to convert. The semantics of this parameter will depend on its type: - * :obj:`int` or :obj:`float` will be interpreted as "seconds from - :paramref:`reference_t`" + * :obj:`float` will be interpreted as "seconds from :paramref:`reference_t`" * :obj:`datetime.timedelta` will be interpreted as "time increment from :paramref:`reference_timestamp`" * :obj:`datetime.datetime` will be interpreted as an absolute date/time value @@ -148,7 +147,7 @@ def to_float_timestamp( def to_timestamp( - dt_obj: Union[int, float, dtm.timedelta, dtm.datetime, dtm.time, None], + dt_obj: Union[float, dtm.timedelta, dtm.datetime, dtm.time, None], reference_timestamp: Optional[float] = None, tzinfo: Optional[dtm.tzinfo] = None, ) -> Optional[int]: diff --git a/telegram/ext/_application.py b/telegram/ext/_application.py index 69b723a6d..1625437fc 100644 --- a/telegram/ext/_application.py +++ b/telegram/ext/_application.py @@ -486,7 +486,7 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AsyncContextManager["Applica self._initialized = False - async def __aenter__(self: _AppType) -> _AppType: + async def __aenter__(self: _AppType) -> _AppType: # noqa: PYI019 """Simple context manager which initializes the App.""" try: await self.initialize() diff --git a/telegram/ext/_jobqueue.py b/telegram/ext/_jobqueue.py index 99c5b5864..3125692df 100644 --- a/telegram/ext/_jobqueue.py +++ b/telegram/ext/_jobqueue.py @@ -107,14 +107,14 @@ class JobQueue(Generic[CCT]): @overload def _parse_time_input( self, - time: Union[float, int, datetime.timedelta, datetime.datetime, datetime.time], + time: Union[float, datetime.timedelta, datetime.datetime, datetime.time], shift_day: bool = False, ) -> datetime.datetime: ... def _parse_time_input( self, - time: Union[float, int, datetime.timedelta, datetime.datetime, datetime.time, None], + time: Union[float, datetime.timedelta, datetime.datetime, datetime.time, None], shift_day: bool = False, ) -> Optional[datetime.datetime]: if time is None: diff --git a/telegram/ext/_updater.py b/telegram/ext/_updater.py index f89498e06..1e51112cb 100644 --- a/telegram/ext/_updater.py +++ b/telegram/ext/_updater.py @@ -163,7 +163,7 @@ class Updater(AsyncContextManager["Updater"]): self._initialized = False _LOGGER.debug("Shut down of Updater complete") - async def __aenter__(self: _UpdaterType) -> _UpdaterType: + async def __aenter__(self: _UpdaterType) -> _UpdaterType: # noqa: PYI019 """Simple context manager which initializes the Updater.""" try: await self.initialize() diff --git a/telegram/warnings.py b/telegram/warnings.py index 8fef6a6c3..5be2aabc6 100644 --- a/telegram/warnings.py +++ b/telegram/warnings.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# +#! /usr/bin/env python # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2023 # Leandro Toledo de Souza