Skip to content

Commit dde144b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4b5fc75 commit dde144b

File tree

26 files changed

+62
-63
lines changed

26 files changed

+62
-63
lines changed

steam/_const.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def json_dumps(
6161
return __decoder(__func(obj))
6262

6363

64-
JSON_LOADS: Final = cast(Callable[[str | bytes], Any], json_loads)
64+
JSON_LOADS: Final = cast("Callable[[str | bytes], Any]", json_loads)
6565
JSON_DUMPS: Final = json_dumps
6666

6767

@@ -109,8 +109,8 @@ def vdf_binary_loads(
109109
vdf_loads = orvdf.loads # type: ignore
110110
vdf_binary_loads = orvdf.binary_loads # type: ignore
111111

112-
VDF_LOADS: Final = cast(Callable[[str], VDFDict], vdf_loads)
113-
VDF_BINARY_LOADS: Final = cast(Callable[[bytes], BinaryVDFDict], vdf_binary_loads)
112+
VDF_LOADS: Final = cast("Callable[[str], VDFDict]", vdf_loads)
113+
VDF_BINARY_LOADS: Final = cast("Callable[[bytes], BinaryVDFDict]", vdf_binary_loads)
114114

115115
HTML_PARSER: Final = "lxml-xml" if importlib.util.find_spec("lxml") else "html.parser"
116116

@@ -125,17 +125,17 @@ def vdf_binary_loads(
125125

126126

127127
def READ_U32(
128-
s: Buffer, unpacker: Callable[[Buffer], tuple[int]] = cast(Any, struct.Struct("<I").unpack_from), /
128+
s: Buffer, unpacker: Callable[[Buffer], tuple[int]] = cast("Any", struct.Struct("<I").unpack_from), /
129129
) -> int:
130130
(u32,) = unpacker(s)
131131
return u32
132132

133133

134-
WRITE_U32: Final = cast(Callable[[int], bytes], struct.Struct("<I").pack)
134+
WRITE_U32: Final = cast("Callable[[int], bytes]", struct.Struct("<I").pack)
135135

136136
_PROTOBUF_MASK: Final = 0x80000000
137137
# inlined as these are some of the most called functions in the library
138-
IS_PROTO: Final = cast(Callable[[int], bool], _PROTOBUF_MASK.__and__) # this is boolean like for a bit of extra speed
138+
IS_PROTO: Final = cast("Callable[[int], bool]", _PROTOBUF_MASK.__and__) # this is boolean like for a bit of extra speed
139139
SET_PROTO_BIT: Final = _PROTOBUF_MASK.__or__
140140
CLEAR_PROTO_BIT: Final = (~_PROTOBUF_MASK).__and__
141141

steam/_gc/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init_subclass__(cls) -> None:
5050
bases = [base for base in cls.__mro__ if issubclass(base, Client) and base is not Client]
5151
previous_state = None
5252
cls._GC_BASES = cast( # type: ignore
53-
tuple[type[GCState[Any]], ...],
53+
"tuple[type[GCState[Any]], ...]",
5454
tuple(
5555
dict.fromkeys(
5656
previous_state := get_annotations(base, eval_str=True).get("_state", previous_state)

steam/_gc/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init_subclass__(cls) -> None:
9898
@property
9999
def backpack(self) -> Inv | None:
100100
try:
101-
return cast(Inv, self.backpacks[APP.get().id])
101+
return cast("Inv", self.backpacks[APP.get().id])
102102
except KeyError:
103103
return None
104104

steam/abc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,9 @@ async def fetch_message(self, id: int, /) -> MessageT | None:
10121012
@dataclass(slots=True)
10131013
class Channel(Messageable[MessageT], Generic[MessageT, ClanT, GroupT]):
10141014
_state: ConnectionState
1015-
clan: ClanT = cast(ClanT, None)
1015+
clan: ClanT = cast("ClanT", None)
10161016
"""The clan this channel belongs to."""
1017-
group: GroupT = cast(GroupT, None)
1017+
group: GroupT = cast("GroupT", None)
10181018
"""The group this channel belongs to."""
10191019

10201020

steam/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,12 @@ def __init__(
432432
self.class_ = data["class"]
433433
"""Extra info about the item."""
434434
self.prices = cast(
435-
Mapping[Currency, int],
435+
"Mapping[Currency, int]",
436436
{Currency.try_name(name): price for name, price in data["prices"].items()},
437437
)
438438
"""The prices of the asset in the store."""
439439
self.original_prices = cast(
440-
Mapping[Currency, int] | None,
440+
"Mapping[Currency, int] | None",
441441
(
442442
{
443443
Currency.try_name(name): price

steam/chat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ def __init__(
175175
self, state: ConnectionState, chat_group: ChatGroup[Any, Any], user: User | ClientUser, member: chat.Member
176176
) -> None:
177177
super().__init__(state, user)
178-
self.clan = cast(ClanT, None)
179-
self.group = cast(GroupT, None)
178+
self.clan = cast("ClanT", None)
179+
self.group = cast("GroupT", None)
180180

181181
self._update(member)
182182

@@ -214,7 +214,7 @@ def __init__(self, proto: chat.IncomingChatMessageNotification, channel: ChatT,
214214
super().__init__(channel, proto)
215215
self.author = author
216216
self.created_at = DateTime.from_timestamp(proto.timestamp)
217-
self._mentions_ids = cast(tuple[ID32, ...], tuple(proto.mentions.ids))
217+
self._mentions_ids = cast("tuple[ID32, ...]", tuple(proto.mentions.ids))
218218
self.mentions_all = proto.mentions.mention_all
219219
self.mentions_here = proto.mentions.mention_here
220220

@@ -554,7 +554,7 @@ async def _from_proto(
554554
self._id = ChatGroupID(proto.chat_group_id)
555555
self.active_member_count = proto.active_member_count
556556
self._owner_id = ID32(proto.accountid_owner)
557-
self._top_members = cast(list[ID32], proto.top_members)
557+
self._top_members = cast("list[ID32]", proto.top_members)
558558
self.tagline = proto.chat_group_tagline
559559
self.app = PartialApp(state, id=proto.appid) if proto.appid else self.app
560560
self._avatar_sha = proto.chat_group_avatar_sha
@@ -632,7 +632,7 @@ def _update_header_state(self, proto: chat.GroupHeaderState, /) -> None:
632632

633633
def _update_group_state(self, group_state: chat.GroupState):
634634
self._partial_members = cast(
635-
dict[ID32, chat.Member], {member.accountid: member for member in group_state.members}
635+
"dict[ID32, chat.Member]", {member.accountid: member for member in group_state.members}
636636
)
637637
self._roles = {
638638
RoleID(role.role_id): Role(self._state, self, role, permissions)
@@ -801,7 +801,7 @@ async def search(self, name: str) -> Sequence[MemberT]:
801801
return [self._members[ID32(user.accountid)] for user in msg.matching_members]
802802

803803
return cast(
804-
list[MemberT],
804+
"list[MemberT]",
805805
self._maybe_members(
806806
user.id for user in [self._state._store_user(user.persona) for user in msg.matching_members]
807807
),

steam/clan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def create_event(
273273
if event.name != name or event.content != content:
274274
continue
275275
self._state.dispatch("event_create", event)
276-
return cast(Event[CreateableEvents, Self], event)
276+
return cast("Event[CreateableEvents, Self]", event)
277277
raise ValueError
278278

279279
async def create_announcement(
@@ -378,15 +378,15 @@ async def _load(self, *, from_proto: bool = False) -> Self:
378378
assert soup.title is not None
379379
_, _, self.name = soup.title.text.rpartition(" :: ")
380380
icon_url = soup.find("link", rel="image_src")
381-
url = URL(cast(str, icon_url["href"])) if isinstance(icon_url, Tag) else None
381+
url = URL(cast("str", icon_url["href"])) if isinstance(icon_url, Tag) else None
382382
if url:
383383
self._avatar_sha = bytes.fromhex(url.path.removesuffix("/").removesuffix("_full.jpg"))
384384

385385
headline = soup.find("div", class_="group_content group_summary")
386386
headline_h1 = headline.h1 if isinstance(headline, Tag) else None
387387
self.headline = headline_h1.text if headline_h1 else None
388388
content = soup.find("meta", property="og:description")
389-
self.summary = parse_bb_code(cast(str, content["content"])) if isinstance(content, Tag) else None
389+
self.summary = parse_bb_code(cast("str", content["content"])) if isinstance(content, Tag) else None
390390

391391
if self._is_app_clan:
392392
for entry in soup.find_all("div", class_="actionItem"):

steam/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ async def throttle() -> None:
475475
try:
476476
async with timeout(60):
477477
self.ws = cast(
478-
SteamWebSocket,
478+
"SteamWebSocket",
479479
await login_func(
480480
self,
481481
*args,
@@ -1118,7 +1118,7 @@ async def fetch_published_files(
11181118
language
11191119
The language to fetch the published files in. If ``None``, the current language is used.
11201120
"""
1121-
return await self._state.fetch_published_files(cast(tuple[PublishedFileID, ...], ids), revision, language)
1121+
return await self._state.fetch_published_files(cast("tuple[PublishedFileID, ...]", ids), revision, language)
11221122

11231123
async def create_post(self, content: str, /, app: App | None = None) -> Post[ClientUser]:
11241124
"""Create a post.

steam/enums.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,10 @@ def from_web_api_str(cls, string: str, /) -> Language:
767767

768768

769769
_REVERSE_API_LANGUAGE_MAP: Final = cast(
770-
Mapping[str, Language], {value: key for key, value in Language.API_LANGUAGE_MAP.items()}
770+
"Mapping[str, Language]", {value: key for key, value in Language.API_LANGUAGE_MAP.items()}
771771
)
772772
_REVERSE_WEB_API_MAP: Final = cast(
773-
Mapping[str, Language], {value: key for key, value in Language.WEB_API_MAP.items()}
773+
"Mapping[str, Language]", {value: key for key, value in Language.WEB_API_MAP.items()}
774774
)
775775

776776

@@ -1513,7 +1513,7 @@ class DepotFileFlag(Flags):
15131513
"""A symlink file."""
15141514

15151515

1516-
TYPE_TRANSFORM_MAP: Final = cast(Mapping[str, str], {
1516+
TYPE_TRANSFORM_MAP: Final = cast("Mapping[str, str]", {
15171517
"Dlc": "DLC",
15181518
})
15191519

steam/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, state: ConnectionState, clan: ClanT, data: clan.Event):
7575
"""The event's description."""
7676
self.app = PartialApp(state, id=data["appid"]) if data["appid"] else None
7777
"""The app that the event is going to be played in."""
78-
self.type = cast(EventTypeT, EventType.try_value(data["event_type"]))
78+
self.type = cast("EventTypeT", EventType.try_value(data["event_type"]))
7979
"""The event's type."""
8080
self.clan = clan
8181
"""The event's clan."""

0 commit comments

Comments
 (0)