Skip to content

Commit 083365c

Browse files
refactor: ignore unsafe lint and apply new lints
1 parent 0e9ffd0 commit 083365c

File tree

10 files changed

+30
-23
lines changed

10 files changed

+30
-23
lines changed

compiler/api/compiler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def get_type_hint(type: str) -> str:
135135
ns, name = type.split(".") if "." in type else ("", type)
136136
type = '"raw.base.' + ".".join([ns, name]).strip(".") + '"'
137137

138-
return f'{type}{" = None" if is_flag else ""}'
138+
return f"{type}{' = None' if is_flag else ''}"
139139

140140

141141
def sort_args(args: list[tuple[str, str]]):
@@ -376,7 +376,7 @@ def start(format: bool = False):
376376
arg_docs = arg_docs["params"].get(arg_name, "N/A") if arg_docs else "N/A"
377377

378378
docstring_args.append(
379-
f'{arg_name} ({get_docstring_arg_type(arg_type)}{", *optional*" if is_optional else ""}):\n {arg_docs}\n'
379+
f"{arg_name} ({get_docstring_arg_type(arg_type)}{', *optional*' if is_optional else ''}):\n {arg_docs}\n"
380380
)
381381

382382
if c.section == "types":
@@ -458,10 +458,10 @@ def start(format: bool = False):
458458

459459
write_types += "\n "
460460
write_types += f"if self.{arg_name} is not None:\n "
461-
write_types += f'b.write(Vector(self.{arg_name}{f", {sub_type.title()}" if sub_type in CORE_TYPES else ""}))\n '
461+
write_types += f"b.write(Vector(self.{arg_name}{f', {sub_type.title()}' if sub_type in CORE_TYPES else ''}))\n "
462462

463463
read_types += "\n "
464-
read_types += f'{arg_name} = TLObject.read(b{f", {sub_type.title()}" if sub_type in CORE_TYPES else ""}) if flags{number} & (1 << {index}) else []\n '
464+
read_types += f"{arg_name} = TLObject.read(b{f', {sub_type.title()}' if sub_type in CORE_TYPES else ''}) if flags{number} & (1 << {index}) else []\n "
465465
else:
466466
write_types += "\n "
467467
write_types += f"if self.{arg_name} is not None:\n "
@@ -479,10 +479,10 @@ def start(format: bool = False):
479479
elif "vector" in arg_type.lower():
480480
sub_type = arg_type.split("<")[1][:-1]
481481

482-
write_types += f'b.write(Vector(self.{arg_name}{f", {sub_type.title()}" if sub_type in CORE_TYPES else ""}))\n '
482+
write_types += f"b.write(Vector(self.{arg_name}{f', {sub_type.title()}' if sub_type in CORE_TYPES else ''}))\n "
483483

484484
read_types += "\n "
485-
read_types += f'{arg_name} = TLObject.read(b{f", {sub_type.title()}" if sub_type in CORE_TYPES else ""})\n '
485+
read_types += f"{arg_name} = TLObject.read(b{f', {sub_type.title()}' if sub_type in CORE_TYPES else ''})\n "
486486
else:
487487
write_types += f"b.write(self.{arg_name}.write())\n "
488488

compiler/docs/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def build(path: Path, level=0):
9797
v = sorted(v)
9898
entities = []
9999

100-
entities = [f'{i} <{snake(i).replace("_", "-")}>' for i in v]
100+
entities = [f"{i} <{snake(i).replace('_', '-')}>" for i in v]
101101

102102
if k != base_name:
103103
inner_path = Path(base_name, k, "index.rst")

hydrogram/methods/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
from .invite_links import InviteLinks
2727
from .messages import Messages
2828
from .password import Password
29+
from .phone import Phone
2930
from .pyromod import Pyromod
3031
from .users import Users
3132
from .utilities import Utilities
32-
from .phone import Phone
3333

3434

