Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bumppre-commit Hooks to Latest Versions#4748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 8 commits intomasterfrompre-commit-ci-update-config
May 12, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
12 changes: 6 additions & 6 deletions.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.8.6'
rev: 'v0.11.9'
hooks:
- id: ruff
name: ruff
Expand All@@ -18,18 +18,18 @@ repos:
- cachetools>=5.3.3,<5.5.0
- aiolimiter~=1.1,<1.3
- repo: https://github.com/psf/black-pre-commit-mirror
rev:24.10.0
rev:25.1.0
hooks:
- id: black
args:
- --diff
- --check
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
rev: 7.2.0
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pylint
rev: v3.3.3
rev: v3.3.6
hooks:
- id: pylint
files: ^(?!(tests|docs)).*\.py$
Expand All@@ -41,7 +41,7 @@ repos:
- aiolimiter~=1.1,<1.3
- . # this basically does `pip install -e .`
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
rev: v1.15.0
hooks:
- id: mypy
name: mypy-ptb
Expand DownExpand Up@@ -74,7 +74,7 @@ repos:
args:
- --py39-plus
- repo: https://github.com/pycqa/isort
rev:5.13.2
rev:6.0.1
hooks:
- id: isort
name: isort
Expand Down
5 changes: 5 additions & 0 deletionschanges/unreleased/4748.j3cKusZZKqTLbc542K4sqJ.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
internal = "Bump `pre-commit` Hooks to Latest Versions"
[[pull_requests]]
uid = "4748"
author_uid = "pre-commit-ci"
closes_threads = []
10 changes: 7 additions & 3 deletionsdocs/auxil/sphinx_hooks.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,12 +15,12 @@
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import collections.abc
import contextlib
import inspect
import re
import typing
from pathlib import Path
from typing import TYPE_CHECKING

from sphinx.application import Sphinx

Expand All@@ -37,6 +37,10 @@
)
from docs.auxil.link_code import LINE_NUMBERS

if TYPE_CHECKING:
import collections.abc


ADMONITION_INSERTER = AdmonitionInserter()

