Skip to content

Commit c34e19e

Browse files
Bump pre-commit Hooks to Latest Versions (#4748)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
1 parent 2fc04e1 commit c34e19e

25 files changed

+42
-38
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ci:
77

88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: 'v0.8.6'
10+
rev: 'v0.11.9'
1111
hooks:
1212
- id: ruff
1313
name: ruff
@@ -18,18 +18,18 @@ repos:
1818
- cachetools>=5.3.3,<5.5.0
1919
- aiolimiter~=1.1,<1.3
2020
- repo: https://github.com/psf/black-pre-commit-mirror
21-
rev: 24.10.0
21+
rev: 25.1.0
2222
hooks:
2323
- id: black
2424
args:
2525
- --diff
2626
- --check
2727
- repo: https://github.com/PyCQA/flake8
28-
rev: 7.1.1
28+
rev: 7.2.0
2929
hooks:
3030
- id: flake8
3131
- repo: https://github.com/PyCQA/pylint
32-
rev: v3.3.3
32+
rev: v3.3.6
3333
hooks:
3434
- id: pylint
3535
files: ^(?!(tests|docs)).*\.py$
@@ -41,7 +41,7 @@ repos:
4141
- aiolimiter~=1.1,<1.3
4242
- . # this basically does `pip install -e .`
4343
- repo: https://github.com/pre-commit/mirrors-mypy
44-
rev: v1.14.1
44+
rev: v1.15.0
4545
hooks:
4646
- id: mypy
4747
name: mypy-ptb
@@ -74,7 +74,7 @@ repos:
7474
args:
7575
- --py39-plus
7676
- repo: https://github.com/pycqa/isort
77-
rev: 5.13.2
77+
rev: 6.0.1
7878
hooks:
7979
- id: isort
8080
name: isort
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
internal = "Bump `pre-commit` Hooks to Latest Versions"
2+
[[pull_requests]]
3+
uid = "4748"
4+
author_uid = "pre-commit-ci"
5+
closes_threads = []

docs/auxil/sphinx_hooks.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
#
1616
# You should have received a copy of the GNU Lesser Public License
1717
# along with this program. If not, see [http://www.gnu.org/licenses/].
18-
import collections.abc
1918
import contextlib
2019
import inspect
2120
import re
2221
import typing
2322
from pathlib import Path
23+
from typing import TYPE_CHECKING
2424

2525
from sphinx.application import Sphinx
2626

@@ -37,6 +37,10 @@
3737
)
3838
from docs.auxil.link_code import LINE_NUMBERS
3939

40+
if TYPE_CHECKING:
41+
import collections.abc
42+
43+
4044
ADMONITION_INSERTER = AdmonitionInserter()
4145

4246
# Some base classes are implementation detail
@@ -128,15 +132,15 @@ def autodoc_process_docstring(
128132
insert_idx += len(effective_insert)
129133

130134
ADMONITION_INSERTER.insert_admonitions(
131-
obj=typing.cast(collections.abc.Callable, obj),
135+
obj=typing.cast("collections.abc.Callable", obj),
132136
docstring_lines=lines,
133137
)
134138

135139
# 2-4) Insert "Returned in", "Available in", "Use in" admonitions into classes
136140
# (where applicable)
137141
if what == "class":
138142
ADMONITION_INSERTER.insert_admonitions(
139-
obj=typing.cast(type, obj), # since "what" == class, we know it's not just object
143+
obj=typing.cast("type", obj), # since "what" == class, we know it's not just object
140144
docstring_lines=lines,
141145
)
142146

examples/arbitrarycallbackdatabot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async def list_button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> Non
6969
# Get the data from the callback_data.
7070
# If you're using a type checker like MyPy, you'll have to use typing.cast
7171
# to make the checker get the expected type of the callback_data
72-
number, number_list = cast(tuple[int, list[int]], query.data)
72+
number, number_list = cast("tuple[int, list[int]]", query.data)
7373
# append the number to the list
7474
number_list.append(number)
7575

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ line-length = 99
125125
show-fixes = true
126126

127127
[tool.ruff.lint]
128-
preview = true
129-
explicit-preview-rules = true # TODO: Drop this when RUF022 and RUF023 are out of preview
128+
typing-extensions = false
130129
ignore = ["PLR2004", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PERF203"]
131130
select = ["E", "F", "I", "PL", "UP", "RUF", "PTH", "C4", "B", "PIE", "SIM", "RET", "RSE",
132131
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022",

telegram/_bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,7 +3928,7 @@ async def get_file(
39283928
api_kwargs=api_kwargs,
39293929
)
39303930

3931-
file_path = cast(dict, result).get("file_path")
3931+
file_path = cast("dict", result).get("file_path")
39323932
if file_path and not is_local_file(file_path):
39333933
result["file_path"] = f"{self._base_file_url}/{file_path}"
39343934

@@ -4591,7 +4591,7 @@ async def get_updates(
45914591
# waiting for the server to return and there's no way of knowing the connection had been
45924592
# dropped in real time.
45934593
result = cast(
4594-
list[JSONDict],
4594+
"list[JSONDict]",
45954595
await self._post(
45964596
"getUpdates",
45974597
data,

telegram/_telegramobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def __setstate__(self, state: dict[str, object]) -> None:
290290
self._bot = None
291291

292292
# get api_kwargs first because we may need to add entries to it (see try-except below)
293-
api_kwargs = cast(dict[str, object], state.pop("api_kwargs", {}))
293+
api_kwargs = cast("dict[str, object]", state.pop("api_kwargs", {}))
294294
# get _frozen before the loop to avoid setting it to True in the loop
295295
frozen = state.pop("_frozen", False)
296296

telegram/_utils/files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def load_file(
5959
try:
6060
contents = obj.read() # type: ignore[union-attr]
6161
except AttributeError:
62-
return None, cast(Union[bytes, "InputFile", str, Path], obj)
62+
return None, cast("Union[bytes, InputFile, str, Path]", obj)
6363

6464
filename = guess_file_name(obj)
6565

@@ -151,7 +151,7 @@ def parse_file_input( # pylint: disable=too-many-return-statements
151151
if isinstance(file_input, bytes):
152152
return InputFile(file_input, filename=filename, attach=attach)
153153
if hasattr(file_input, "read"):
154-
return InputFile(cast(IO, file_input), filename=filename, attach=attach)
154+
return InputFile(cast("IO", file_input), filename=filename, attach=attach)
155155
if tg_type and isinstance(file_input, tg_type):
156156
return file_input.file_id # type: ignore[attr-defined]
157157
return file_input

telegram/ext/_application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def __init__(
355355
self.__create_task_tasks: set[asyncio.Task] = set() # Used for awaiting tasks upon exit
356356
self.__stop_running_marker = asyncio.Event()
357357

358-
async def __aenter__(self: _AppType) -> _AppType: # noqa: PYI019
358+
async def __aenter__(self: _AppType) -> _AppType:
359359
"""|async_context_manager| :meth:`initializes <initialize>` the App.
360360
361361
Returns:

telegram/ext/_baseupdateprocessor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, max_concurrent_updates: int):
7474
raise ValueError("`max_concurrent_updates` must be a positive integer!")
7575
self._semaphore = TrackedBoundedSemaphore(self.max_concurrent_updates)
7676

77-
async def __aenter__(self: _BUPT) -> _BUPT: # noqa: PYI019
77+
async def __aenter__(self: _BUPT) -> _BUPT:
7878
"""|async_context_manager| :meth:`initializes <initialize>` the Processor.
7979
8080
Returns:

0 commit comments

Comments
 (0)