Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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$
Expand All @@ -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
Expand All @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions telegram/ext/_handlers/chatjoinrequesthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,5 @@ def check_update(self, update: object) -> bool:
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
6 changes: 2 additions & 4 deletions telegram/ext/_handlers/commandhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ def _check_correct_args(self, args: List[str]) -> Optional[bool]:
: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
Expand Down
6 changes: 2 additions & 4 deletions telegram/ext/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,12 @@ def check_update(self, update: Update) -> Optional[Union[bool, FilterDataDict]]:
: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):
Expand Down
4 changes: 1 addition & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
7 changes: 2 additions & 5 deletions tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def is_type_attribute(name: str) -> bool:

if any(re.match(pattern, name) for pattern in patters):
return False
if name in {
return name not in {
"author_signature",
"api_kwargs",
"caption",
Expand All @@ -176,10 +176,7 @@ def is_type_attribute(name: str) -> bool:
# attribute is deprecated, no need to add it to MessageType
"user_shared",
"via_bot",
}:
return False

return True
}

@pytest.mark.parametrize(
"attribute",
Expand Down