From 040cd2c2fc1996e610c9fdcad143442c1e1b5fb9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:26:08 +0200 Subject: [PATCH] `pre-commit` autoupdate (#4184) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bibo-Joshi <22366557+Bibo-Joshi@users.noreply.github.com> --- .pre-commit-config.yaml | 10 +++++----- telegram/ext/_handlers/chatjoinrequesthandler.py | 4 +--- telegram/ext/_handlers/commandhandler.py | 6 ++---- telegram/ext/filters.py | 6 ++---- tests/conftest.py | 4 +--- tests/test_constants.py | 7 ++----- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5acb00b0..55166a453 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.2.1' + rev: 'v0.3.5' hooks: - id: ruff name: ruff @@ -17,7 +17,7 @@ repos: - cachetools~=5.3.3 - aiolimiter~=1.1.0 - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.1.1 + rev: 24.3.0 hooks: - id: black args: @@ -28,7 +28,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/PyCQA/pylint - rev: v3.0.3 + rev: v3.1.0 hooks: - id: pylint files: ^(?!(tests|docs)).*\.py$ @@ -40,7 +40,7 @@ repos: - aiolimiter~=1.1.0 - . # this basically does `pip install -e .` - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.9.0 hooks: - id: mypy name: mypy-ptb @@ -67,7 +67,7 @@ repos: - cachetools~=5.3.3 - . # this basically does `pip install -e .` - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.15.2 hooks: - id: pyupgrade args: diff --git a/telegram/ext/_handlers/chatjoinrequesthandler.py b/telegram/ext/_handlers/chatjoinrequesthandler.py index 9e4f3a011..7007f61ab 100644 --- a/telegram/ext/_handlers/chatjoinrequesthandler.py +++ b/telegram/ext/_handlers/chatjoinrequesthandler.py @@ -107,7 +107,5 @@ class ChatJoinRequestHandler(BaseHandler[Update, CCT]): return True if update.chat_join_request.chat.id in self._chat_ids: return True - if update.chat_join_request.from_user.username in self._usernames: - return True - return False + return update.chat_join_request.from_user.username in self._usernames return False diff --git a/telegram/ext/_handlers/commandhandler.py b/telegram/ext/_handlers/commandhandler.py index b509918d7..94ee77493 100644 --- a/telegram/ext/_handlers/commandhandler.py +++ b/telegram/ext/_handlers/commandhandler.py @@ -153,14 +153,12 @@ class CommandHandler(BaseHandler[Update, CCT]): :obj:`bool`: Whether the args are valid for this handler. """ # pylint: disable=too-many-boolean-expressions - if ( + return bool( (self.has_args is None) or (self.has_args is True and args) or (self.has_args is False and not args) or (isinstance(self.has_args, int) and len(args) == self.has_args) - ): - return True - return False + ) def check_update( self, update: object diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index aad3ad95d..34bede100 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -281,14 +281,12 @@ class BaseFilter: :attr:`~telegram.Update.edited_channel_post` or :attr:`~telegram.Update.edited_message`, :obj:`False` otherwise. """ - if ( # Only message updates should be handled. + return bool( # Only message updates should be handled. update.channel_post or update.message or update.edited_channel_post or update.edited_message - ): - return True - return False + ) class MessageFilter(BaseFilter): diff --git a/tests/conftest.py b/tests/conftest.py index c7e816672..213bcff4a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -73,9 +73,7 @@ def no_rerun_after_xfail_or_flood(error, name, test: pytest.Function, plugin): if getattr(error[1], "msg", "") is None: raise error[1] did_we_flood = "flood" in getattr(error[1], "msg", "") # _pytest.outcomes.XFailed has 'msg' - if xfail_present or did_we_flood: - return False - return True + return not (xfail_present or did_we_flood) def pytest_collection_modifyitems(items: List[pytest.Item]): diff --git a/tests/test_constants.py b/tests/test_constants.py index 5055f7579..d99dbc8bd 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -149,7 +149,7 @@ class TestConstantsWithoutRequest: if any(re.match(pattern, name) for pattern in patters): return False - if name in { + return name not in { "author_signature", "api_kwargs", "caption", @@ -176,10 +176,7 @@ class TestConstantsWithoutRequest: # attribute is deprecated, no need to add it to MessageType "user_shared", "via_bot", - }: - return False - - return True + } @pytest.mark.parametrize( "attribute",