Skip to content

Commit 2cfb87e

Browse files
authored
Merge pull request #228 from an-swe/feat/add-type-stubs
add type stubs for static type checking support
2 parents fba0d50 + 6658f1c commit 2cfb87e

67 files changed

Lines changed: 3035 additions & 325 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docker-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ jobs:
111111
docker cp pyproject.toml test_container:/root/python-sc2/
112112
docker cp uv.lock test_container:/root/python-sc2/
113113
docker cp sc2 test_container:/root/python-sc2/sc2
114+
docker cp s2clientprotocol test_container:/root/python-sc2/s2clientprotocol
114115
docker cp test test_container:/root/python-sc2/test
115116
docker cp examples test_container:/root/python-sc2/examples
116117
docker exec -i test_container bash -c "pip install uv \

dockerfiles/test_docker_image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ docker cp uv.lock test_container:/root/python-sc2/
4646
docker exec -i test_container bash -c "pip install uv && cd python-sc2 && uv sync --no-cache --no-install-project"
4747

4848
docker cp sc2 test_container:/root/python-sc2/sc2
49+
docker cp s2clientprotocol test_container:/root/python-sc2/s2clientprotocol
4950
docker cp test test_container:/root/python-sc2/test
5051

5152
# Run various test bots

examples/arcade_bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def on_start(self):
4242
await self.chat_send("Edit this message for automatic chat commands.")
4343
self.client.game_step = 2
4444

45-
async def on_step(self, iteration):
45+
async def on_step(self, iteration: int):
4646
# do marine micro vs zerglings
4747
for unit in self.units(UnitTypeId.MARINE):
4848
if self.enemy_units:

examples/competitive/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async def on_start(self):
77
print("Game started")
88
# Do things here before the game starts
99

10-
async def on_step(self, iteration):
10+
async def on_step(self, iteration: int):
1111
# Populate this function with whatever your bot should do!
1212
pass
1313

examples/distributed_workers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class TerranBot(BotAI):
11-
async def on_step(self, iteration):
11+
async def on_step(self, iteration: int):
1212
await self.distribute_workers()
1313
await self.build_supply()
1414
await self.build_workers()

examples/fastreload.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
from sc2 import maps
55
from sc2.data import Difficulty, Race
66
from sc2.main import _host_game_iter
7-
from sc2.player import Bot, Computer
7+
from sc2.player import AbstractPlayer, Bot, Computer
88

99

1010
def main():
11-
player_config = [Bot(Race.Zerg, zerg_rush.ZergRushBot()), Computer(Race.Terran, Difficulty.Medium)]
11+
player_config: list[AbstractPlayer] = [
12+
Bot(Race.Zerg, zerg_rush.ZergRushBot()),
13+
Computer(Race.Terran, Difficulty.Medium),
14+
]
1215

1316
gen = _host_game_iter(maps.get("Abyssal Reef LE"), player_config, realtime=False)
1417

examples/host_external_norestart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import sc2
21
from examples.zerg.zerg_rush import ZergRushBot
32
from sc2 import maps
43
from sc2.data import Race
54
from sc2.main import _host_game_iter
65
from sc2.player import Bot
6+
from sc2.portconfig import Portconfig
77

88

99
def main():
10-
portconfig = sc2.portconfig.Portconfig()
10+
portconfig: Portconfig = Portconfig()
1111
print(portconfig.as_json)
1212

1313
player_config = [Bot(Race.Zerg, ZergRushBot()), Bot(Race.Zerg, None)]

examples/protoss/cannon_rush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class CannonRushBot(BotAI):
12-
async def on_step(self, iteration):
12+
async def on_step(self, iteration: int):
1313
if iteration == 0:
1414
await self.chat_send("(probe)(pylon)(cannon)(cannon)(gg)")
1515

examples/protoss/find_adept_shades.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class FindAdeptShadesBot(BotAI):
1414
def __init__(self):
1515
self.shaded = False
16-
self.shades_mapping = {}
16+
self.shades_mapping: dict[int, int] = {}
1717

1818
async def on_start(self):
1919
self.client.game_step = 2

examples/protoss/threebase_voidray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class ThreebaseVoidrayBot(BotAI):
12-
async def on_step(self, iteration):
12+
async def on_step(self, iteration: int):
1313
target_base_count = 3
1414
target_stargate_count = 3
1515

0 commit comments

Comments
 (0)