Skip to content

Commit 13b1654

Browse files
committed
Migrate from black to ruff
1 parent 8257d0f commit 13b1654

File tree

10 files changed

+22
-16
lines changed

10 files changed

+22
-16
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ The following is how to setup a development environment for this project, NOT ho
3030
- `pip uninstall rlbot_flatbuffers`
3131
- `pip install --editable <path/to/rlbot_flatbuffers>`
3232

33-
This project is formatted using [Black](https://github.com/psf/black).
33+
This project is formatted using [Ruff](https://docs.astral.sh/ruff/formatter/).
3434

35-
- Install: `pip install black`.
36-
- Use: `black .`
35+
- Install: `pip install ruff`.
36+
- Sort imports: `ruff check --select I --fix`
37+
- Format code: `ruff format`
3738

3839
## Testing
3940

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ Repository = "https://github.com/RLBot/python-interface"
2323

2424
[tool.setuptools.dynamic]
2525
version = {attr = "rlbot.version.__version__"}
26+
27+
[dependency-groups]
28+
dev = [
29+
"ruff>=0.12.5",
30+
"toml>=0.10.2",
31+
]
32+
33+
[tool.ruff.format]
34+
docstring-code-format = true

rlbot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .version import __version__
1+
from .version import __version__ as __version__

rlbot/interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def disconnect(self):
323323
self.logger.critical("RLBot is not responding to our disconnect request!?")
324324
self._running = False
325325

326-
assert (
327-
not self._running
328-
), "Disconnect request or timeout should have set self._running to False"
326+
assert not self._running, (
327+
"Disconnect request or timeout should have set self._running to False"
328+
)
329329
self.is_connected = False

rlbot/utils/maps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"FuturaGarden": "UF_Day_P",
8484
"DFHStadium_Anniversary": "stadium_10a_p",
8585
"Holyfield": "Labs_Holyfield_Space_P",
86-
"DriftWoods_Night": "woods_night_p"
86+
"DriftWoods_Night": "woods_night_p",
8787
}
8888

8989
STANDARD_MAPS = [
@@ -138,5 +138,5 @@
138138
"Neotokyo_Arcade",
139139
"FuturaGarden",
140140
"DFHStadium_Anniversary",
141-
"DriftWoods_Night"
141+
"DriftWoods_Night",
142142
]

tests/fashion/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
5050
),
5151
)
5252

53-
self.logger.info(f"State setting new loadout")
53+
self.logger.info("State setting new loadout")
5454
self.set_loadout(loadout)
5555
self.last_tick = packet.match_info.frame_num
5656

tests/nexto/bot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ def toxicity(self, packet: GamePacket):
369369
return
370370

371371
for p in human_opps:
372-
373372
d = math.sqrt(
374373
(p.physics.location.x - bad_goal[0]) ** 2
375374
+ (p.physics.location.y - bad_goal[1]) ** 2

tests/nexto/nexto_obs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ def batched_build_obs(self, encoded_states: np.ndarray):
286286
for i in range(n_players):
287287
encoded_player = encoded_states[
288288
:,
289-
players_start_index
290-
+ i * player_length : players_start_index
289+
players_start_index + i * player_length : players_start_index
291290
+ (i + 1) * player_length,
292291
]
293292

tests/run_forever.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
if __name__ == "__main__":
1515
match_manager = MatchManager(RLBOT_SERVER_FOLDER)
16-
match_manager.ensure_server_started()
1716

1817
current_map = -1
1918

tests/runner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
match_manager = MatchManager(RLBOT_SERVER_FOLDER)
1717

1818
try:
19-
match_manager.ensure_server_started()
2019
match_manager.start_match(MATCH_CONFIG_PATH)
2120

2221
logger.info("Waiting before shutdown...")
@@ -25,7 +24,7 @@
2524
except KeyboardInterrupt:
2625
logger.warning("Shutting down early due to interrupt")
2726
except Exception:
28-
logger.critical(f"Shutting down early due to the following error:")
27+
logger.critical("Shutting down early due to the following error:")
2928
print_exc()
3029

3130
match_manager.shut_down()

0 commit comments

Comments
 (0)