3535
class Methods(

hydrogram/methods/auth/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .connect import Connect
2323
from .disconnect import Disconnect
2424
from .get_password_hint import GetPasswordHint
25+
from .get_sessions import GetSessions
2526
from .initialize import Initialize
2627
from .log_out import LogOut
2728
from .recover_password import RecoverPassword
@@ -32,7 +33,6 @@
3233
from .sign_in_bot import SignInBot
3334
from .sign_up import SignUp
3435
from .terminate import Terminate
35-
from .get_sessions import GetSessions
3636

3737

3838
class Auth(

hydrogram/methods/messages/download_media.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async def progress(current, total):
181181
else:
182182
extension = ".unknown"
183183

184-
file_name = f'{FileType(file_id_obj.file_type).name.lower()}_{(date or datetime.now()).strftime("%Y-%m-%d_%H-%M-%S")}_{self.rnd_id()}{extension}'
184+
file_name = f"{FileType(file_id_obj.file_type).name.lower()}_{(date or datetime.now()).strftime('%Y-%m-%d_%H-%M-%S')}_{self.rnd_id()}{extension}"
185185

186186
downloader = self.handle_download((
187187
file_id_obj,

hydrogram/methods/phone/create_video_chat.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@
1818

1919
from __future__ import annotations
2020

21-
from datetime import datetime
21+
from typing import TYPE_CHECKING
2222

2323
import hydrogram
24-
from hydrogram import types, raw, utils
24+
from hydrogram import raw, types, utils
25+
26+
if TYPE_CHECKING:
27+
from datetime import datetime
2528

2629

2730
class CreateVideoChat:
2831
async def create_video_chat(
29-
self: "hydrogram.Client",
32+
self: hydrogram.Client,
3033
chat_id: int | str,
31-
title: str = None,
34+
title: str | None = None,
3235
start_date: datetime = utils.zero_datetime(),
33-
is_rtmp_stream: bool = None,
34-
) -> "types.Message":
36+
is_rtmp_stream: bool | None = None,
37+
) -> types.Message:
3538
"""Creates a video chat (a group call bound to a chat).
3639
3740
Available only for basic groups, supergroups and channels; requires can_manage_video_chats administrator right.
@@ -91,3 +94,4 @@ async def create_video_chat(
9194
{i.id: i for i in r.chats},
9295
is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage),
9396
)
97+
return None

hydrogram/methods/phone/discard_group_call.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
from __future__ import annotations
2020

2121
import hydrogram
22-
from hydrogram import types, raw
22+
from hydrogram import raw, types
2323

2424

2525
class DiscardGroupCall:
2626
async def discard_group_call(
27-
self: "hydrogram.Client",
27+
self: hydrogram.Client,
2828
chat_id: int | str,
29-
) -> "types.Message":
29+
) -> types.Message:
3030
"""Terminate a group/channel call or livestream
3131
3232
.. include:: /_includes/usable-by/users.rst
@@ -76,3 +76,4 @@ async def discard_group_call(
7676
{i.id: i for i in r.chats},
7777
is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage),
7878
)
79+
return None

hydrogram/methods/phone/invite_group_call_members.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
from __future__ import annotations
2020

2121
import hydrogram
22-
from hydrogram import types, raw
22+
from hydrogram import raw, types
2323

2424

2525
class InviteGroupCallMembers:
2626
async def invite_group_call_members(
27-
self: "hydrogram.Client",
27+
self: hydrogram.Client,
2828
chat_id: int | str,
2929
user_ids: int | str | list[int | str],
30-
) -> "types.Message":
30+
) -> types.Message:
3131
"""Invites users to an active group call. Sends a service message of type :obj:`~pyrogram.enums.MessageServiceType.VIDEO_CHAT_PARTICIPANTS_INVITED` for video chats.
3232
3333
.. include:: /_includes/usable-by/users.rst
@@ -88,3 +88,4 @@ async def invite_group_call_members(
8888
{i.id: i for i in r.chats},
8989
is_scheduled=isinstance(i, raw.types.UpdateNewScheduledMessage),
9090
)
91+
return None

hydrogram/raw/core/tl_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __str__(self) -> str:
5959

6060
def __repr__(self) -> str:
6161
return (
62-
f'hydrogram.raw.{self.QUALNAME}({", ".join(f"{attr}={getattr(self, attr)!r}" for attr in self.__slots__ if getattr(self, attr) is not None)})'
62+
f"hydrogram.raw.{self.QUALNAME}({', '.join(f'{attr}={getattr(self, attr)!r}' for attr in self.__slots__ if getattr(self, attr) is not None)})"
6363
if hasattr(self, "QUALNAME")
6464
else repr(self)
6565
)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ ignore = [
134134
"PLW1514",
135135
"PLW2901",
136136
"PLW0603",
137+
"FURB189", # This rule is unsafe and not relevant for us.
137138
]
138139
preview = true
139140

0 commit comments

Comments
 (0)