Skip to content

Commit cc24709

Browse files
fix the format exclusions and format
1 parent 87a3480 commit cc24709

File tree

101 files changed

+1200
-1162
lines changed

Some content is hidden

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

101 files changed

+1200
-1162
lines changed

doc/conf.py

Lines changed: 107 additions & 108 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ build-backend = "setuptools.build_meta"
8484
[tool.ruff]
8585
line-length = 100
8686
output-format = "full"
87-
exclude = [
87+
lint.exclude = [
8888
"venv",
8989
".venv*",
9090
"tests",
@@ -114,7 +114,7 @@ lint.select = [
114114

115115
[tool.ruff.format]
116116
docstring-code-format = false
117-
exclude = ["arcade/examples/*", "benchmarks/*"]
117+
exclude = ["arcade/examples/*", "benchmarks/*", "doc/*"]
118118

119119
# This ignores __init__.py files and examples for import sorting
120120
[tool.ruff.lint.per-file-ignores]
@@ -126,9 +126,7 @@ exclude = ["arcade/examples/*", "benchmarks/*"]
126126

127127
[tool.mypy]
128128
disable_error_code = "annotation-unchecked"
129-
exclude = [
130-
"arcade/gl/backends"
131-
]
129+
exclude = ["arcade/gl/backends"]
132130

133131
[tool.pytest.ini_options]
134132
norecursedirs = [
@@ -143,7 +141,7 @@ norecursedirs = [
143141
]
144142
markers = [
145143
"backendgl: Run OpenGL (or OpenGL ES) backend specific tests",
146-
"backendwebgl: Run WebGL backend specific tests"
144+
"backendwebgl: Run WebGL backend specific tests",
147145
]
148146

149147
[tool.pyright]

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
# Headless mode
44
if os.environ.get("ARCADE_HEADLESS_TEST"):
55
import pyglet
6+
67
pyglet.options.headless = True

tests/conftest.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from arcade.clock import GLOBAL_CLOCK, GLOBAL_FIXED_CLOCK
1818
from arcade import Rect, LBWH
1919
from arcade import gl
20+
2021
# from arcade.texture import default_texture_cache
2122
# NOTE: Load liberation fonts in unit tests
2223
arcade.resources.load_liberation_fonts()
@@ -30,28 +31,30 @@
3031
WINDOW = None
3132
OFFSCREEN = None
3233

33-
POSSIBLE_BACKENDS = [
34-
"backendopengl",
35-
"backendwebgl"
36-
]
34+
POSSIBLE_BACKENDS = ["backendopengl", "backendwebgl"]
3735

3836
arcade.resources.load_kenney_fonts()
3937

4038

4139
def pytest_addoption(parser):
4240
parser.addoption("--gl-backend", default="opengl")
4341

42+
4443
def pytest_configure(config):
4544
global GL_BACKEND
4645
GL_BACKEND = config.option.gl_backend
4746

47+
4848
def pytest_collection_modifyitems(config, items):
4949
desired_backend = "backend" + GL_BACKEND
5050
for item in items:
5151
for backend in POSSIBLE_BACKENDS:
5252
if backend in item.keywords:
5353
if backend != desired_backend:
54-
item.add_marker(pytest.mark.skip(f"Skipping GL backend specific test for {backend}"))
54+
item.add_marker(
55+
pytest.mark.skip(f"Skipping GL backend specific test for {backend}")
56+
)
57+
5558

5659
def make_window_caption(request=None, prefix="Testing", sep=" - ") -> str:
5760
"""Centralizes test name customization.
@@ -72,7 +75,12 @@ def create_window(width=1280, height=720, caption="Testing", **kwargs):
7275
global WINDOW
7376
if not WINDOW:
7477
WINDOW = REAL_WINDOW_CLASS(
75-
width=width, height=height, title=caption, vsync=False, antialiasing=False, gl_api = GL_BACKEND
78+
width=width,
79+
height=height,
80+
title=caption,
81+
vsync=False,
82+
antialiasing=False,
83+
gl_api=GL_BACKEND,
7684
)
7785
WINDOW.set_vsync(False)
7886
# This value is being monkey-patched into the Window class so that tests can identify if we are using

tests/doc/check_examples_2.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55

66
def get_references_in_index():
7-
txt = Path('../../doc/example_code/how_to_examples/index.rst').read_text()
7+
txt = Path("../../doc/example_code/how_to_examples/index.rst").read_text()
88
references_in_index = re.findall(":ref:`(.*)`", txt)
99
return references_in_index
1010

11+
1112
def get_references_in_rsts():
1213
mypath = Path("../../doc/example_code/how_to_examples/")
1314

@@ -24,6 +25,7 @@ def get_references_in_rsts():
2425

2526
return references
2627

28+
2729
def main():
2830
references_in_index = get_references_in_index()
2931
files_to_reference = get_references_in_rsts()
@@ -32,7 +34,9 @@ def main():
3234
if not reference in references_in_index:
3335
print(f"index.rst is missing any mention of '{reference}'")
3436

35-
print("Done with checking to make sure references in doc/examples/*.rst are in doc/examples/index.rst")
37+
print(
38+
"Done with checking to make sure references in doc/examples/*.rst are in doc/examples/index.rst"
39+
)
3640

3741

3842
main()

tests/doc/check_samples.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,18 @@ def main():
2727

2828
# See if there are rst files for all the py files
2929
for py_file in python_example_filename_list:
30-
base_name = py_file[:len(py_file) - 3]
30+
base_name = py_file[: len(py_file) - 3]
3131
rst_name = base_name + ".rst"
3232
if rst_name not in python_rst_filename_list:
3333
print("Missing " + rst_name)
3434

3535
# See if there are py files for all the rst files
3636
print()
3737
for rst_file in python_rst_filename_list:
38-
base_name = rst_file[:len(rst_file) - 4]
38+
base_name = rst_file[: len(rst_file) - 4]
3939
py_name = base_name + ".py"
4040
if py_name not in python_example_filename_list:
4141
print("Missing " + py_name)
4242

43+
4344
main()

tests/integration/examples/test_examples.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Import and run all examples one frame
33
"""
4+
45
import contextlib
56
import io
67
import inspect
@@ -15,24 +16,20 @@
1516

1617
# File path, module path
1718
EXAMPLE_LOCATIONS = [
18-
(
19-
Path(arcade.__file__).parent / "examples",
20-
"arcade.examples"
21-
),
19+
(Path(arcade.__file__).parent / "examples", "arcade.examples"),
2220
(
2321
Path(arcade.__file__).parent / "examples" / "platform_tutorial",
24-
"arcade.examples.platform_tutorial"
25-
),
26-
(
27-
Path(arcade.__file__).parent / "examples" / "gl",
28-
"arcade.examples.gl"
22+
"arcade.examples.platform_tutorial",
2923
),
24+
(Path(arcade.__file__).parent / "examples" / "gl", "arcade.examples.gl"),
3025
]
3126
# These examples are allowed to print to stdout
32-
ALLOW_STDOUT = set([
33-
"arcade.examples.dual_stick_shooter",
34-
"transform_multi",
35-
])
27+
ALLOW_STDOUT = set(
28+
[
29+
"arcade.examples.dual_stick_shooter",
30+
"transform_multi",
31+
]
32+
)
3633
IGNORE_PATTERNS = [
3734
"net_process_animal_facts", # Starts network process
3835
"transform_emit", # Broken
@@ -42,16 +39,19 @@
4239
"bindless", # Bindless textures cannot be run in unit test
4340
]
4441

42+
4543
def list_examples():
4644
for path, module_path in EXAMPLE_LOCATIONS:
4745
for example in path.glob("*.py"):
4846
if example.stem.startswith("_"):
4947
continue
48+
5049
def is_ignored(example):
5150
for pattern in IGNORE_PATTERNS:
5251
if pattern in example.stem:
5352
return True
5453
return False
54+
5555
if is_ignored(example):
5656
continue
5757
yield f"{module_path}.{example.stem}", example, True
@@ -85,13 +85,12 @@ def test_examples(window_proxy, module_path, file_path, allow_stdout):
8585
# Manually load the module as __main__ so it runs on import
8686
loader = SourceFileLoader("__main__", str(file_path))
8787
loader.exec_module(loader.load_module())
88-
88+
8989
# Reset the global clock's tick speed
9090
# is this a good argument against a global scope clock?
9191
# yes.
9292
arcade.clock.GLOBAL_CLOCK.set_tick_speed(1.0)
9393

94-
9594
if not allow_stdout:
9695
output = stdout.getvalue()
9796
assert not output, f"Example {module_path} printed to stdout: {output}"

tests/integration/tutorials/test_tutorials.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Find and run all tutorials in the doc/tutorials directory
33
"""
4+
45
import io
56
import os
67
import contextlib
@@ -11,7 +12,7 @@
1112
import pytest
1213
import arcade
1314

14-
TUTORIAL_DIR = Path(arcade.__file__).parent.parent / "doc" /"tutorials"
15+
TUTORIAL_DIR = Path(arcade.__file__).parent.parent / "doc" / "tutorials"
1516
ALLOW_STDOUT = {}
1617

1718

tests/manual_smoke/sprite_collision_inspector.py

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
TEX_GREY_PANEL_RAW = load_texture(":resources:gui_basic_assets/window/grey_panel.png")
1616

17-
T = TypeVar('T')
17+
T = TypeVar("T")
18+
1819

1920
def _tname(t: Any) -> str:
2021
if not isinstance(t, builtins.type):
21-
return t.__class__.__name__
22+
return t.__class__.__name__
2223
else:
2324
return t.__name__
2425

@@ -61,7 +62,7 @@ def __init__(
6162
size_hint=size_hint,
6263
size_hint_min=size_hint_min,
6364
size_hint_max=size_hint_max,
64-
**kwargs
65+
**kwargs,
6566
)
6667
self._error_color = error_color
6768
self._parsed_type: Type[T] = parsed_type
@@ -102,9 +103,7 @@ def color(self, new_color: RGBOrA255) -> None:
102103
return
103104

104105
self.caret.color = validated
105-
self.doc.set_style(
106-
0, len(self.text), dict(color=validated)
107-
)
106+
self.doc.set_style(0, len(self.text), dict(color=validated))
108107
self.trigger_full_render()
109108

110109
@property
@@ -123,66 +122,47 @@ def text(self, new_text: str) -> None:
123122
raise e
124123

125124

126-
127125
def draw_crosshair(
128126
where: tuple[float, float],
129127
color=arcade.color.BLACK,
130128
radius: float = 20.0,
131129
border_width: float = 1.0,
132130
) -> None:
133131
x, y = where
134-
arcade.draw.circle.draw_circle_outline(
135-
x, y,
136-
radius,
137-
color=color,
138-
border_width=border_width
139-
)
140-
arcade.draw.draw_line(
141-
x, y - radius, x, y + radius,
142-
color=color, line_width=border_width)
132+
arcade.draw.circle.draw_circle_outline(x, y, radius, color=color, border_width=border_width)
133+
arcade.draw.draw_line(x, y - radius, x, y + radius, color=color, line_width=border_width)
143134

144-
arcade.draw.draw_line(
145-
x - radius, y, x + radius, y,
146-
color=color, line_width=border_width)
135+
arcade.draw.draw_line(x - radius, y, x + radius, y, color=color, line_width=border_width)
147136

148137

149138
class MyGame(arcade.Window):
150-
151139
def add_field_row(self, label_text: str, widget: UIWidget) -> None:
152140
children = (
153141
arcade.gui.widgets.text.UITextArea(
154-
text=label_text,
155-
width=100,
156-
height=20,
157-
color=arcade.color.BLACK,
158-
font_size=12
142+
text=label_text, width=100, height=20, color=arcade.color.BLACK, font_size=12
159143
),
160-
widget
144+
widget,
161145
)
162146
row = UIBoxLayout(vertical=False, space_between=10, children=children)
163147
self.rows.add(row)
164148

165-
def __init__(
166-
self,
167-
width: int = 1280,
168-
height: int = 720,
169-
grid_tile_px: int = 100
170-
):
171-
149+
def __init__(self, width: int = 1280, height: int = 720, grid_tile_px: int = 100):
172150
super().__init__(width, height, "Collision Inspector")
173151
# why does this need a context again?
174152
self.nine_patch = NinePatchTexture(
175-
left=5, right=5, top=5, bottom=5, texture=TEX_GREY_PANEL_RAW)
153+
left=5, right=5, top=5, bottom=5, texture=TEX_GREY_PANEL_RAW
154+
)
176155
self.ui = UIManager()
177156
self.spritelist: SpriteList[Sprite] = arcade.SpriteList()
178157

179-
180158
textbox_template = dict(width=40, height=20, text_color=arcade.color.BLACK)
181-
self.cursor_x_field = UIInputText(
182-
text="1.0", **textbox_template).with_background(texture=self.nine_patch)
159+
self.cursor_x_field = UIInputText(text="1.0", **textbox_template).with_background(
160+
texture=self.nine_patch
161+
)
183162

184-
self.cursor_y_field = UIInputText(
185-
text="1.0", **textbox_template).with_background(texture=self.nine_patch)
163+
self.cursor_y_field = UIInputText(text="1.0", **textbox_template).with_background(
164+
texture=self.nine_patch
165+
)
186166

187167
self.rows = UIBoxLayout(space_between=20).with_background(color=arcade.color.GRAY)
188168

@@ -206,11 +186,7 @@ def __init__(
206186
self.on_widget = False
207187

208188
def build_sprite_grid(
209-
self,
210-
columns: int,
211-
rows: int,
212-
grid_tile_px: int,
213-
offset: tuple[float, float] = (0, 0)
189+
self, columns: int, rows: int, grid_tile_px: int, offset: tuple[float, float] = (0, 0)
214190
):
215191
offset_x, offset_y = offset
216192
self.spritelist.clear()
@@ -254,4 +230,5 @@ def on_draw(self):
254230

255231
self.ui.draw()
256232

257-
MyGame().run()
233+
234+
MyGame().run()

0 commit comments

Comments
 (0)