pre-commit autoupdate (#3537)

Co-authored-by: Dmitry Kolomatskiy <58207913+lemontree210@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot] 2023-02-08 17:41:10 +01:00 committed by GitHub
parent 23a685335b
commit 007f432ee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 21 additions and 49 deletions

View file

@ -9,7 +9,7 @@ ci:
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
args:
@ -20,7 +20,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pylint
rev: v2.15.9
rev: v2.16.1
hooks:
- id: pylint
files: ^(telegram|examples)/.*\.py$
@ -80,7 +80,7 @@ repos:
- --diff
- --check
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.222'
rev: 'v0.0.243'
hooks:
- id: ruff
name: ruff

View file

@ -106,7 +106,6 @@ class AdmonitionInserter:
# docs.auxil.sphinx_hooks.autodoc_process_docstring()
for admonition_type in self.ALL_ADMONITION_TYPES:
# If there is no admonition of the given type for the given class or method,
# continue to the next admonition type, maybe the class/method is listed there.
if obj not in self.admonitions[admonition_type]:
@ -258,7 +257,6 @@ class AdmonitionInserter:
for cls, method_names in self.METHOD_NAMES_FOR_BOT_AND_APPBUILDER.items():
for method_name in method_names:
sig = inspect.signature(getattr(cls, method_name))
ret_annot = sig.return_annotation
@ -301,16 +299,13 @@ class AdmonitionInserter:
# inspect methods of all telegram classes for return statements that indicate
# that this given method is a shortcut for a Bot method
for class_name, cls in inspect.getmembers(telegram, predicate=inspect.isclass):
# no need to inspect Bot's own methods, as Bot can't have shortcuts in Bot
if cls is telegram.Bot:
continue
for method_name, method in _iter_own_public_methods(cls):
# .getsourcelines() returns a tuple. Item [1] is an int
for line in inspect.getsourcelines(method)[0]:
if not (bot_method_match := bot_method_pattern.search(line)):
continue
@ -412,7 +407,6 @@ class AdmonitionInserter:
admonition_for_class = {}
for cls, attrs in attrs_or_methods_for_class.items():
if cls is telegram.ext.ApplicationBuilder:
# ApplicationBuilder is only used in and returned from its own methods,
# so its page needs no admonitions.
@ -472,7 +466,6 @@ class AdmonitionInserter:
**Modifies dictionary in place.**
"""
for cls in self._resolve_arg(arg):
# When trying to resolve an argument from args or return annotation,
# the method _resolve_arg returns None if nothing could be resolved.
# Also, if class was resolved correctly, "telegram" will definitely be in its str().
@ -549,7 +542,6 @@ class AdmonitionInserter:
# For some reason "InlineQueryResult", "InputMedia" & some others are currently not
# recognized as ForwardRefs and are identified as plain strings.
elif isinstance(arg, str):
# args like "ApplicationBuilder[BT, CCT, UD, CD, BD, JQ]" can be recognized as strings.
# Remove whatever is in the square brackets because it doesn't need to be parsed.
arg = re.sub(r"\[.+]", "", arg)

View file

@ -391,7 +391,6 @@ class InputMediaVideo(InputMedia):
*,
api_kwargs: JSONDict = None,
):
if isinstance(media, Video):
width = width if width is not None else media.width
height = height if height is not None else media.height

View file

@ -99,7 +99,6 @@ class InlineQueryResultArticle(InlineQueryResult):
*,
api_kwargs: JSONDict = None,
):
# Required
super().__init__(InlineQueryResultType.ARTICLE, id, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -113,7 +113,6 @@ class InlineQueryResultAudio(InlineQueryResult):
*,
api_kwargs: JSONDict = None,
):
# Required
super().__init__(InlineQueryResultType.AUDIO, id, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -130,7 +130,6 @@ class InlineQueryResultGif(InlineQueryResult):
*,
api_kwargs: JSONDict = None,
):
# Required
super().__init__(InlineQueryResultType.GIF, id, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -133,7 +133,6 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
*,
api_kwargs: JSONDict = None,
):
# Required
super().__init__(InlineQueryResultType.MPEG4GIF, id, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -125,7 +125,6 @@ class InlineQueryResultVenue(InlineQueryResult):
*,
api_kwargs: JSONDict = None,
):
# Required
super().__init__(InlineQueryResultType.VENUE, id, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -141,7 +141,6 @@ class InlineQueryResultVideo(InlineQueryResult):
*,
api_kwargs: JSONDict = None,
):
# Required
super().__init__(InlineQueryResultType.VIDEO, id, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -111,7 +111,6 @@ class InlineQueryResultVoice(InlineQueryResult):
*,
api_kwargs: JSONDict = None,
):
# Required
super().__init__(InlineQueryResultType.VOICE, id, api_kwargs=api_kwargs)
with self._unfrozen():

View file

@ -3241,10 +3241,10 @@ class Message(TelegramObject):
html_text = ""
last_offset = 0
sorted_entities = sorted(entities.items(), key=(lambda item: item[0].offset))
sorted_entities = sorted(entities.items(), key=lambda item: item[0].offset)
parsed_entities = []
for (entity, text) in sorted_entities:
for entity, text in sorted_entities:
if entity not in parsed_entities:
nested_entities = {
e: t
@ -3426,10 +3426,10 @@ class Message(TelegramObject):
markdown_text = ""
last_offset = 0
sorted_entities = sorted(entities.items(), key=(lambda item: item[0].offset))
sorted_entities = sorted(entities.items(), key=lambda item: item[0].offset)
parsed_entities = []
for (entity, text) in sorted_entities:
for entity, text in sorted_entities:
if entity not in parsed_entities:
nested_entities = {
e: t

View file

@ -289,7 +289,6 @@ class TelegramObject:
frozen = state.pop("_frozen", False)
for key, val in state.items():
try:
setattr(self, key, val)
except AttributeError:
@ -402,7 +401,6 @@ class TelegramObject:
data = {}
for key in self._get_attrs_names(include_private=include_private):
value = getattr(self, key, None)
if value is not None:
if recursive and hasattr(value, "to_dict"):

View file

@ -221,12 +221,12 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
DefaultValue.get_value(getattr(self, f"{prefix}connection_pool_size")) or 256
)
timeouts = dict(
connect_timeout=getattr(self, f"{prefix}connect_timeout"),
read_timeout=getattr(self, f"{prefix}read_timeout"),
write_timeout=getattr(self, f"{prefix}write_timeout"),
pool_timeout=getattr(self, f"{prefix}pool_timeout"),
)
timeouts = {
"connect_timeout": getattr(self, f"{prefix}connect_timeout"),
"read_timeout": getattr(self, f"{prefix}read_timeout"),
"write_timeout": getattr(self, f"{prefix}write_timeout"),
"pool_timeout": getattr(self, f"{prefix}pool_timeout"),
}
# Get timeouts that were actually set-
effective_timeouts = {
key: value for key, value in timeouts.items() if not isinstance(value, DefaultValue)

View file

@ -292,6 +292,7 @@ class ConversationHandler(BaseHandler[Update, CCT]):
WAITING: ClassVar[int] = -3
""":obj:`int`: Used as a constant to handle state when a conversation is still waiting on the
previous :attr:`block=False <block>` handler to finish."""
# pylint: disable=super-init-not-called
def __init__(
self,

View file

@ -80,7 +80,6 @@ class MessageHandler(BaseHandler[Update, CCT]):
callback: HandlerCallback[Update, CCT, RT],
block: DVType[bool] = DEFAULT_TRUE,
):
super().__init__(callback, block=block)
self.filters: filters_module.BaseFilter = (
filters if filters is not None else filters_module.ALL

View file

@ -130,7 +130,6 @@ class PrefixHandler(BaseHandler[Update, CCT]):
filters: filters_module.BaseFilter = None,
block: DVType[bool] = DEFAULT_TRUE,
):
super().__init__(callback=callback, block=block)
if isinstance(prefix, str):

View file

@ -301,7 +301,6 @@ class Updater(AsyncContextManager["Updater"]):
ready: asyncio.Event,
error_callback: Optional[Callable[[TelegramError], None]],
) -> None:
self._logger.debug("Updater started (polling)")
# the bootstrapping phase does two things:

View file

@ -117,13 +117,13 @@ class HTTPXRequest(BaseRequest):
http1 = http_version == "1.1"
self._client_kwargs = dict(
timeout=timeout,
proxies=proxy_url,
limits=limits,
http1=http1,
http2=not http1,
)
self._client_kwargs = {
"timeout": timeout,
"proxies": proxy_url,
"limits": limits,
"http1": http1,
"http2": not http1,
}
try:
self._client = self._build_client()

View file

@ -45,7 +45,6 @@ def invite_link(creator):
class TestChatInviteLink:
link = "thisialink"
creates_join_request = False
primary = True

View file

@ -201,7 +201,6 @@ class TestChatPermissions:
assert f != t
def test_equality_warning(self, recwarn, chat_permissions):
recwarn.clear()
assert chat_permissions == chat_permissions

View file

@ -2053,7 +2053,6 @@ class TestConversationHandler:
await app.stop()
async def test_no_timeout_on_end(self, app, user1):
conv_handler = ConversationHandler(
entry_points=[MessageHandler(filters.ALL, callback=self.start_end)],
states={ConversationHandler.TIMEOUT: [TypeHandler(Update, self.passout2)]},
@ -2116,7 +2115,6 @@ class TestConversationHandler:
async def test_blocking_resolution_order(
self, bot, default_block, ch_block, handler_block, ext_bot
):
event = asyncio.Event()
async def callback(_, __):

View file

@ -131,7 +131,6 @@ class TestKeyboardButton:
assert hash(a) == hash(f)
def test_equality_warning(self, recwarn, keyboard_button):
recwarn.clear()
assert keyboard_button == keyboard_button

View file

@ -199,7 +199,6 @@ class TestAIORateLimiter:
@pytest.mark.parametrize("max_retries", [0, 1, 4])
async def test_max_retries(self, bot, max_retries):
bot = ExtBot(
token=bot.token,
request=self.CountRequest(retry_after=1),

View file

@ -480,7 +480,6 @@ class TestHTTPXRequest:
write_timeout=default_timeouts.write,
pool_timeout=default_timeouts.pool,
) as httpx_request:
monkeypatch.setattr(httpx.AsyncClient, "request", make_assertion)
await httpx_request.do_request(method="GET", url="URL")
@ -500,7 +499,6 @@ class TestHTTPXRequest:
write_timeout=default_timeouts.write,
pool_timeout=default_timeouts.pool,
) as httpx_request:
monkeypatch.setattr(httpx.AsyncClient, "request", make_assertion)
await httpx_request.do_request(
method="GET",