Skip to content

Commit 94e94ed

Browse files
committed
Fix most pyrefly issues
1 parent 724da69 commit 94e94ed

33 files changed

+354
-263
lines changed

.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

.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

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
```

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,18 @@ project_includes = [
9898
# "examples",
9999
# "test"
100100
]
101+
project-excludes = [
102+
# Disable for those files and folders
103+
"sc2/data.py",
104+
# TODO Temp disable for those files and folders
105+
"sc2/client.py",
106+
"sc2/bot_ai_internal.py",
107+
"sc2/bot_ai.py",
108+
]
101109

102110
[tool.pyrefly.errors]
103111
bad-override = false
112+
inconsistent-overload = false
104113

105114
[tool.ruff]
106115
target-version = 'py310'

s2clientprotocol/data_pb2.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Iterable
1+
from collections.abc import Sequence
22
from enum import Enum
33

44
from google.protobuf.message import Message
@@ -71,15 +71,15 @@ class TargetType(Enum):
7171
class Weapon(Message):
7272
type: int
7373
damage: float
74-
damage_bonus: Iterable[DamageBonus]
74+
damage_bonus: Sequence[DamageBonus]
7575
attacks: int
7676
range: float
7777
speed: float
7878
def __init__(
7979
self,
8080
type: int = ...,
8181
damage: float = ...,
82-
damage_bonus: Iterable[DamageBonus] = ...,
82+
damage_bonus: Sequence[DamageBonus] = ...,
8383
attacks: int = ...,
8484
range: float = ...,
8585
speed: float = ...,
@@ -100,14 +100,14 @@ class UnitTypeData(Message):
100100
has_vespene: bool
101101
has_minerals: bool
102102
sight_range: float
103-
tech_alias: Iterable[int]
103+
tech_alias: Sequence[int]
104104
unit_alias: int
105105
tech_requirement: int
106106
require_attached: bool
107-
attributes: Iterable[int]
107+
attributes: Sequence[int]
108108
movement_speed: float
109109
armor: float
110-
weapons: Iterable[Weapon]
110+
weapons: Sequence[Weapon]
111111
def __init__(
112112
self,
113113
unit_id: int = ...,
@@ -124,14 +124,14 @@ class UnitTypeData(Message):
124124
has_vespene: bool = ...,
125125
has_minerals: bool = ...,
126126
sight_range: float = ...,
127-
tech_alias: Iterable[int] = ...,
127+
tech_alias: Sequence[int] = ...,
128128
unit_alias: int = ...,
129129
tech_requirement: int = ...,
130130
require_attached: bool = ...,
131-
attributes: Iterable[int] = ...,
131+
attributes: Sequence[int] = ...,
132132
movement_speed: float = ...,
133133
armor: float = ...,
134-
weapons: Iterable[Weapon] = ...,
134+
weapons: Sequence[Weapon] = ...,
135135
) -> None: ...
136136

137137
class UpgradeData(Message):

s2clientprotocol/debug_pb2.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Iterable
1+
from collections.abc import Sequence
22
from enum import Enum
33

44
from google.protobuf.message import Message
@@ -27,16 +27,16 @@ class DebugCommand(Message):
2727
) -> None: ...
2828

2929
class DebugDraw(Message):
30-
text: Iterable[DebugText]
31-
lines: Iterable[DebugLine]
32-
boxes: Iterable[DebugBox]
33-
spheres: Iterable[DebugSphere]
30+
text: Sequence[DebugText]
31+
lines: Sequence[DebugLine]
32+
boxes: Sequence[DebugBox]
33+
spheres: Sequence[DebugSphere]
3434
def __init__(
3535
self,
36-
text: Iterable[DebugText] = ...,
37-
lines: Iterable[DebugLine] = ...,
38-
boxes: Iterable[DebugBox] = ...,
39-
spheres: Iterable[DebugSphere] = ...,
36+
text: Sequence[DebugText] = ...,
37+
lines: Sequence[DebugLine] = ...,
38+
boxes: Sequence[DebugBox] = ...,
39+
spheres: Sequence[DebugSphere] = ...,
4040
) -> None: ...
4141

4242
class Line(Message):
@@ -110,8 +110,8 @@ class DebugCreateUnit(Message):
110110
) -> None: ...
111111

112112
class DebugKillUnit(Message):
113-
tag: Iterable[int]
114-
def __init__(self, tag: Iterable[int] = ...) -> None: ...
113+
tag: Sequence[int]
114+
def __init__(self, tag: Sequence[int] = ...) -> None: ...
115115

116116
class Test(Enum):
117117
hang: int

s2clientprotocol/query_pb2.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
from collections.abc import Iterable
1+
from collections.abc import Sequence
22

33
from google.protobuf.message import Message
44

55
from .common_pb2 import AvailableAbility, Point2D
66

77
class RequestQuery(Message):
8-
pathing: Iterable[RequestQueryPathing]
9-
abilities: Iterable[RequestQueryAvailableAbilities]
10-
placements: Iterable[RequestQueryBuildingPlacement]
8+
pathing: Sequence[RequestQueryPathing]
9+
abilities: Sequence[RequestQueryAvailableAbilities]
10+
placements: Sequence[RequestQueryBuildingPlacement]
1111
ignore_resource_requirements: bool
1212
def __init__(
1313
self,
14-
pathing: Iterable[RequestQueryPathing] = ...,
15-
abilities: Iterable[RequestQueryAvailableAbilities] = ...,
16-
placements: Iterable[RequestQueryBuildingPlacement] = ...,
14+
pathing: Sequence[RequestQueryPathing] = ...,
15+
abilities: Sequence[RequestQueryAvailableAbilities] = ...,
16+
placements: Sequence[RequestQueryBuildingPlacement] = ...,
1717
ignore_resource_requirements: bool = ...,
1818
) -> None: ...
1919

2020
class ResponseQuery(Message):
21-
pathing: Iterable[ResponseQueryPathing]
22-
abilities: Iterable[ResponseQueryAvailableAbilities]
23-
placements: Iterable[ResponseQueryBuildingPlacement]
21+
pathing: Sequence[ResponseQueryPathing]
22+
abilities: Sequence[ResponseQueryAvailableAbilities]
23+
placements: Sequence[ResponseQueryBuildingPlacement]
2424
def __init__(
2525
self,
26-
pathing: Iterable[ResponseQueryPathing] = ...,
27-
abilities: Iterable[ResponseQueryAvailableAbilities] = ...,
28-
placements: Iterable[ResponseQueryBuildingPlacement] = ...,
26+
pathing: Sequence[ResponseQueryPathing] = ...,
27+
abilities: Sequence[ResponseQueryAvailableAbilities] = ...,
28+
placements: Sequence[ResponseQueryBuildingPlacement] = ...,
2929
) -> None: ...
3030

3131
class RequestQueryPathing(Message):
@@ -48,12 +48,12 @@ class RequestQueryAvailableAbilities(Message):
4848
def __init__(self, unit_tag: int = ...) -> None: ...
4949

5050
class ResponseQueryAvailableAbilities(Message):
51-
abilities: Iterable[AvailableAbility]
51+
abilities: Sequence[AvailableAbility]
5252
unit_tag: int
5353
unit_type_id: int
5454
def __init__(
5555
self,
56-
abilities: Iterable[AvailableAbility] = ...,
56+
abilities: Sequence[AvailableAbility] = ...,
5757
unit_tag: int = ...,
5858
unit_type_id: int = ...,
5959
) -> None: ...

0 commit comments

Comments
 (0)