Skip to content

Commit e3c6088

Browse files
authored
Merge pull request #235 from BurnySc2/fix-pyrefly-errors
Fix pyrefly type checker issues
2 parents 0a130d7 + f38ddf2 commit e3c6088

93 files changed

Lines changed: 831 additions & 2794 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
uv run pre-commit install
5252
5353
- name: Run pre-commit hooks
54-
run: uv run pre-commit run --all-files --hook-stage push
54+
run: uv run pre-commit run --all-files --hook-stage pre-push
5555

5656
generate_dicts_from_data_json:
5757
name: Generate dicts from data.json
@@ -80,7 +80,7 @@ jobs:
8080
run: |
8181
mv sc2/dicts sc2/dicts_old
8282
uv run python generate_dicts_from_data_json.py
83-
uv run pre-commit run --all-files --hook-stage push || true
83+
uv run pre-commit run --all-files --hook-stage pre-push || true
8484
rm -rf sc2/dicts/__pycache__ sc2/dicts_old/__pycache__
8585
8686
- name: Upload generated dicts folder as artifact

.github/workflows/docker-ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ jobs:
163163
docker cp pyproject.toml test_container:/root/python-sc2/
164164
docker cp uv.lock test_container:/root/python-sc2/
165165
docker cp sc2 test_container:/root/python-sc2/sc2
166-
docker cp s2clientprotocol test_container:/root/python-sc2/s2clientprotocol
167166
docker cp test test_container:/root/python-sc2/test
168167
docker cp examples test_container:/root/python-sc2/examples
169168
docker exec -i test_container bash -c "pip install uv \

.pre-commit-config.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,25 @@ repos:
3838
# Autoformat code
3939
- id: ruff-format-check
4040
name: Check if files are formatted
41-
stages: [push]
41+
stages: [pre-push]
4242
language: system
43+
# Run the following command to fix:
44+
# uv run ruff format .
4345
entry: uv run ruff format . --check --diff
4446
pass_filenames: false
4547

4648
- id: ruff-lint
4749
name: Lint files
48-
stages: [push]
50+
stages: [pre-push]
4951
language: system
52+
# Run the following command to fix:
53+
# uv run ruff check . --fix
5054
entry: uv run ruff check .
5155
pass_filenames: false
5256

53-
# TODO Fix issues
54-
# - id: pyrefly
55-
# name: Static types checking with pyrefly
56-
# stages: [push]
57-
# language: system
58-
# entry: uv run pyrefly check
59-
# pass_filenames: false
57+
- id: pyrefly
58+
name: Static types checking with pyrefly
59+
stages: [pre-push]
60+
language: system
61+
entry: uv run pyrefly check
62+
pass_filenames: false

.pyre_configuration

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,5 @@ Git commit messages use [imperative-style messages](https://stackoverflow.com/a/
186186
To run pre-commit hooks (which run autoformatting and autosort imports) you can run
187187
```sh
188188
uv run pre-commit install
189-
uv run pre-commit run --all-files --hook-stage push
189+
uv run pre-commit run --all-files --hook-stage pre-push
190190
```

dockerfiles/test_docker_image.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ docker cp uv.lock test_container:/root/python-sc2/
3535
docker exec -i test_container bash -c "pip install uv && cd python-sc2 && uv sync --no-cache --no-install-project"
3636

3737
docker cp sc2 test_container:/root/python-sc2/sc2
38-
docker cp s2clientprotocol test_container:/root/python-sc2/s2clientprotocol
3938
docker cp test test_container:/root/python-sc2/test
4039

4140
# Run various test bots
4241
docker exec -i test_container bash -c "cd python-sc2 && uv run python test/travis_test_script.py test/autotest_bot.py"
4342
docker exec -i test_container bash -c "cd python-sc2 && uv run python test/travis_test_script.py test/queries_test_bot.py"
44-
#docker exec -i test_container bash -c "cd python-sc2 && uv run python test/travis_test_script.py test/damagetest_bot.py"
43+
docker exec -i test_container bash -c "cd python-sc2 && uv run python test/travis_test_script.py test/damagetest_bot.py"
4544

4645
docker cp examples test_container:/root/python-sc2/examples
4746
docker exec -i test_container bash -c "cd python-sc2 && uv run python test/run_example_bots_vs_computer.py"

dockerfiles/test_new_python_candidate.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ docker cp uv.lock test_container:/root/python-sc2/
3636
docker exec -i test_container bash -c "pip install uv && cd python-sc2 && uv sync --no-cache --no-install-project"
3737

3838
docker cp sc2 test_container:/root/python-sc2/sc2
39-
docker cp s2clientprotocol test_container:/root/python-sc2/s2clientprotocol
4039
docker cp test test_container:/root/python-sc2/test
4140

4241
# Run various test bots

examples/arcade_bot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def position_around_unit(
101101
step_size: int = 1,
102102
exclude_out_of_bounds: bool = True,
103103
):
104-
# pyre-ignore[16]
105104
pos = pos.position.rounded
106105
positions = {
107106
pos.offset(Point2((x, y)))
@@ -114,7 +113,6 @@ def position_around_unit(
114113
positions = {
115114
p
116115
for p in positions
117-
# pyre-ignore[16]
118116
if 0 <= p[0] < self.game_info.pathing_grid.width and 0 <= p[1] < self.game_info.pathing_grid.height
119117
}
120118
return positions

examples/bot_vs_bot.py

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

1616

1717
def main_old():
18-
result: list[Result] = run_game(
18+
result: Result | list[Result | None] = run_game(
1919
maps.get("AcropolisLE"),
2020
[
2121
Bot(Race.Protoss, WarpGateBot()),

examples/competitive/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import aiohttp
55
from loguru import logger
66

7-
import sc2
87
from sc2.client import Client
8+
from sc2.main import _play_game
9+
from sc2.portconfig import Portconfig
910
from sc2.protocol import ConnectionAlreadyClosedError
1011

1112

@@ -41,7 +42,7 @@ def run_ladder_game(bot):
4142
else:
4243
ports = [lan_port + p for p in range(1, 6)]
4344

44-
portconfig = sc2.portconfig.Portconfig()
45+
portconfig = Portconfig()
4546
portconfig.server = [ports[1], ports[2]]
4647
portconfig.players = [[ports[3], ports[4]]]
4748

@@ -56,10 +57,11 @@ def run_ladder_game(bot):
5657
# Modified version of sc2.main._join_game to allow custom host and port, and to not spawn an additional sc2process (thanks to alkurbatov for fix)
5758
async def join_ladder_game(host, port, players, realtime, portconfig, save_replay_as=None, game_time_limit=None):
5859
ws_url = f"ws://{host}:{port}/sc2api"
60+
# pyrefly: ignore
5961
ws_connection = await aiohttp.ClientSession().ws_connect(ws_url, timeout=120)
6062
client = Client(ws_connection)
6163
try:
62-
result = await sc2.main._play_game(players[0], client, realtime, portconfig, game_time_limit)
64+
result = await _play_game(players[0], client, realtime, portconfig, game_time_limit)
6365
if save_replay_as is not None:
6466
await client.save_replay(save_replay_as)
6567
# await client.leave()
@@ -68,6 +70,6 @@ async def join_ladder_game(host, port, players, realtime, portconfig, save_repla
6870
logger.error("Connection was closed before the game ended")
6971
return None
7072
finally:
71-
ws_connection.close()
73+
await ws_connection.close()
7274

7375
return result

0 commit comments

Comments
 (0)