# Some base classes are implementation detail
Expand DownExpand Up@@ -128,15 +132,15 @@ def autodoc_process_docstring(
insert_idx += len(effective_insert)

ADMONITION_INSERTER.insert_admonitions(
obj=typing.cast(collections.abc.Callable, obj),
obj=typing.cast("collections.abc.Callable", obj),
docstring_lines=lines,
)

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

Expand Down
2 changes: 1 addition & 1 deletionexamples/arbitrarycallbackdatabot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ async def list_button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> Non
# Get the data from the callback_data.
# If you're using a type checker like MyPy, you'll have to use typing.cast
# to make the checker get the expected type of the callback_data
number, number_list = cast(tuple[int, list[int]], query.data)
number, number_list = cast("tuple[int, list[int]]", query.data)
# append the number to the list
number_list.append(number)

Expand Down
3 changes: 1 addition & 2 deletionspyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,8 +125,7 @@ line-length = 99
show-fixes = true

[tool.ruff.lint]
preview = true
explicit-preview-rules = true # TODO: Drop this when RUF022 and RUF023 are out of preview
typing-extensions = false
ignore = ["PLR2004", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PERF203"]
select = ["E", "F", "I", "PL", "UP", "RUF", "PTH", "C4", "B", "PIE", "SIM", "RET", "RSE",
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022",
Expand Down
4 changes: 2 additions & 2 deletionstelegram/_bot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3928,7 +3928,7 @@ async def get_file(
api_kwargs=api_kwargs,
)

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

Expand DownExpand Up@@ -4591,7 +4591,7 @@ async def get_updates(
# waiting for the server to return and there's no way of knowing the connection had been
# dropped in real time.
result = cast(
list[JSONDict],
"list[JSONDict]",
await self._post(
"getUpdates",
data,
Expand Down
2 changes: 1 addition & 1 deletiontelegram/_telegramobject.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -290,7 +290,7 @@ def __setstate__(self, state: dict[str, object]) -> None:
self._bot = None

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

Expand Down
4 changes: 2 additions & 2 deletionstelegram/_utils/files.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ def load_file(
try:
contents = obj.read() # type: ignore[union-attr]
except AttributeError:
return None, cast(Union[bytes,"InputFile", str, Path], obj)
return None, cast("Union[bytes, InputFile, str, Path]", obj)

filename = guess_file_name(obj)

Expand DownExpand Up@@ -151,7 +151,7 @@ def parse_file_input( # pylint: disable=too-many-return-statements
if isinstance(file_input, bytes):
return InputFile(file_input, filename=filename, attach=attach)
if hasattr(file_input, "read"):
return InputFile(cast(IO, file_input), filename=filename, attach=attach)
return InputFile(cast("IO", file_input), filename=filename, attach=attach)
if tg_type and isinstance(file_input, tg_type):
return file_input.file_id # type: ignore[attr-defined]
return file_input
2 changes: 1 addition & 1 deletiontelegram/ext/_application.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -355,7 +355,7 @@ def __init__(
self.__create_task_tasks: set[asyncio.Task] = set() # Used for awaiting tasks upon exit
self.__stop_running_marker = asyncio.Event()

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

Returns:
Expand Down
2 changes: 1 addition & 1 deletiontelegram/ext/_baseupdateprocessor.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,7 +74,7 @@ def __init__(self, max_concurrent_updates: int):
raise ValueError("`max_concurrent_updates` must be a positive integer!")
self._semaphore = TrackedBoundedSemaphore(self.max_concurrent_updates)

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

Returns:
Expand Down
2 changes: 1 addition & 1 deletiontelegram/ext/_callbackdatacache.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -347,7 +347,7 @@ def __process_message(self, message: Message) -> Optional[str]:
for row in message.reply_markup.inline_keyboard:
for button in row:
if button.callback_data:
button_data = cast(str, button.callback_data)
button_data = cast("str", button.callback_data)
keyboard_id, callback_data = self.__get_keyboard_uuid_and_button_data(
button_data
)
Expand Down
2 changes: 1 addition & 1 deletiontelegram/ext/_dictpersistence.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -145,7 +145,7 @@ def __init__(
self._callback_data = None
else:
self._callback_data = cast(
CDCData,
"CDCData",
([(one, float(two), three) for one, two, three in data[0]], data[1]),
)
self._callback_data_json = callback_data_json
Expand Down
2 changes: 1 addition & 1 deletiontelegram/ext/_extbot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -253,7 +253,7 @@ def __init__(
return

if not isinstance(arbitrary_callback_data, bool):
maxsize = cast(int, arbitrary_callback_data)
maxsize = cast("int", arbitrary_callback_data)
else:
maxsize = 1024

Expand Down
2 changes: 1 addition & 1 deletiontelegram/ext/_handlers/callbackqueryhandler.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -204,5 +204,5 @@ def collect_additional_context(
:attr:`CallbackContext.matches` as list with one element.
"""
if self.pattern:
check_result = cast(Match, check_result)
check_result = cast("Match", check_result)
context.matches = [check_result]
2 changes: 1 addition & 1 deletiontelegram/ext/_handlers/choseninlineresulthandler.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -118,5 +118,5 @@ def collect_additional_context(
:attr:`telegram.ext.CallbackContext.matches`.
"""
if self.pattern:
check_result = cast(Match, check_result)
check_result = cast("Match", check_result)
context.matches = [check_result]
4 changes: 2 additions & 2 deletionstelegram/ext/_handlers/conversationhandler.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,7 +599,7 @@ async def _initialize_persistence(

current_conversations = self._conversations
self._conversations = cast(
TrackingDict[ConversationKey, object],
"TrackingDict[ConversationKey, object]",
TrackingDict(),
)
# In the conversation already processed updates
Expand DownExpand Up@@ -924,7 +924,7 @@ async def _trigger_timeout(self, context: CCT) -> None:
:obj:`True` is handled.
"""
job = cast("Job", context.job)
ctxt = cast(_ConversationTimeoutContext, job.data)
ctxt = cast("_ConversationTimeoutContext", job.data)

_LOGGER.debug(
"Conversation timeout was triggered for conversation %s!", ctxt.conversation_key
Expand Down
2 changes: 1 addition & 1 deletiontelegram/ext/_handlers/inlinequeryhandler.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,5 +139,5 @@ def collect_additional_context(
:attr:`CallbackContext.matches` as list with one element.
"""
if self.pattern:
check_result = cast(Match, check_result)
check_result = cast("Match", check_result)
context.matches = [check_result]
2 changes: 1 addition & 1 deletiontelegram/ext/_picklepersistence.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -237,7 +237,7 @@ def __init__(
self.callback_data: Optional[CDCData] = None
self.conversations: Optional[dict[str, dict[tuple[Union[int, str], ...], object]]] = None
self.context_types: ContextTypes[Any, UD, CD, BD] = cast(
ContextTypes[Any, UD, CD, BD], context_types or ContextTypes()
"ContextTypes[Any, UD, CD, BD]", context_types or ContextTypes()
)

def _load_singlefile(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletiontelegram/ext/_updater.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,7 +124,7 @@ def __init__(
self.__polling_task_stop_event: asyncio.Event = asyncio.Event()
self.__polling_cleanup_cb: Optional[Callable[[], Coroutine[Any, Any, None]]] = None

async def __aenter__(self: _UpdaterType) -> _UpdaterType: # noqa: PYI019
async def __aenter__(self: _UpdaterType) -> _UpdaterType:
"""
|async_context_manager| :meth:`initializes <initialize>` the Updater.

Expand Down
4 changes: 2 additions & 2 deletionstelegram/ext/filters.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1588,10 +1588,10 @@ class Language(MessageFilter):

def __init__(self, lang: SCT[str]):
if isinstance(lang, str):
lang = cast(str, lang)
lang = cast("str", lang)
self.lang: Sequence[str] = [lang]
else:
lang = cast(list[str], lang)
lang = cast("list[str]", lang)
self.lang = lang
super().__init__(name=f"filters.Language({self.lang})")

Expand Down
1 change: 0 additions & 1 deletiontests/_files/test_inputmedia.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -710,7 +710,6 @@ async def test_send_media_group_with_thumbs(
self, offline_bot, chat_id, video_file, photo_file, monkeypatch
):
async def make_assertion(method, url, request_data: RequestData, *args, **kwargs):
nonlocal input_video
files = request_data.multipart_data
video_check = files[input_video.media.attach_name] == input_video.media.field_tuple
thumb_check = (
Expand Down
2 changes: 1 addition & 1 deletiontests/auxil/bot_method_checks.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -621,7 +621,7 @@ async def check_defaults_handling(
kwargs_need_default.remove("parse_mode")

defaults_no_custom_defaults = Defaults()
kwargs ={kwarg: "custom_default" for kwarg ininspect.signature(Defaults).parameters}
kwargs =dict.fromkeys(inspect.signature(Defaults).parameters, "custom_default")
kwargs["tzinfo"] = zoneinfo.ZoneInfo("America/New_York")
kwargs["link_preview_options"] = LinkPreviewOptions(
url="custom_default", show_above_text="custom_default"
Expand Down
3 changes: 1 addition & 2 deletionstests/ext/test_application.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,7 @@
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""The integration of persistence into the application is tested in test_basepersistence.
"""
"""The integration of persistence into the application is tested in test_basepersistence."""
import asyncio
import functools
import inspect
Expand Down
1 change: 0 additions & 1 deletiontests/ext/test_applicationbuilder.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -426,7 +426,6 @@ def test_custom_socket_options(self, builder, monkeypatch, bot):
httpx_request_init = HTTPXRequest.__init__

def init_transport(*args, **kwargs):
nonlocal httpx_request_kwargs
# This is called once for request and once for get_updates_request, so we make
# it a list
httpx_request_kwargs.append(kwargs.copy())
Expand Down
3 changes: 1 addition & 2 deletionstests/ext/test_conversationhandler.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1438,7 +1438,7 @@ async def test_conversation_handler_timeout_update_and_context(self, app, bot, u
context = None

async def start_callback(u, c):
nonlocal context, self
nonlocal context
context = c
return await self.start(u, c)

Expand All@@ -1459,7 +1459,6 @@ async def start_callback(u, c):
update = Update(update_id=0, message=message)

async def timeout_callback(u, c):
nonlocal update, context
assert u is update
assert c is context

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp