Skip to content

Commit 0ecf64c

Browse files
committed
Add pyrefly ignores and update pyrefly version
1 parent 54e4aa8 commit 0ecf64c

4 files changed

Lines changed: 71 additions & 32 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dev = [
5454
"pyglet>=2.0.20",
5555
"pylint>=3.3.2",
5656
# Type checker
57-
"pyrefly>=0.46.3",
57+
"pyrefly>=0.58.0",
5858
"pytest>=8.3.4",
5959
"pytest-asyncio>=0.25.0",
6060
"pytest-benchmark>=5.1.0",
@@ -70,7 +70,7 @@ dev = [
7070
]
7171

7272
[tool.setuptools]
73-
package-dir = { sc2 = "sc2", s2clientprotocol = "s2clientprotocol" }
73+
package-dir = { sc2 = "sc2" }
7474

7575
[tool.setuptools.package-data]
7676
sc2 = ["py.typed", "*.pyi"]

sc2/client.py

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def join_game(
9393
request = sc_pb.RequestJoinGame(observed_player_id=observed_player_id, options=ifopts)
9494
else:
9595
assert isinstance(race, Race)
96-
request = sc_pb.RequestJoinGame(race=race.value, options=ifopts)
96+
request = sc_pb.RequestJoinGame(race=race.value, options=ifopts) # pyrefly: ignore[bad-argument-type]
9797

9898
if portconfig:
9999
request.server_ports.game_port = portconfig.server[0]
@@ -357,7 +357,11 @@ async def chat_send(self, message: str, team_only: bool) -> None:
357357
ch = ChatChannel.Team if team_only else ChatChannel.Broadcast
358358
await self._execute(
359359
action=sc_pb.RequestAction(
360-
actions=[sc_pb.Action(action_chat=sc_pb.ActionChat(channel=ch.value, message=message))]
360+
actions=[
361+
sc_pb.Action(
362+
action_chat=sc_pb.ActionChat(channel=ch.value, message=message) # type: ignore[bad-argument-type]
363+
)
364+
]
361365
)
362366
)
363367

@@ -710,11 +714,12 @@ async def debug_set_unit_value(
710714
assert value >= 0, "Value can't be negative"
711715
await self._execute(
712716
debug=sc_pb.RequestDebug(
713-
# pyrefly: ignore
714717
debug=(
715718
debug_pb.DebugCommand(
716719
unit_value=debug_pb.DebugSetUnitValue(
717-
unit_value=unit_value, value=float(value), unit_tag=unit_tag
720+
unit_value=unit_value, # pyrefly: ignore[bad-argument-type]
721+
value=float(value),
722+
unit_tag=unit_tag,
718723
)
719724
)
720725
for unit_tag in unit_tags
@@ -727,57 +732,88 @@ async def debug_hang(self, delay_in_seconds: float) -> None:
727732
delay_in_ms = int(round(delay_in_seconds * 1000))
728733
await self._execute(
729734
debug=sc_pb.RequestDebug(
730-
debug=[debug_pb.DebugCommand(test_process=debug_pb.DebugTestProcess(test=1, delay_ms=delay_in_ms))]
735+
debug=[
736+
debug_pb.DebugCommand(
737+
test_process=debug_pb.DebugTestProcess(
738+
test=1, # pyrefly: ignore
739+
delay_ms=delay_in_ms,
740+
)
741+
)
742+
]
731743
)
732744
)
733745

734746
async def debug_show_map(self) -> None:
735747
"""Reveals the whole map for the bot. Using it a second time disables it again."""
736-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=1)]))
748+
await self._execute(
749+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=1)]) # pyrefly: ignore[bad-argument-type]
750+
)
737751

738752
async def debug_control_enemy(self) -> None:
739753
"""Allows control over enemy units and structures similar to team games control - does not allow the bot to spend the opponent's ressources. Using it a second time disables it again."""
740-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=2)]))
754+
await self._execute(
755+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=2)]) # pyrefly: ignore[bad-argument-type]
756+
)
741757

742758
async def debug_food(self) -> None:
743759
"""Should disable food usage (does not seem to work?). Using it a second time disables it again."""
744-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=3)]))
760+
await self._execute(
761+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=3)]) # pyrefly: ignore[bad-argument-type]
762+
)
745763

746764
async def debug_free(self) -> None:
747765
"""Units, structures and upgrades are free of mineral and gas cost. Using it a second time disables it again."""
748-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=4)]))
766+
await self._execute(
767+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=4)]) # pyrefly: ignore[bad-argument-type]
768+
)
749769

750770
async def debug_all_resources(self) -> None:
751771
"""Gives 5000 minerals and 5000 vespene to the bot."""
752-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=5)]))
772+
await self._execute(
773+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=5)]) # pyrefly: ignore[bad-argument-type]
774+
)
753775

754776
async def debug_god(self) -> None:
755777
"""Your units and structures no longer take any damage. Using it a second time disables it again."""
756-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=6)]))
778+
await self._execute(
779+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=6)]) # pyrefly: ignore[bad-argument-type]
780+
)
757781

758782
async def debug_minerals(self) -> None:
759783
"""Gives 5000 minerals to the bot."""
760-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=7)]))
784+
await self._execute(
785+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=7)]) # pyrefly: ignore[bad-argument-type]
786+
)
761787

762788
async def debug_gas(self) -> None:
763789
"""Gives 5000 vespene to the bot. This does not seem to be working."""
764-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=8)]))
790+
await self._execute(
791+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=8)]) # pyrefly: ignore[bad-argument-type]
792+
)
765793

766794
async def debug_cooldown(self) -> None:
767795
"""Disables cooldowns of unit abilities for the bot. Using it a second time disables it again."""
768-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=9)]))
796+
await self._execute(
797+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=9)]) # pyrefly: ignore[bad-argument-type]
798+
)
769799

770800
async def debug_tech_tree(self) -> None:
771801
"""Removes all tech requirements (e.g. can build a factory without having a barracks). Using it a second time disables it again."""
772-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=10)]))
802+
await self._execute(
803+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=10)]) # pyrefly: ignore[bad-argument-type]
804+
)
773805

774806
async def debug_upgrade(self) -> None:
775807
"""Researches all currently available upgrades. E.g. using it once unlocks combat shield, stimpack and 1-1. Using it a second time unlocks 2-2 and all other upgrades stay researched."""
776-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=11)]))
808+
await self._execute(
809+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=11)]) # pyrefly: ignore[bad-argument-type]
810+
)
777811

778812
async def debug_fast_build(self) -> None:
779813
"""Sets the build time of units and structures and upgrades to zero. Using it a second time disables it again."""
780-
await self._execute(debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=12)]))
814+
await self._execute(
815+
debug=sc_pb.RequestDebug(debug=[debug_pb.DebugCommand(game_state=12)]) # pyrefly: ignore[bad-argument-type]
816+
)
781817

782818
async def quick_save(self) -> None:
783819
"""Saves the current game state to an in-memory bookmark.

sc2/controller.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ async def create_game(self, game_map, players, realtime: bool, random_seed=None,
3939
p = req.player_setup.add()
4040
p.type = player.type.value
4141
if isinstance(player, Computer):
42+
# pyrefly: ignore[bad-assignment]
4243
p.race = player.race.value
44+
# pyrefly: ignore[bad-assignment]
4345
p.difficulty = player.difficulty.value
4446
if player.ai_build is not None:
47+
# pyrefly: ignore[bad-assignment]
4548
p.ai_build = player.ai_build.value
4649

4750
logger.info("Creating new game")

uv.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)