Skip to content

Commit 202694e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 90fee18 commit 202694e

26 files changed

+62
-62
lines changed

steam/_const.py

+6-6
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

+1-1
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

+1-1
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

+2-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,12 @@ def __init__(
435435
self.class_ = data["class"]
436436
"""Extra info about the item."""
437437
self.prices = cast(
438-
Mapping[Currency, int],
438+
"Mapping[Currency, int]",
439439
{Currency.try_name(name): price for name, price in data["prices"].items()},
440440
)
441441
"""The prices of the asset in the store."""
442442
self.original_prices = cast(
443-
Mapping[Currency, int] | None,
443+
"Mapping[Currency, int] | None",
444444
(
445445
{
446446
Currency.try_name(name): price

steam/chat.py

+6-6
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

+3-3
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

+2-2
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

+3-3
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

+1-1
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."""

steam/ext/commands/commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ def decorator(callback: CoroFuncT) -> G:
772772
attrs.setdefault("parent", self)
773773
result = group(name=name, cls=cls or Group, **attrs)(callback)
774774
self.add_command(result)
775-
return cast(G, result) # casting shouldn't really be necessary
775+
return cast("G", result) # casting shouldn't really be necessary
776776

777777
return decorator(callback) if callback is not None else decorator
778778

steam/ext/commands/converters.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async def source(ctx, command: commands.Command): # this then calls command_con
108108

109109
annotations = get_annotations(func)
110110
converter_for = annotations["return"]
111-
func = cast(BasicConverter[T], func)
111+
func = cast("BasicConverter[T]", func)
112112
func.converter_for = converter_for
113113
CONVERTERS[converter_for].append(func)
114114
return func
@@ -221,7 +221,7 @@ async def is_cool(ctx, user: steam.User): ...
221221
(
222222
command.special_converters
223223
if isinstance(command, Command)
224-
else cast(list[Converters], command.__special_converters__) # type: ignore
224+
else cast("list[Converters]", command.__special_converters__) # type: ignore
225225
).append(cls)
226226
except AttributeError:
227227
command.__special_converters__ = [cls] # type: ignore
@@ -531,4 +531,4 @@ def __class_getitem__(cls, converter: T | tuple[T]) -> Self:
531531
if (isinstance(converter, type) and issubclass(converter, str)) or converter is types.NoneType:
532532
raise TypeError(f"Greedy[{converter.__name__}] is invalid") # type: ignore
533533

534-
return cast(Self, GreedyGenericAlias(cls, (converter,)))
534+
return cast("Self", GreedyGenericAlias(cls, (converter,)))

steam/ext/commands/cooldown.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
class BucketTypeType:
2525
def __new__(cls, *values: int | None) -> Self:
26-
return cast(Self, values)
26+
return cast("Self", values)
2727

2828

2929
class BucketType(IntEnum):

steam/ext/commands/help.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class HelpCommand(Command[None, ..., None]):
3232
"""The context for the command's invocation."""
3333

3434
def __init__(self, **kwargs: Unpack[CommandKwargs]):
35-
default = cast(CommandKwargs, {"name": "help", "help": "Shows this message."} | kwargs)
35+
default = cast("CommandKwargs", {"name": "help", "help": "Shows this message."} | kwargs)
3636
super().__init__(self.command_callback, **default)
3737

3838
async def invoke(self, ctx: Context) -> None:

steam/ext/csgo/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(self, state: GCState, match_info: cstrike.MatchInfo, players: dict[
8787

8888
self.rounds: list[Round] = []
8989
for round in match_info.roundstatsall:
90-
player_ids = cast(list[ID32], round.reservation.account_ids)
90+
player_ids = cast("list[ID32]", round.reservation.account_ids)
9191
team_size = len(player_ids) // len(round.team_scores)
9292
previous_scores = [0] * len(round.team_scores)
9393
teams: list[Team] = []
@@ -201,7 +201,7 @@ class MatchPlayer(PartialUser, user.WrapsUser): # type: ignore
201201
mvp: bool
202202

203203

204-
LEVEL_MAP: Final = cast(Mapping[int, str], {
204+
LEVEL_MAP: Final = cast("Mapping[int, str]", {
205205
0: "Not Recruited",
206206
1: "Recruit", # 1-3
207207
4: "Private", # 4-7 etc.

steam/ext/csgo/protobufs/cstrike.py

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

steam/ext/csgo/state.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
def READ_F32(
35-
bytes: bytes, *, _unpacker: Callable[[bytes], tuple[float]] = cast(Any, struct.Struct("<f").unpack_from)
35+
bytes: bytes, *, _unpacker: Callable[[bytes], tuple[float]] = cast("Any", struct.Struct("<f").unpack_from)
3636
) -> float:
3737
(f32,) = _unpacker(bytes)
3838
return f32

steam/ext/csgo/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Final, NamedTuple, cast
88

99
CHARS = cast(
10-
Mapping[str, int], dict(zip("ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789", itertools.count()))
10+
"Mapping[str, int]", dict(zip("ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789", itertools.count()))
1111
)
1212

1313

steam/game_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def where(cls, **kwargs: Unpack[QueryWhereKwargs]) -> str:
176176
raise TypeError(f"{name!r} is an invalid keyword argument for where()") from None
177177
metadata: tuple[Any, ...] = annotated.__metadata__
178178
if name in QueryWhereBoolKwargs.__annotations__:
179-
value = cast(bool, value)
179+
value = cast("bool", value)
180180
try:
181181
filter_code = metadata[not value]
182182
except IndexError:

steam/id.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def id64_from_url(url: StrOrURL, /, session: aiohttp.ClientSession | None
167167
return id.id64 if id is not None else None
168168

169169

170-
_ID64_TO_ID32: Final = cast(Callable[[int], ID32], 0xFFFFFFFF.__and__)
170+
_ID64_TO_ID32: Final = cast("Callable[[int], ID32]", 0xFFFFFFFF.__and__)
171171

172172

173173
TypeT = TypeVar("TypeT", bound=Type, default=Type, covariant=True)
@@ -281,7 +281,7 @@ def universe(self) -> Universe:
281281
@property
282282
def type(self) -> TypeT:
283283
"""The Steam type of the ID."""
284-
return cast(TypeT, Type.try_value((self.id64 >> 52) & 0xF))
284+
return cast("TypeT", Type.try_value((self.id64 >> 52) & 0xF))
285285

286286
@property
287287
def instance(self) -> Instance:

steam/leaderboard.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Leaderboard(Generic[AppT, DisplayNameT]):
8686
"""The display type of the leaderboard."""
8787
entry_count: int
8888
"""The number of entries in the leaderboard."""
89-
display_name: DisplayNameT = cast(DisplayNameT, None)
89+
display_name: DisplayNameT = cast("DisplayNameT", None)
9090
"""The display name of the leaderboard. This is only set if the leaderboard is fetched using :meth:`PartialApp.leaderboards`."""
9191

9292
def __repr__(self) -> str:

steam/protobufs/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
PROTOBUFS: Final = cast("Mapping[EMsg, type[ProtobufMessage | Message]]", {})
1515
RequestType: TypeAlias = "type[UnifiedMessage]"
1616
ResponseType: TypeAlias = "type[UnifiedMessage]"
17-
UMS: Final = cast(Mapping[str, tuple[RequestType, ResponseType]], {})
17+
UMS: Final = cast("Mapping[str, tuple[RequestType, ResponseType]]", {})
1818
GC_PROTOBUFS: Final = cast("Mapping[AppID, Mapping[IntEnum, type[GCProtobufMessage | GCMessage]]]", {})
1919

2020
from .emsg import *

steam/reaction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class _Reaction:
5656

5757
BASE_REACTION_URL: Final = "https://store.cloudflare.steamstatic.com/public/images/loyalty/reactions/{type}/{id}.png"
5858
BASE_ECONOMY_URL: Final = URL("https://community.akamai.steamstatic.com/economy")
59-
AWARD_ID_TO_NAME: Final = cast(Mapping[int, str], {
59+
AWARD_ID_TO_NAME: Final = cast("Mapping[int, str]", {
6060
1: "Deep Thoughts",
6161
2: "Heartwarming",
6262
3: "Hilarious",

0 commit comments

Comments
 (0)