8000 Switch from black to ruff format (#2550) · pythonarcade/arcade@79defbf · GitHub
[go: up one dir, main page]

Skip to content

Commit 79defbf

Browse files
cdeileinarf
andauthored
Switch from black to ruff format (#2550)
* Improve make.py a bit * ruff format changes on arcade * Switch from black to ruff format * Fix ruff-check in .github/workflows/test.yml --------- Co-authored-by: Einar Forselv <eforselv@gmail.com>
1 parent 5743504 commit 79defbf

34 files changed

+132
-216
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ jobs:
3636
id: wheel
3737
run: |
3838
python -m pip install -e .[dev]
39+
- name: "code-inspection: formatting"
40+
if: ${{ (success() || failure()) && steps.wheel.outcome == 'success' }}
41+
run: |
42+
python ./make.py format --check
43+
- name: "code-inspection: ruff-check"
44+
if: ${{ (success() || failure()) && steps.wheel.outcome == 'success' }}
45+
run: |
46+
python ./make.py ruff-check
3947
- name: "code-inspection: mypy"
4048
if: ${{ (success() || failure()) && steps.wheel.outcome == 'success' }}
4149
run: |
@@ -44,14 +52,6 @@ jobs:
4452
if: ${{ (success() || failure()) && steps.wheel.outcome == 'success' }}
4553
run: |
4654
python ./make.py pyright
47-
- name: "code-inspection: ruff"
48-
if: ${{ (success() || failure()) && steps.wheel.outcome == 'success' }}
49-
run: |
50-
python ./make.py ruff
51-
- name: "code-inspection: formatting"
52-
if: ${{ (success() || failure()) && steps.wheel.outcome == 'success' }}
53-
run: |
54-
python ./make.py format --check
5555
# Prepare the Pull Request Payload artifact. If this fails,
5656
# we fail silently using the `continue-on-error` option. It's
5757
# nice if this succeeds, but if it fails for any reason, it

CONTRIBUTING.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,20 @@ steps at the end of this document.
8181

8282
## Formatting
8383

84-
Arcade uses [Black](https://black.readthedocs.io/en/stable) for autoformatting our code.
84+
Arcade uses [ruff format](https://docs.astral.sh/ruff/formatter/) for autoformatting our code
85+
as well as sorting imports.
8586

8687
This can be run both with our `make.py` script, as well as setup for your editor to run it automatically.
87-
See [this link](https://black.readthedocs.io/en/stable/integrations/editors.html) for more information on
88-
Black integration for your specific editor.
88+
See [this link](https://docs.astral.sh/ruff/editors/) for more information on ruff editor integration.
8989

90-
The following command will run black for you if you do not want to configure your editor to do it. It can be
91-
a good idea to run this command when you are finished working anyway, as our CI will use this to check that
92-
the formatting is correct.
90+
The following command will run ``ruff format`` for you if you do not want to configure your editor to do it.
91+
It can be a good idea to run this command when you are finished working anyway,
92+
as our CI will use this to check that the formatting is correct.
9393

9494
```bash
9595
python make.py format
9696
```
9797

98-
In addition to Black, this will sort the imports using [Ruff](https://docs.astral.sh/ruff/). If you want to set up
99-
your editor to run this, please see [this link](https://docs.astral.sh/ruff/integrations/) for more information on
100-
Ruff integration for your specific editor.
101-
10298
Docstring should be formatted using [Google Style](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
10399

104100
The minium for docstrings is covering all parameters in an `Args:` block.

arcade/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ def show_view(self, new_view: View) -> None:
962962
"""
963963
if not isinstance(new_view, View):
964964
raise TypeError(
965-
f"Window.show_view() takes an arcade.View," f"but it got a {type(new_view)}."
965+
f"Window.show_view() takes an arcade.View, but it got a {type(new_view)}."
966966
)
967967

968968
self._ctx.screen.use()

arcade/camera/camera_2d.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ def __init__(
124124
if projection is not None:
125125
if left == right:
126126
raise ZeroProjectionDimension(
127-
(f"projection width is 0 due to equal {left=}" f"and {right=} values")
127+
f"projection width is 0 due to equal {left=} and {right=} values"
128128
)
129129
if bottom == top:
130130
raise ZeroProjectionDimension(
131-
(f"projection height is 0 due to equal {bottom=}" f"and {top=}")
131+
f"projection height is 0 due to equal {bottom=} and {top=}"
132132
)
133133
if near == far:
134134
raise ZeroProjectionDimension(
135-
f"projection depth is 0 due to equal {near=}" f"and {far=} values"
135+
f"projection depth is 0 due to equal {near=} and {far=} values"
136136
)
137137

138138
pos_x = position[0] if position is not None else half_width
@@ -223,17 +223,17 @@ def from_camera_data(
223223
left, right = projection_data.left, projection_data.right
224224
if projection_data.left == projection_data.right:
225225
raise ZeroProjectionDimension(
226-
(f"projection width is 0 due to equal {left=}" f"and {right=} values")
226+
(f"projection width is 0 due to equal {left=}and {right=} values")
227227
)
228228
bottom, top = projection_data.bottom, projection_data.top
229229
if bottom == top:
230230
raise ZeroProjectionDimension(
231-
(f"projection height is 0 due to equal {bottom=}" f"and {top=}")
231+
(f"projection height is 0 due to equal {bottom=}and {top=}")
232232
)
233233
near, far = projection_data.near, projection_data.far
234234
if near == far:
235235
raise ZeroProjectionDimension(
236-
f"projection depth is 0 due to equal {near=}" f"and {far=} values"
236+
f"projection depth is 0 due to equal {near=}and {far=} values"
237237
)
238238

239239
# build a new camera with defaults and then apply the provided camera objects.

arcade/camera/data_types.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def __init__(
8484
forward: Point3 = (0.0, 0.0, -1.0),
8585
zoom: float = 1.0,
8686
):
87-
8887
self.position: tuple[float, float, float] = position
8988
"""A 3D vector which describes where the camera is located."""
9089

@@ -260,9 +259,7 @@ def lrbt(self, new_lrbt: tuple[float, float, float, float]):
260259
self.rect = LRBT(*new_lrbt)
261260

262261
def __str__(self):
263-
return (
264-
f"OrthographicProjection<" f"LRBT={self.rect.lrbt}, " f"{self.near=}, " f"{self.far=}"
265-
)
262+
return f"OrthographicProjection<LRBT={self.rect.lrbt}, {self.near=}, {self.far=}>"
266263

267264
def __repr__(self):
268265
return self.__str__()

arcade/camera/static.py

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

2828

2929
class _StaticCamera:
30-
3130
def __init__(
3231
self,
3332
view_matrix: Mat4,

arcade/draw/rect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ def draw_lrbt_rectangle_outline(
187187
ValueError: Raised if left > right or top < bottom.
188188
"""
189189
if left > right:
190-
raise ValueError("Left coordinate must be less than or equal to " "the right coordinate")
190+
raise ValueError("Left coordinate must be less than or equal to the right coordinate")
191191

192192
if bottom > top:
193-
raise ValueError("Bottom coordinate must be less than or equal to " "the top coordinate")
193+
raise ValueError("Bottom coordinate must be less than or equal to the top coordinate")
194194

195195
draw_rect_outline(LRBT(left, right, bottom, top), color, border_width)
196196

arcade/experimental/atlas_render_into.py

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

1111

1212
class AtlasRenderDemo(arcade.Window):
13-
1413
def __init__(self):
1514
super().__init__(1280, 720, "Atlas Render Demo")
1615
self.atlas = arcade.DefaultTextureAtlas((600, 600))

arcade/experimental/atlas_replace_image.py

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

6969

7070
class AtlasReplaceImage(arcade.Window):
71-
7271
def __init__(self):
7372
super().__init__(800, 600, "Replacing images in atlas")
7473
self.sprite_1 = arcade.Sprite(TEXTURE_PATHS[-1], center_x=200, center_y=300)

arcade/experimental/geo_culling_check.py

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

1717

1818
class GeoCullingTest(arcade.Window):
19-
2019
def __init__(self):
2120
super().__init__(1280, 720, "Cull test", resizable=True)
2221
self.proj = 0, self.width, 0, self.height

0 commit comments

Comments
 (0)
0