From 837ab7557e3c94f5c00ce62d2e494cbebd7e885f Mon Sep 17 00:00:00 2001 From: Paul V Craven Date: Wed, 7 Oct 2026 13:29:47 -0500 Subject: [PATCH 1/3] Fix the existing ruff lint, format, and import order errors CI runs these checks but ignores their results, so errors built up. Fix them with ruff 0.15.20, the version uv.lock pins: - Reflow the 28 docstring lines over 100 characters in arcade/input/manager.py and arcade/application.py. - Declare the re-export in arcade/cli/__init__.py in __all__. - Sort imports in arcade (15 files) and tests (92 files) with ruff. - Format tests/integration/test_ubo_stress.py and tests/unit/rendering/image_compare.py. Co-Authored-By: Claude Opus 5.5 --- arcade/application.py | 11 ++- arcade/cli/__init__.py | 2 + arcade/cli/commands/info.py | 2 +- arcade/context.py | 2 +- arcade/experimental/input_manager_example.py | 4 +- arcade/future/video/video_player.py | 4 +- arcade/gl/backends/opengl/context.py | 2 +- arcade/gl/backends/webgl/context.py | 2 +- arcade/gl/context.py | 3 +- arcade/gui/widgets/text.py | 4 +- arcade/input/manager.py | 86 ++++++++++++------- arcade/paths.py | 2 +- arcade/sound.py | 2 +- arcade/sprite_list/sprite_list.py | 4 +- arcade/text.py | 2 +- arcade/window_commands.py | 1 - tests/conftest.py | 5 +- tests/doc/check_examples_2.py | 2 +- tests/integration/examples/test_examples.py | 4 +- .../integration/examples/test_line_lengths.py | 1 + tests/integration/test_ubo_stress.py | 5 +- tests/integration/tutorials/test_tutorials.py | 5 +- .../sprite_collision_inspector.py | 8 +- tests/unit/atlas/conftest.py | 1 + tests/unit/atlas/test_basics.py | 3 +- tests/unit/atlas/test_gc.py | 1 + tests/unit/atlas/test_rebuild_resize.py | 1 + tests/unit/atlas/test_region.py | 4 +- .../test_update_texture_image_from_atlas.py | 1 + tests/unit/cache/test_hit_box_cache.py | 1 + tests/unit/cache/test_image_cache.py | 3 +- tests/unit/cache/test_texture_cache.py | 1 + tests/unit/camera/test_camera2d.py | 7 +- .../camera/test_camera_controller_methods.py | 2 +- tests/unit/camera/test_camera_shake.py | 2 +- .../camera/test_orthographic_projector.py | 3 +- .../unit/camera/test_perspective_projector.py | 4 +- tests/unit/camera/test_viewport_projector.py | 7 +- tests/unit/color/test_color_type.py | 2 +- tests/unit/gl/backends/gl/test_gl_program.py | 4 +- tests/unit/gl/test_gl_buffer.py | 1 + tests/unit/gl/test_gl_buffer_description.py | 1 + tests/unit/gl/test_gl_framebuffer.py | 1 + tests/unit/gl/test_gl_query.py | 1 + tests/unit/gl/test_gl_texture.py | 1 + tests/unit/gl/test_gl_types.py | 1 + tests/unit/gl/test_gl_vertex_array.py | 4 +- tests/unit/gui/conftest.py | 1 + tests/unit/gui/test_animate.py | 2 +- tests/unit/gui/test_event_order.py | 2 +- tests/unit/gui/test_exp_restricted_input.py | 2 +- tests/unit/gui/test_interactions.py | 3 +- .../gui/test_interactive_sprite_widget.py | 2 +- tests/unit/gui/test_layouting_anchorlayout.py | 2 +- tests/unit/gui/test_layouting_examples.py | 3 +- tests/unit/gui/test_ninepatch_draw.py | 2 +- tests/unit/gui/test_property_alias.py | 1 + tests/unit/gui/test_property_dict.py | 3 +- tests/unit/gui/test_property_list.py | 3 +- tests/unit/gui/test_surface.py | 2 +- tests/unit/gui/test_transitions.py | 10 +-- tests/unit/gui/test_uilabel.py | 2 +- tests/unit/gui/test_uimanager.py | 2 +- tests/unit/gui/test_uimanager_callbacks.py | 7 +- tests/unit/gui/test_uimanager_layouting.py | 2 +- .../gui/test_uimanager_layouting_cascade.py | 2 +- tests/unit/gui/test_uistyle.py | 2 +- tests/unit/gui/test_widget_events.py | 2 +- tests/unit/hitbox/test_black_image.py | 1 + tests/unit/hitbox/test_hitbox.py | 1 + tests/unit/hitbox/test_hitbox_algo_legacy.py | 3 +- tests/unit/rect/test_rect_creation_helpers.py | 2 +- tests/unit/rect/test_rect_instances.py | 4 +- tests/unit/rendering/generate_baseline.py | 1 - tests/unit/rendering/image_compare.py | 3 +- tests/unit/resources/test_handles.py | 2 + tests/unit/resources/test_list_resources.py | 1 + tests/unit/scene/test_scene.py | 1 + tests/unit/scene/test_scene_dunder_methods.py | 3 +- .../scene/test_scene_remove_sprite_lists.py | 3 +- .../unit/shape_list/test_buffered_drawing.py | 11 +-- tests/unit/sprite/test_copy_dunders.py | 1 + tests/unit/sprite/test_sprite_collision.py | 2 +- .../sprite/test_sprite_texture_animation.py | 1 + tests/unit/spritelist/test_spatial_hash.py | 1 + tests/unit/spritelist/test_spritelist.py | 4 +- .../spritelist/test_spritelist_buffers.py | 1 + tests/unit/spritelist/test_spritelist_draw.py | 1 + tests/unit/spritelist/test_spritelist_lazy.py | 1 + tests/unit/test_arcade.py | 6 +- tests/unit/test_example_docstrings.py | 4 +- tests/unit/test_hexagon.py | 3 +- tests/unit/test_isometric.py | 2 +- tests/unit/test_math.py | 1 + tests/unit/test_shadertoy.py | 1 + tests/unit/test_utils.py | 2 +- tests/unit/test_version.py | 3 +- tests/unit/text/test_text.py | 1 + tests/unit/text/test_text_fonts.py | 2 +- .../text/test_text_instance_properties.py | 1 + tests/unit/text/test_text_pool.py | 1 + tests/unit/texture/test_image_data.py | 3 +- tests/unit/texture/test_sprite_sheet.py | 3 +- tests/unit/texture/test_texture.py | 3 +- tests/unit/texture/test_texture_tools.py | 6 +- .../texture/test_texture_transform_render.py | 9 +- .../texture/test_texture_transform_values.py | 4 +- tests/unit/tilemap/test_tilemap_objects.py | 4 +- tests/unit/window/test_window.py | 3 +- 109 files changed, 230 insertions(+), 157 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 724a2736da..55697ef833 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -12,7 +12,6 @@ from typing import TYPE_CHECKING import pyglet - from arcade.utils import is_pyodide if is_pyodide: @@ -579,13 +578,13 @@ def _dispatch_frame(self, delta_time: float) -> None: The modulus on the accumulated draw time means that when the update rate is greater than the draw rate no time is lost. - This method is entirely skipped when running in pyodide, this is because the event loop - is driven by requestAnimationFrame in the browser, which adds some unique limitations and + This method is entirely skipped when running in pyodide, this is because the event loop is + driven by requestAnimationFrame in the browser, which adds some unique limitations and considerations around Arcade's event loop handling. In pyglet, the draw() function of the window is called directly during the requestAnimationFrame loop, so Arcade handles special - control of the update/draw timing directly in that function. Arcade's version of this function - is never called on desktop, because this function is called instead, and this calls directly - to the superclass's implementation. + control of the update/draw timing directly in that function. Arcade's version of this + function is never called on desktop, because this function is called instead, and this calls + directly to the superclass's implementation. Args: delta_time: The amount of time since the last update. diff --git a/arcade/cli/__init__.py b/arcade/cli/__init__.py index 217c3738e4..7cef7a420e 100644 --- a/arcade/cli/__init__.py +++ b/arcade/cli/__init__.py @@ -1 +1,3 @@ from .cli import run_arcade_cli + +__all__ = ["run_arcade_cli"] diff --git a/arcade/cli/commands/info.py b/arcade/cli/commands/info.py index ba1328d61d..84e0024144 100644 --- a/arcade/cli/commands/info.py +++ b/arcade/cli/commands/info.py @@ -2,9 +2,9 @@ import sys import PIL -import pyglet import arcade +import pyglet from .base import BaseCommand diff --git a/arcade/context.py b/arcade/context.py index c088fb5a68..645bb9505f 100644 --- a/arcade/context.py +++ b/arcade/context.py @@ -9,11 +9,11 @@ from pathlib import Path from typing import Any -import pyglet from PIL import Image from pyglet.math import Mat4 import arcade +import pyglet from arcade.camera import Projector from arcade.camera.default import DefaultProjector from arcade.gl import BufferDescription, Context diff --git a/arcade/experimental/input_manager_example.py b/arcade/experimental/input_manager_example.py index 92b70dde2a..534160064b 100644 --- a/arcade/experimental/input_manager_example.py +++ b/arcade/experimental/input_manager_example.py @@ -9,11 +9,11 @@ import random from collections.abc import Sequence -import pyglet from pyglet.input import Controller import arcade -from arcade.input import ActionState, ControllerSticks, ControllerButtons, InputManager, Keys +import pyglet +from arcade.input import ActionState, ControllerButtons, ControllerSticks, InputManager, Keys WINDOW_WIDTH = 1280 WINDOW_HEIGHT = 720 diff --git a/arcade/future/video/video_player.py b/arcade/future/video/video_player.py index 35bdc35838..3fc55b956a 100644 --- a/arcade/future/video/video_player.py +++ b/arcade/future/video/video_player.py @@ -7,11 +7,11 @@ from pathlib import Path +import arcade + # import sys import pyglet -import arcade - class VideoPlayer: """ diff --git a/arcade/gl/backends/opengl/context.py b/arcade/gl/backends/opengl/context.py index 81cbe78e06..3349cae2f1 100644 --- a/arcade/gl/backends/opengl/context.py +++ b/arcade/gl/backends/opengl/context.py @@ -1,9 +1,9 @@ from ctypes import c_char_p, c_float, c_int, cast from typing import Dict, Iterable, List, Sequence, Tuple -import pyglet from pyglet.graphics.api import gl +import pyglet from arcade.context import ArcadeContext from arcade.gl import enums from arcade.gl.context import Context, Info diff --git a/arcade/gl/backends/webgl/context.py b/arcade/gl/backends/webgl/context.py index 7902fcd622..f5d8a8112b 100644 --- a/arcade/gl/backends/webgl/context.py +++ b/arcade/gl/backends/webgl/context.py @@ -1,8 +1,8 @@ from typing import TYPE_CHECKING, Dict, Iterable, List, Sequence, Tuple -import pyglet import pyglet.graphics.api +import pyglet from arcade.context import ArcadeContext from arcade.gl import enums from arcade.gl.context import Context, Info diff --git a/arcade/gl/context.py b/arcade/gl/context.py index 2466715cbf..6d07d20a59 100644 --- a/arcade/gl/context.py +++ b/arcade/gl/context.py @@ -18,9 +18,10 @@ overload, ) -import pyglet from pyglet.window import Window +import pyglet + from ..types import BufferProtocol from . import enums from .buffer import Buffer diff --git a/arcade/gui/widgets/text.py b/arcade/gui/widgets/text.py index ae64b09142..2fe9bed6e8 100644 --- a/arcade/gui/widgets/text.py +++ b/arcade/gui/widgets/text.py @@ -3,14 +3,14 @@ from dataclasses import dataclass from typing import Literal -import pyglet from pyglet.event import EVENT_HANDLED, EVENT_UNHANDLED -from pyglet.text.caret import Caret from pyglet.text import LinearGradient +from pyglet.text.caret import Caret from pyglet.text.document import AbstractDocument from typing_extensions import override import arcade +import pyglet from arcade import uicolor from arcade.gui.events import ( UIEvent, diff --git a/arcade/input/manager.py b/arcade/input/manager.py index f2b7658d08..368820ab11 100644 --- a/arcade/input/manager.py +++ b/arcade/input/manager.py @@ -5,11 +5,11 @@ from enum import Enum from typing import Any, TypeVar -import pyglet from pyglet.input.base import Controller from typing_extensions import TypedDict import arcade +import pyglet from arcade.input import inputs from arcade.input.input_mapping import ( Action, @@ -66,11 +66,13 @@ class InputDevice(Enum): class InputManager: """ - The InputManager is responsible for managing input for a given device, this can be the keyboard/mouse or a controller. + The InputManager is responsible for managing input for a given device, this can be the + keyboard/mouse or a controller. - In general, you can share one InputManager for one controller and the keyboard/mouse, there are even utilities to handle - automatically switching between them as the active device. However if you intend to have multiple controllers connected - to your game, each controller should have it's own InputManager. + In general, you can share one InputManager for one controller and the keyboard/mouse, there are + even utilities to handle automatically switching between them as the active device. However if + you intend to have multiple controllers connected to your game, each controller should have it's + own InputManager. For runnable examples of how to use this, please see Arcdade's :ref:`built-in InputManager examples `. @@ -79,13 +81,15 @@ class InputManager: controller: Either a Pyglet Controller object or None if you only want to use the keyboard/mouse. allow_keyboard: - Whether to allow keyboard input, defaults to True, can be changed safely after initialization. + Whether to allow keyboard input, defaults to True, can be changed safely after + initialization. action_handlers: - Either one or a collection of functions that will be called for every action that is triggered. - :py:meth:`InputManager.subscribe_to_action` may be preferred to subscribe to individual actions instead. + Either one or a collection of functions that will be called for every action that is + triggered. :py:meth:`InputManager.subscribe_to_action` may be preferred to subscribe to + individual actions instead. controller_deadzone: - The deadzone for controller input, defaults to 0.1. If changes to axis values are within this - range from the underlying hardware, they will be ignored. + The deadzone for controller input, defaults to 0.1. If changes to axis values are within + this range from the underlying hardware, they will be ignored. """ def __init__( @@ -155,15 +159,17 @@ def __init__( def serialize(self) -> RawInputManager: """ - Serializes the current state of the InputManager into a RawInputManager dictionary which can easily be saved to JSON. + Serializes the current state of the InputManager into a RawInputManager dictionary which can + easily be saved to JSON. - This does not include current values of inputs, but rather the structure of the InputManager. Including: + This does not include current values of inputs, but rather the structure of the + InputManager. Including: - Actions: All registered actions - Axes: All registered axis inputs - Current Mappings: All current mappings of underlying inputs to actions/axis - The output dictionary of this function can be passed to :meth:`arcade.InputManager.parse` to create a new InputManager - from a serialized one. + The output dictionary of this function can be passed to :meth:`arcade.InputManager.parse` to + create a new InputManager from a serialized one. Returns: A RawInputManager dictionary representing the current state of the InputManager. @@ -183,8 +189,8 @@ def serialize(self) -> RawInputManager: @classmethod def parse(cls, raw: RawInputManager) -> InputManager: """ - Create a new InputManager from a serialized dictionary. Can be used in combination with the :meth:`arcade.InputManager.serialize` to - save/load input configurations. + Create a new InputManager from a serialized dictionary. Can be used in combination with the + :meth:`arcade.InputManager.serialize` to save/load input configurations. Returns: A new InputManager with the state defined in the provided RawInputManager dictionary. @@ -218,11 +224,13 @@ def parse(cls, raw: RawInputManager) -> InputManager: def copy_existing(self, existing: InputManager): """ - Copies the state of another InputManager into this one. Note that this does not create a new InputManager, but modifies the one on which it is called. + Copies the state of another InputManager into this one. Note that this does not create a new + InputManager, but modifies the one on which it is called. This does not copy current input values, just the structure/mappings of the InputManager. - If you want to create a new InputManager from an existing one, use :meth:`arcade.InputManager.from_existing` + If you want to create a new InputManager from an existing one, use + :meth:`arcade.InputManager.from_existing` Args: existing: The InputManager to copy from. @@ -244,13 +252,16 @@ def from_existing( controller: pyglet.input.Controller | None = None, ) -> InputManager: """ - Create a new InputManager from an existing one. This does not copy current input values, just the structure/mappings of the InputManager. + Create a new InputManager from an existing one. This does not copy current input values, + just the structure/mappings of the InputManager. - If you want to create a new InputManager from a serialized dictionary, use :meth:`arcade.InputManager.parse` + If you want to create a new InputManager from a serialized dictionary, use + :meth:`arcade.InputManager.parse` Args: existing: The InputManager to copy from. - controller: The controller to use for this InputManager. If None, no Controller will be bound. + controller: The controller to use for this InputManager. If None, no Controller will be + bound. Returns: A new InputManager with the state defined in the provided existing InputManager. @@ -266,7 +277,8 @@ def from_existing( def bind_controller(self, controller: Controller): """ - Bind a controller to this InputManager. If a controller is already bound, it will be unbound first. + Bind a controller to this InputManager. If a controller is already bound, it will be unbound + first. Upon binding a controller it will be set as the active device. @@ -318,7 +330,8 @@ def allow_keyboard(self): """ Whether the keyboard is allowed for this InputManager. This also effects mouse input. - If this is false then all keyboard and mouse input will be ignored regardless of if there are mappings for them. + If this is false then all keyboard and mouse input will be ignored regardless of if there + are mappings for them. """ return self._allow_keyboard @@ -343,7 +356,8 @@ def new_action( name: str, ): """ - Create a new action with the given name. If an action with the same name already exists, this will do nothing. + Create a new action with the given name. If an action with the same name already exists, + this will do nothing. Args: name: The name of the action to create. @@ -356,7 +370,8 @@ def new_action( def remove_action(self, name: str): """ - Remove the specified action. If the action does not exist, this will do nothing. All registered inputs for the action will be removed. + Remove the specified action. If the action does not exist, this will do nothing. All + registered inputs for the action will be removed. Args: name: The name of the action to remove. """ @@ -427,8 +442,9 @@ def register_action_handler(self, handler: OneOrIterableOf[Callable[[str, Action """ Register a callback function for all actions from this InputManager. - The callback function should accept a String with the name of the Action, and an ActionState. - This callback will receive all action events, regardless of if :meth:`arcade.InputManager.subscribe_to_action` has been used as well. + The callback function should accept a String with the name of the Action, and an + ActionState. This callback will receive all action events, regardless of if + :meth:`arcade.InputManager.subscribe_to_action` has been used as well. Args: handler: The callback function to register. @@ -470,7 +486,8 @@ def add_axis_input(self, axis: str, input: InputEnum, scale: float = 1.0): Args: axis: The axis to register the input for input: The input to register - scale: The value to multiply the input by, for non analog inputs the scale value is used literally. + scale: The value to multiply the input by, for non analog inputs the scale value is used + literally. """ mapping = AxisMapping(input, scale) self.axes[axis].add_mapping(mapping) @@ -495,8 +512,8 @@ def add_axis_input_combined( self, axis: str, positive: InputEnum, negative: InputEnum, scale: float = 1.0 ): """ - This is a helper function that wraps :meth:`arcade.InputManager.add_axis_input` to add two inputs - with a positive and negative scale. + This is a helper function that wraps :meth:`arcade.InputManager.add_axis_input` to add two + inputs with a positive and negative scale. For example, you can do: add_axis_input_combined("MoveHorizontal", arcade.Keys.RIGHT, arcade.Keys.LEFT, 1.0) @@ -508,7 +525,8 @@ def add_axis_input_combined( axis: The axis name to register the input for positive: The input that will correspond to the positive side of the axis negative: The input that will correspond to the negative side of the axis - scale: The value to multiply the input by, for non analog inputs the scale value is used literally. + scale: The value to multiply the input by, for non analog inputs the scale value is used + literally. """ self.add_axis_input(axis, positive, scale) self.add_axis_input(axis, negative, -scale) @@ -527,7 +545,8 @@ def clear_axis_input(self, axis: str): def remove_axis(self, axis: str): """ - Completely remove an axis from the manager. This will also clear the registered inputs for that axis. + Completely remove an axis from the manager. This will also clear the registered inputs for + that axis. Args: axis: The axis to remove @@ -691,7 +710,8 @@ def on_righttrigger_motion(self, controller: Controller, value: float): def update(self): """ - Updates axis inputs, all axis values will remain unchanged unless this function is called, usually during on_update. + Updates axis inputs, all axis values will remain unchanged unless this function is called, + usually during on_update. """ for name in self.axes.keys(): self.axes_state[name] = 0 diff --git a/arcade/paths.py b/arcade/paths.py index d13624afc7..e6ca949aeb 100644 --- a/arcade/paths.py +++ b/arcade/paths.py @@ -8,8 +8,8 @@ BasicSprite, Sprite, SpriteSequence, - has_collision_with_list, get_sprites_at_point, + has_collision_with_list, ) from arcade.math import get_distance, lerp_2d from arcade.types import Point2 diff --git a/arcade/sound.py b/arcade/sound.py index 09c70ce321..95d8f6bfdd 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -5,9 +5,9 @@ import os from pathlib import Path -import pyglet from pyglet.media import Source +import pyglet from arcade.resources import resolve from arcade.utils import is_pyodide diff --git a/arcade/sprite_list/sprite_list.py b/arcade/sprite_list/sprite_list.py index 835e3adebe..e75527b197 100644 --- a/arcade/sprite_list/sprite_list.py +++ b/arcade/sprite_list/sprite_list.py @@ -11,10 +11,10 @@ import struct from abc import abstractmethod from array import array -from itertools import filterfalse -from math import hypot from collections import deque from collections.abc import Callable, Collection, Iterable, Iterator, Sized +from itertools import filterfalse +from math import hypot from typing import ( TYPE_CHECKING, Any, diff --git a/arcade/text.py b/arcade/text.py index 9dc2ed0394..deececee55 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -10,7 +10,6 @@ import PIL.Image import PIL.ImageChops -import pyglet from pyglet.enums import Style, Weight # Pyright can't figure out the dynamic backend imports in pyglet.graphics @@ -19,6 +18,7 @@ from pyglet.text import LinearGradient import arcade +import pyglet from arcade.clock import GLOBAL_CLOCK from arcade.exceptions import NoArcadeWindowError, PerformanceWarning, warning from arcade.resources import resolve diff --git a/arcade/window_commands.py b/arcade/window_commands.py index 13dc5c5533..c6516361f6 100644 --- a/arcade/window_commands.py +++ b/arcade/window_commands.py @@ -13,7 +13,6 @@ from typing import TYPE_CHECKING import pyglet - from arcade.exceptions import NoArcadeWindowError from arcade.types import RGBA255, Color diff --git a/tests/conftest.py b/tests/conftest.py index 5d9644c3fb..e28965a69a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,14 +9,13 @@ arcade_accelerate.bootstrap() -import pytest import PIL.Image +import pytest from pyglet.math import Mat4 import arcade +from arcade import LBWH, Rect, gl from arcade.clock import GLOBAL_CLOCK, GLOBAL_FIXED_CLOCK -from arcade import Rect, LBWH -from arcade import gl # from arcade.texture import default_texture_cache # NOTE: Load liberation fonts in unit tests diff --git a/tests/doc/check_examples_2.py b/tests/doc/check_examples_2.py index 78592cdfba..979faf144b 100644 --- a/tests/doc/check_examples_2.py +++ b/tests/doc/check_examples_2.py @@ -1,5 +1,5 @@ -import re import os +import re from pathlib import Path diff --git a/tests/integration/examples/test_examples.py b/tests/integration/examples/test_examples.py index 7b7098df73..34b39b5326 100644 --- a/tests/integration/examples/test_examples.py +++ b/tests/integration/examples/test_examples.py @@ -3,15 +3,15 @@ """ import contextlib -import io import inspect +import io import os import runpy from pathlib import Path -import arcade import pytest +import arcade import arcade.clock # File path, module path diff --git a/tests/integration/examples/test_line_lengths.py b/tests/integration/examples/test_line_lengths.py index 5682c61539..ed21007ae0 100644 --- a/tests/integration/examples/test_line_lengths.py +++ b/tests/integration/examples/test_line_lengths.py @@ -7,6 +7,7 @@ import re from pathlib import Path + import arcade EXAMPLE_ROOT = Path(arcade.__file__).resolve().parent / "examples" diff --git a/tests/integration/test_ubo_stress.py b/tests/integration/test_ubo_stress.py index 2e6a838bf2..7fd7434c15 100644 --- a/tests/integration/test_ubo_stress.py +++ b/tests/integration/test_ubo_stress.py @@ -18,7 +18,7 @@ import arcade # noqa: E402 from arcade.gl import Context # noqa: E402 -from arcade.types import Color, LBWH # noqa: E402 +from arcade.types import LBWH, Color # noqa: E402 WINDOW_CYCLES = 100 @@ -174,6 +174,5 @@ def test_window_draw_reset_cycles_do_not_grow_ubo(): str(w.message) for w in caught if "Growing UniformBufferObject" in str(w.message) ] assert not growth_warnings, ( - f"UBO grew unboundedly across {WINDOW_CYCLES} reset cycles:\n" - + "\n".join(growth_warnings) + f"UBO grew unboundedly across {WINDOW_CYCLES} reset cycles:\n" + "\n".join(growth_warnings) ) diff --git a/tests/integration/tutorials/test_tutorials.py b/tests/integration/tutorials/test_tutorials.py index 8be9e6e2d3..1df4d7769b 100644 --- a/tests/integration/tutorials/test_tutorials.py +++ b/tests/integration/tutorials/test_tutorials.py @@ -2,14 +2,15 @@ Find and run all tutorials in the doc/tutorials directory """ +import contextlib import io import os -import contextlib import runpy -from pathlib import Path import sys +from pathlib import Path import pytest + import arcade TUTORIAL_DIR = Path(arcade.__file__).parent.parent / "doc" / "tutorials" diff --git a/tests/manual_smoke/sprite_collision_inspector.py b/tests/manual_smoke/sprite_collision_inspector.py index efcaa5fb2f..f858993823 100644 --- a/tests/manual_smoke/sprite_collision_inspector.py +++ b/tests/manual_smoke/sprite_collision_inspector.py @@ -1,12 +1,12 @@ import builtins -from typing import TypeVar, Type, Generic, Any, Callable +from typing import Any, Callable, Generic, Type, TypeVar from pyglet.math import Vec2 import arcade -from arcade import SpriteList, Sprite, SpriteSolidColor, load_texture -from arcade.gui import UIManager, NinePatchTexture, UIInputText, UIWidget, UIBoxLayout -from arcade.types import RGBOrA255, Color +from arcade import Sprite, SpriteList, SpriteSolidColor, load_texture +from arcade.gui import NinePatchTexture, UIBoxLayout, UIInputText, UIManager, UIWidget +from arcade.types import Color, RGBOrA255 GRID_REGULAR = arcade.color.GREEN.replace(a=128) GRID_HIGHLIGHT = arcade.color.GREEN diff --git a/tests/unit/atlas/conftest.py b/tests/unit/atlas/conftest.py index 68792dc623..91c69460a2 100644 --- a/tests/unit/atlas/conftest.py +++ b/tests/unit/atlas/conftest.py @@ -1,4 +1,5 @@ import pytest + import arcade diff --git a/tests/unit/atlas/test_basics.py b/tests/unit/atlas/test_basics.py index 8aa71c5a98..9980efb0dc 100644 --- a/tests/unit/atlas/test_basics.py +++ b/tests/unit/atlas/test_basics.py @@ -1,9 +1,10 @@ import PIL.Image import pytest from pyglet.graphics.atlas import AllocatorException + import arcade from arcade import DefaultTextureAtlas, load_texture -from arcade.gl import Texture2D, Framebuffer +from arcade.gl import Framebuffer, Texture2D def test_create(ctx, common): diff --git a/tests/unit/atlas/test_gc.py b/tests/unit/atlas/test_gc.py index e637e483b2..492b34bfae 100644 --- a/tests/unit/atlas/test_gc.py +++ b/tests/unit/atlas/test_gc.py @@ -1,4 +1,5 @@ import gc + import arcade diff --git a/tests/unit/atlas/test_rebuild_resize.py b/tests/unit/atlas/test_rebuild_resize.py index 7848355445..85090e98da 100644 --- a/tests/unit/atlas/test_rebuild_resize.py +++ b/tests/unit/atlas/test_rebuild_resize.py @@ -1,6 +1,7 @@ import PIL.Image import pytest from pyglet.graphics.atlas import AllocatorException + import arcade from arcade import DefaultTextureAtlas, load_texture diff --git a/tests/unit/atlas/test_region.py b/tests/unit/atlas/test_region.py index be03f8bbf2..f1a9e1ecc8 100644 --- a/tests/unit/atlas/test_region.py +++ b/tests/unit/atlas/test_region.py @@ -1,11 +1,11 @@ """Test AtlasRegion class.""" -import pytest import PIL.Image +import pytest -from arcade.texture_atlas.region import AtlasRegion from arcade.texture.texture import ImageData from arcade.texture_atlas.atlas_default import DefaultTextureAtlas +from arcade.texture_atlas.region import AtlasRegion def test_region_coordinates_simple(ctx): diff --git a/tests/unit/atlas/test_update_texture_image_from_atlas.py b/tests/unit/atlas/test_update_texture_image_from_atlas.py index f44a4e6e82..102b61f6a3 100644 --- a/tests/unit/atlas/test_update_texture_image_from_atlas.py +++ b/tests/unit/atlas/test_update_texture_image_from_atlas.py @@ -3,6 +3,7 @@ """ from PIL import Image, ImageDraw + import arcade diff --git a/tests/unit/cache/test_hit_box_cache.py b/tests/unit/cache/test_hit_box_cache.py index cdb842a880..c634f1e8da 100644 --- a/tests/unit/cache/test_hit_box_cache.py +++ b/tests/unit/cache/test_hit_box_cache.py @@ -1,4 +1,5 @@ import pytest + from arcade import load_texture from arcade.cache import HitBoxCache diff --git a/tests/unit/cache/test_image_cache.py b/tests/unit/cache/test_image_cache.py index 581b313a34..8838df7d3d 100644 --- a/tests/unit/cache/test_image_cache.py +++ b/tests/unit/cache/test_image_cache.py @@ -1,7 +1,8 @@ import pytest from PIL import Image -from arcade.texture import ImageData + from arcade.cache import ImageDataCache +from arcade.texture import ImageData image_1 = ImageData(Image.new("RGBA", (10, 10), (255, 0, 0, 255))) image_2 = ImageData(Image.new("RGBA", (10, 10), (255, 0, 0, 255))) diff --git a/tests/unit/cache/test_texture_cache.py b/tests/unit/cache/test_texture_cache.py index 7709e08d53..b3626231a7 100644 --- a/tests/unit/cache/test_texture_cache.py +++ b/tests/unit/cache/test_texture_cache.py @@ -1,5 +1,6 @@ import pytest from PIL import Image + import arcade from arcade.cache import TextureCache diff --git a/tests/unit/camera/test_camera2d.py b/tests/unit/camera/test_camera2d.py index ac1c7489ea..f73ffcf3e4 100644 --- a/tests/unit/camera/test_camera2d.py +++ b/tests/unit/camera/test_camera2d.py @@ -1,13 +1,12 @@ -from typing import Tuple from math import radians +from typing import Tuple import pytest as pytest - from pyglet.math import Vec2 -from arcade import Window, LRBT +from arcade import LRBT, Window from arcade.camera import Camera2D -from arcade.camera.data_types import ZeroProjectionDimension, OrthographicProjectionData +from arcade.camera.data_types import OrthographicProjectionData, ZeroProjectionDimension class Camera2DSub1(Camera2D): ... diff --git a/tests/unit/camera/test_camera_controller_methods.py b/tests/unit/camera/test_camera_controller_methods.py index 87848412fe..b2351078e5 100644 --- a/tests/unit/camera/test_camera_controller_methods.py +++ b/tests/unit/camera/test_camera_controller_methods.py @@ -1,7 +1,7 @@ import pytest as pytest -from arcade import camera, Window import arcade.camera.grips as grips +from arcade import Window, camera def test_strafe(): diff --git a/tests/unit/camera/test_camera_shake.py b/tests/unit/camera/test_camera_shake.py index 7346f370c5..ac096c1690 100644 --- a/tests/unit/camera/test_camera_shake.py +++ b/tests/unit/camera/test_camera_shake.py @@ -1,4 +1,4 @@ -from arcade import camera, Window +from arcade import Window, camera from arcade.camera.grips import ScreenShake2D diff --git a/tests/unit/camera/test_orthographic_projector.py b/tests/unit/camera/test_orthographic_projector.py index 8834a71f2e..dbe2b6f5ce 100644 --- a/tests/unit/camera/test_orthographic_projector.py +++ b/tests/unit/camera/test_orthographic_projector.py @@ -1,8 +1,7 @@ import pytest as pytest - from pyglet.math import Vec3 -from arcade import camera, Window +from arcade import Window, camera def test_orthographic_projector_use(window: Window): diff --git a/tests/unit/camera/test_perspective_projector.py b/tests/unit/camera/test_perspective_projector.py index e4e0caa906..17626e150b 100644 --- a/tests/unit/camera/test_perspective_projector.py +++ b/tests/unit/camera/test_perspective_projector.py @@ -1,8 +1,8 @@ -from math import tan, radians +from math import radians, tan import pytest as pytest -from arcade import camera, Window +from arcade import Window, camera def test_perspective_projector_use(window: Window): diff --git a/tests/unit/camera/test_viewport_projector.py b/tests/unit/camera/test_viewport_projector.py index 56fe0fa48f..e373c56ffa 100644 --- a/tests/unit/camera/test_viewport_projector.py +++ b/tests/unit/camera/test_viewport_projector.py @@ -1,9 +1,8 @@ import pytest as pytest +from pyglet.math import Vec2, Vec3 -from pyglet.math import Vec3, Vec2 - -from arcade import camera, Window -from arcade.types import Point, LBWH, Rect +from arcade import Window, camera +from arcade.types import LBWH, Point, Rect @pytest.mark.parametrize("wrld_pos", [Vec2(100, 150), Vec2(1280, 720), Vec3(500, 500, -10)]) diff --git a/tests/unit/color/test_color_type.py b/tests/unit/color/test_color_type.py index c92f66fe7d..f7d3ae896c 100644 --- a/tests/unit/color/test_color_type.py +++ b/tests/unit/color/test_color_type.py @@ -1,7 +1,7 @@ import math from copy import deepcopy from itertools import product -from typing import Iterable, Callable, Tuple +from typing import Callable, Iterable, Tuple from unittest.mock import Mock import pytest diff --git a/tests/unit/gl/backends/gl/test_gl_program.py b/tests/unit/gl/backends/gl/test_gl_program.py index 63fc978596..6ac0043678 100644 --- a/tests/unit/gl/backends/gl/test_gl_program.py +++ b/tests/unit/gl/backends/gl/test_gl_program.py @@ -1,10 +1,12 @@ import struct + import pytest from pyglet.graphics.api import gl from pyglet.math import Mat4 + from arcade.gl import ShaderException -from arcade.gl.backends.opengl.uniform import UniformBlock from arcade.gl.backends.opengl.glsl import ShaderSource +from arcade.gl.backends.opengl.uniform import UniformBlock pytestmark = pytest.mark.backendgl diff --git a/tests/unit/gl/test_gl_buffer.py b/tests/unit/gl/test_gl_buffer.py index 1a919a2e80..1c605ef6f5 100644 --- a/tests/unit/gl/test_gl_buffer.py +++ b/tests/unit/gl/test_gl_buffer.py @@ -1,4 +1,5 @@ from array import array + import pytest diff --git a/tests/unit/gl/test_gl_buffer_description.py b/tests/unit/gl/test_gl_buffer_description.py index 14c3ca1d79..1a216dc748 100644 --- a/tests/unit/gl/test_gl_buffer_description.py +++ b/tests/unit/gl/test_gl_buffer_description.py @@ -1,4 +1,5 @@ import pytest + from arcade.gl import BufferDescription diff --git a/tests/unit/gl/test_gl_framebuffer.py b/tests/unit/gl/test_gl_framebuffer.py index ee813fd4bc..1f7679e07f 100644 --- a/tests/unit/gl/test_gl_framebuffer.py +++ b/tests/unit/gl/test_gl_framebuffer.py @@ -1,4 +1,5 @@ import pytest + import arcade diff --git a/tests/unit/gl/test_gl_query.py b/tests/unit/gl/test_gl_query.py index efd0bd2ab6..967efa13f2 100644 --- a/tests/unit/gl/test_gl_query.py +++ b/tests/unit/gl/test_gl_query.py @@ -1,4 +1,5 @@ import sys + import arcade from arcade.gl import geometry diff --git a/tests/unit/gl/test_gl_texture.py b/tests/unit/gl/test_gl_texture.py index 3ff6272bb5..65c7a9e270 100644 --- a/tests/unit/gl/test_gl_texture.py +++ b/tests/unit/gl/test_gl_texture.py @@ -1,4 +1,5 @@ import array + import pytest diff --git a/tests/unit/gl/test_gl_types.py b/tests/unit/gl/test_gl_types.py index 0e0d70fc9b..5e19540bc0 100644 --- a/tests/unit/gl/test_gl_types.py +++ b/tests/unit/gl/test_gl_types.py @@ -1,5 +1,6 @@ import pytest from pyglet.graphics.api import gl + from arcade.gl import types diff --git a/tests/unit/gl/test_gl_vertex_array.py b/tests/unit/gl/test_gl_vertex_array.py index 1397542649..e01585481e 100644 --- a/tests/unit/gl/test_gl_vertex_array.py +++ b/tests/unit/gl/test_gl_vertex_array.py @@ -4,10 +4,12 @@ import array import struct + import pytest + from arcade.gl import BufferDescription -from arcade.gl.vertex_array import VertexArray from arcade.gl.program import Program +from arcade.gl.vertex_array import VertexArray def test_geometry(ctx): diff --git a/tests/unit/gui/conftest.py b/tests/unit/gui/conftest.py index a34f64cd99..95572d1a15 100644 --- a/tests/unit/gui/conftest.py +++ b/tests/unit/gui/conftest.py @@ -1,6 +1,7 @@ from pytest import fixture from arcade.gui import UIManager + from . import InteractionMixin diff --git a/tests/unit/gui/test_animate.py b/tests/unit/gui/test_animate.py index 7c224c688b..abb6674ebb 100644 --- a/tests/unit/gui/test_animate.py +++ b/tests/unit/gui/test_animate.py @@ -2,8 +2,8 @@ from arcade.anim import Easing from arcade.gui import UIDummy, UIWidget -from arcade.gui.experimental import Animation, TransitionAttr, UIAnimatedGroup, rel from arcade.gui.events import UIOnUpdateEvent +from arcade.gui.experimental import Animation, TransitionAttr, UIAnimatedGroup, rel from arcade.types import Color diff --git a/tests/unit/gui/test_event_order.py b/tests/unit/gui/test_event_order.py index a46b0f756d..432ac92d01 100644 --- a/tests/unit/gui/test_event_order.py +++ b/tests/unit/gui/test_event_order.py @@ -1,5 +1,5 @@ import arcade -from arcade.gui import UIManager, UIFlatButton +from arcade.gui import UIFlatButton, UIManager def test_event_order_from_window(window: arcade.Window): diff --git a/tests/unit/gui/test_exp_restricted_input.py b/tests/unit/gui/test_exp_restricted_input.py index bc373cd36c..aa82b2e66e 100644 --- a/tests/unit/gui/test_exp_restricted_input.py +++ b/tests/unit/gui/test_exp_restricted_input.py @@ -1,4 +1,4 @@ -from arcade.gui.experimental.restricted_input import UIRestrictedInput, UIIntInput, UIRegexInput +from arcade.gui.experimental.restricted_input import UIIntInput, UIRegexInput, UIRestrictedInput def test_restricted_input_ignore_invalid_input(ui): diff --git a/tests/unit/gui/test_interactions.py b/tests/unit/gui/test_interactions.py index a6cce78256..3ec32ef685 100644 --- a/tests/unit/gui/test_interactions.py +++ b/tests/unit/gui/test_interactions.py @@ -2,8 +2,9 @@ from unittest.mock import Mock import arcade -from arcade.gui.events import UIEvent, UIOnClickEvent, UIMousePressEvent, UIMouseReleaseEvent +from arcade.gui.events import UIEvent, UIMousePressEvent, UIMouseReleaseEvent, UIOnClickEvent from arcade.gui.widgets import UIDummy + from . import record_ui_events diff --git a/tests/unit/gui/test_interactive_sprite_widget.py b/tests/unit/gui/test_interactive_sprite_widget.py index b6fc12a3c6..06c6db873b 100644 --- a/tests/unit/gui/test_interactive_sprite_widget.py +++ b/tests/unit/gui/test_interactive_sprite_widget.py @@ -1,7 +1,7 @@ from unittest.mock import Mock import arcade -from arcade.gui import UIInteractiveSpriteWidget, UIBoxLayout +from arcade.gui import UIBoxLayout, UIInteractiveSpriteWidget from arcade.gui.events import UIOnClickEvent from arcade.gui.widgets.layout import UIAnchorLayout diff --git a/tests/unit/gui/test_layouting_anchorlayout.py b/tests/unit/gui/test_layouting_anchorlayout.py index b6fbc5b8d3..7ce135335c 100644 --- a/tests/unit/gui/test_layouting_anchorlayout.py +++ b/tests/unit/gui/test_layouting_anchorlayout.py @@ -1,6 +1,6 @@ from pyglet.math import Vec2 -from arcade.gui import UIDummy, UIBoxLayout +from arcade.gui import UIBoxLayout, UIDummy from arcade.gui.widgets.layout import UIAnchorLayout from arcade.types import LBWH diff --git a/tests/unit/gui/test_layouting_examples.py b/tests/unit/gui/test_layouting_examples.py index 0eeb676e4a..940a620daf 100644 --- a/tests/unit/gui/test_layouting_examples.py +++ b/tests/unit/gui/test_layouting_examples.py @@ -1,6 +1,7 @@ +from pyglet.math import Vec2 + from arcade import LBWH from arcade.gui import UIBoxLayout, UIDummy -from pyglet.math import Vec2 def test_uiboxlayout_bars_with_size_hint(window): diff --git a/tests/unit/gui/test_ninepatch_draw.py b/tests/unit/gui/test_ninepatch_draw.py index 291bbab8a7..5afcecec63 100644 --- a/tests/unit/gui/test_ninepatch_draw.py +++ b/tests/unit/gui/test_ninepatch_draw.py @@ -5,8 +5,8 @@ from pyglet.math import Mat4 import arcade -from arcade.gui import NinePatchTexture from arcade import LBWH +from arcade.gui import NinePatchTexture # Various combinations of borders sizes PATCH_VARIANTS = list(itertools.product([1, 0], repeat=4)) diff --git a/tests/unit/gui/test_property_alias.py b/tests/unit/gui/test_property_alias.py index 33ae17d9f7..4dd9230a29 100644 --- a/tests/unit/gui/test_property_alias.py +++ b/tests/unit/gui/test_property_alias.py @@ -3,6 +3,7 @@ import pytest from arcade.gui.property import AliasProperty, Property, bind, unbind + from .test_property import Observer diff --git a/tests/unit/gui/test_property_dict.py b/tests/unit/gui/test_property_dict.py index 01026385ea..4bf6a89f60 100644 --- a/tests/unit/gui/test_property_dict.py +++ b/tests/unit/gui/test_property_dict.py @@ -1,7 +1,8 @@ import gc from typing import Dict -from arcade.gui.property import bind, DictProperty, _ObservableDict +from arcade.gui.property import DictProperty, _ObservableDict, bind + from .test_property import Observer diff --git a/tests/unit/gui/test_property_list.py b/tests/unit/gui/test_property_list.py index 5ec7ada102..9285bbfad5 100644 --- a/tests/unit/gui/test_property_list.py +++ b/tests/unit/gui/test_property_list.py @@ -1,7 +1,8 @@ import gc from typing import List -from arcade.gui.property import bind, ListProperty, _ObservableList +from arcade.gui.property import ListProperty, _ObservableList, bind + from .test_property import Observer diff --git a/tests/unit/gui/test_surface.py b/tests/unit/gui/test_surface.py index f23e495592..640f9b7475 100644 --- a/tests/unit/gui/test_surface.py +++ b/tests/unit/gui/test_surface.py @@ -3,7 +3,7 @@ import arcade from arcade import LBWH, load_texture from arcade.color import WHITE -from arcade.gui import Surface, NinePatchTexture +from arcade.gui import NinePatchTexture, Surface def test_surface_draw_texture_raises_not_implemented_error_on_unsupported_values(window): diff --git a/tests/unit/gui/test_transitions.py b/tests/unit/gui/test_transitions.py index dece0508ec..da36d35d5a 100644 --- a/tests/unit/gui/test_transitions.py +++ b/tests/unit/gui/test_transitions.py @@ -3,17 +3,17 @@ import pytest from arcade.gui import UIDummy, UIWidget +from arcade.gui.events import UIOnUpdateEvent from arcade.gui.experimental import ( - TransitionAttr, - TransitionChain, EventTransitionBase, - TransitionParallel, - TransitionDelay, + TransitionAttr, TransitionAttrIncr, TransitionAttrSet, + TransitionChain, + TransitionDelay, + TransitionParallel, UIAnimatedGroup, ) -from arcade.gui.events import UIOnUpdateEvent def update(widget: UIWidget, dt: float): diff --git a/tests/unit/gui/test_uilabel.py b/tests/unit/gui/test_uilabel.py index 60f7a2bfcd..538bd3b4de 100644 --- a/tests/unit/gui/test_uilabel.py +++ b/tests/unit/gui/test_uilabel.py @@ -4,7 +4,7 @@ from pyglet.text import LinearGradient from arcade.gui import UILabel -from arcade.types import Color, LBWH +from arcade.types import LBWH, Color def test_constructor_only_text_no_size(window): diff --git a/tests/unit/gui/test_uimanager.py b/tests/unit/gui/test_uimanager.py index cc961fa31a..c9c08cdd59 100644 --- a/tests/unit/gui/test_uimanager.py +++ b/tests/unit/gui/test_uimanager.py @@ -1,4 +1,4 @@ -from arcade.gui import UIManager, UIDummy +from arcade.gui import UIDummy, UIManager def test_walk_widgets(window): diff --git a/tests/unit/gui/test_uimanager_callbacks.py b/tests/unit/gui/test_uimanager_callbacks.py index edfa10293e..f162e685f7 100644 --- a/tests/unit/gui/test_uimanager_callbacks.py +++ b/tests/unit/gui/test_uimanager_callbacks.py @@ -1,15 +1,16 @@ import arcade -from arcade.gui import UIMousePressEvent, UIMouseReleaseEvent, UIKeyReleaseEvent +from arcade.gui import UIKeyReleaseEvent, UIMousePressEvent, UIMouseReleaseEvent from arcade.gui.events import ( - UIMouseScrollEvent, - UIMouseMovementEvent, UIKeyPressEvent, + UIMouseMovementEvent, + UIMouseScrollEvent, UITextInputEvent, UITextMotionEvent, UITextMotionSelectEvent, ) from arcade.gui.widgets import UIDummy from arcade.key import MOTION_UP + from . import record_ui_events diff --git a/tests/unit/gui/test_uimanager_layouting.py b/tests/unit/gui/test_uimanager_layouting.py index f9f29ee409..58a9296fee 100644 --- a/tests/unit/gui/test_uimanager_layouting.py +++ b/tests/unit/gui/test_uimanager_layouting.py @@ -2,7 +2,7 @@ from pyglet.math import Vec2 -from arcade.gui import UIManager, UIDummy +from arcade.gui import UIDummy, UIManager @contextmanager diff --git a/tests/unit/gui/test_uimanager_layouting_cascade.py b/tests/unit/gui/test_uimanager_layouting_cascade.py index fd832ba013..7eb55f78aa 100644 --- a/tests/unit/gui/test_uimanager_layouting_cascade.py +++ b/tests/unit/gui/test_uimanager_layouting_cascade.py @@ -1,4 +1,4 @@ -from arcade.gui import UIManager, UILayout, Surface +from arcade.gui import Surface, UILayout, UIManager class MockLayout(UILayout): diff --git a/tests/unit/gui/test_uistyle.py b/tests/unit/gui/test_uistyle.py index 4b478091a9..6af4162c8b 100644 --- a/tests/unit/gui/test_uistyle.py +++ b/tests/unit/gui/test_uistyle.py @@ -1,8 +1,8 @@ from dataclasses import dataclass import arcade -from arcade.types import Color from arcade.gui.style import UIStyleBase +from arcade.types import Color @dataclass diff --git a/tests/unit/gui/test_widget_events.py b/tests/unit/gui/test_widget_events.py index 9367c01ecd..d88a474f46 100644 --- a/tests/unit/gui/test_widget_events.py +++ b/tests/unit/gui/test_widget_events.py @@ -1,4 +1,4 @@ -from arcade.gui import UIWidget, Surface +from arcade.gui import Surface, UIWidget from arcade.gui.events import UIOnUpdateEvent diff --git a/tests/unit/hitbox/test_black_image.py b/tests/unit/hitbox/test_black_image.py index 9558bf6a17..498206032d 100644 --- a/tests/unit/hitbox/test_black_image.py +++ b/tests/unit/hitbox/test_black_image.py @@ -3,6 +3,7 @@ """ from PIL import Image + import arcade EXPECTED = ((-50.0, -50.0), (50.0, -50.0), (50.0, 50.0), (-50.0, 50.0)) diff --git a/tests/unit/hitbox/test_hitbox.py b/tests/unit/hitbox/test_hitbox.py index f96f7cd109..c979951d52 100644 --- a/tests/unit/hitbox/test_hitbox.py +++ b/tests/unit/hitbox/test_hitbox.py @@ -2,6 +2,7 @@ import random import pytest + from arcade import hitbox points = [(0.0, 0.0), (0.0, 10.0), (10.0, 10.0), (10.0, 0.0)] diff --git a/tests/unit/hitbox/test_hitbox_algo_legacy.py b/tests/unit/hitbox/test_hitbox_algo_legacy.py index 92e4972655..45f4e2f41f 100644 --- a/tests/unit/hitbox/test_hitbox_algo_legacy.py +++ b/tests/unit/hitbox/test_hitbox_algo_legacy.py @@ -1,7 +1,8 @@ import pytest -from arcade import hitbox from PIL import Image +from arcade import hitbox + def test_calculate_hit_box_points_simple(): # Completely filled RGBA image diff --git a/tests/unit/rect/test_rect_creation_helpers.py b/tests/unit/rect/test_rect_creation_helpers.py index f78cb24027..942d899e95 100644 --- a/tests/unit/rect/test_rect_creation_helpers.py +++ b/tests/unit/rect/test_rect_creation_helpers.py @@ -1,6 +1,6 @@ import pytest -from arcade.types.rect import LBWH, LRBT, XYWH, XYRR, Rect +from arcade.types.rect import LBWH, LRBT, XYRR, XYWH, Rect def test_make_LBWH(): diff --git a/tests/unit/rect/test_rect_instances.py b/tests/unit/rect/test_rect_instances.py index 500fb13edd..53413c87b1 100644 --- a/tests/unit/rect/test_rect_instances.py +++ b/tests/unit/rect/test_rect_instances.py @@ -1,8 +1,8 @@ -from typing import Callable, Any +from typing import Any, Callable from pyglet.math import Vec2 -from arcade.types.rect import Rect, LBWH, LRBT, XYRR, XYWH +from arcade.types.rect import LBWH, LRBT, XYRR, XYWH, Rect A_RECT = Rect(10, 20, 10, 20, 10, 10, 15, 15) diff --git a/tests/unit/rendering/generate_baseline.py b/tests/unit/rendering/generate_baseline.py index a988898abb..91856ec13b 100644 --- a/tests/unit/rendering/generate_baseline.py +++ b/tests/unit/rendering/generate_baseline.py @@ -22,7 +22,6 @@ os.environ["ARCADE_TEST"] = "True" import arcade # noqa: E402 - from tests.unit.rendering.scenes import SCENE_HEIGHT, SCENE_WIDTH, SCENES # noqa: E402 BASELINE_DIR = Path(__file__).parent / "baseline" diff --git a/tests/unit/rendering/image_compare.py b/tests/unit/rendering/image_compare.py index b12769eb20..aa91f87b1f 100644 --- a/tests/unit/rendering/image_compare.py +++ b/tests/unit/rendering/image_compare.py @@ -76,8 +76,7 @@ def compare_images(actual: PIL.Image.Image, expected: PIL.Image.Image) -> ImageD mean_abs_difference_fraction = sum(PIL.ImageStat.Stat(diff).mean) / (3 * 255) per_channel_masks = [ - channel.point(lambda v: 255 if v > MAX_PER_CHANNEL_DELTA else 0) - for channel in diff.split() + channel.point(lambda v: 255 if v > MAX_PER_CHANNEL_DELTA else 0) for channel in diff.split() ] combined_mask = per_channel_masks[0] for mask in per_channel_masks[1:]: diff --git a/tests/unit/resources/test_handles.py b/tests/unit/resources/test_handles.py index 66bd803942..e6315fe24a 100644 --- a/tests/unit/resources/test_handles.py +++ b/tests/unit/resources/test_handles.py @@ -1,5 +1,7 @@ from pathlib import Path + import pytest + from arcade import resources MODULE_DIR = Path(__file__).parent.parent.resolve() diff --git a/tests/unit/resources/test_list_resources.py b/tests/unit/resources/test_list_resources.py index e62f1015ac..d388943510 100644 --- a/tests/unit/resources/test_list_resources.py +++ b/tests/unit/resources/test_list_resources.py @@ -5,6 +5,7 @@ """ import pytest + import arcade diff --git a/tests/unit/scene/test_scene.py b/tests/unit/scene/test_scene.py index d86fbeb591..efa31d76b2 100644 --- a/tests/unit/scene/test_scene.py +++ b/tests/unit/scene/test_scene.py @@ -1,4 +1,5 @@ import pytest + import arcade diff --git a/tests/unit/scene/test_scene_dunder_methods.py b/tests/unit/scene/test_scene_dunder_methods.py index e10f1bde2f..cfc2fb7a29 100644 --- a/tests/unit/scene/test_scene_dunder_methods.py +++ b/tests/unit/scene/test_scene_dunder_methods.py @@ -1,6 +1,7 @@ -import arcade import pytest +import arcade + def test_len(): scene = arcade.Scene() diff --git a/tests/unit/scene/test_scene_remove_sprite_lists.py b/tests/unit/scene/test_scene_remove_sprite_lists.py index 4dcd35571b..9656de0ee3 100644 --- a/tests/unit/scene/test_scene_remove_sprite_lists.py +++ b/tests/unit/scene/test_scene_remove_sprite_lists.py @@ -1,6 +1,7 @@ -import arcade import pytest +import arcade + def test_remove_sprite_list_by_index(): scene = arcade.Scene() diff --git a/tests/unit/shape_list/test_buffered_drawing.py b/tests/unit/shape_list/test_buffered_drawing.py index b1e51460af..6e0373eba2 100644 --- a/tests/unit/shape_list/test_buffered_drawing.py +++ b/tests/unit/shape_list/test_buffered_drawing.py @@ -1,20 +1,21 @@ import copy + +import pyglet.graphics.api.gl as gl import pytest import arcade from arcade.shape_list import ( ShapeElementList, - create_line, create_ellipse_filled, create_ellipse_filled_with_colors, - create_rectangle_filled, - create_rectangle_outline, create_ellipse_outline, - create_rectangle_filled_with_colors, + create_line, create_line_generic, create_line_strip, + create_rectangle_filled, + create_rectangle_filled_with_colors, + create_rectangle_outline, ) -import pyglet.graphics.api.gl as gl SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 diff --git a/tests/unit/sprite/test_copy_dunders.py b/tests/unit/sprite/test_copy_dunders.py index 6975b1e76e..9a46b1deca 100644 --- a/tests/unit/sprite/test_copy_dunders.py +++ b/tests/unit/sprite/test_copy_dunders.py @@ -1,4 +1,5 @@ import copy + import pytest import arcade diff --git a/tests/unit/sprite/test_sprite_collision.py b/tests/unit/sprite/test_sprite_collision.py index 90b21cb813..a482f9bc11 100644 --- a/tests/unit/sprite/test_sprite_collision.py +++ b/tests/unit/sprite/test_sprite_collision.py @@ -2,9 +2,9 @@ import random import pytest +from pyglet.math import Vec2 import arcade -from pyglet.math import Vec2 def test_sprites_at_point(): diff --git a/tests/unit/sprite/test_sprite_texture_animation.py b/tests/unit/sprite/test_sprite_texture_animation.py index 765150cd2a..516cf8a9bb 100644 --- a/tests/unit/sprite/test_sprite_texture_animation.py +++ b/tests/unit/sprite/test_sprite_texture_animation.py @@ -1,4 +1,5 @@ import pytest + import arcade diff --git a/tests/unit/spritelist/test_spatial_hash.py b/tests/unit/spritelist/test_spatial_hash.py index 20f33f1a02..18ae6626ca 100644 --- a/tests/unit/spritelist/test_spatial_hash.py +++ b/tests/unit/spritelist/test_spatial_hash.py @@ -1,4 +1,5 @@ import pytest + import arcade from arcade.sprite_list.spatial_hash import SpatialHash from arcade.types.rect import LRBT diff --git a/tests/unit/spritelist/test_spritelist.py b/tests/unit/spritelist/test_spritelist.py index a3e6efd8ce..6558e2424b 100644 --- a/tests/unit/spritelist/test_spritelist.py +++ b/tests/unit/spritelist/test_spritelist.py @@ -1,6 +1,8 @@ -from array import array import struct +from array import array + import pytest + import arcade from arcade import gl diff --git a/tests/unit/spritelist/test_spritelist_buffers.py b/tests/unit/spritelist/test_spritelist_buffers.py index 2063565c8c..97201625e5 100644 --- a/tests/unit/spritelist/test_spritelist_buffers.py +++ b/tests/unit/spritelist/test_spritelist_buffers.py @@ -4,6 +4,7 @@ """ import struct + import arcade diff --git a/tests/unit/spritelist/test_spritelist_draw.py b/tests/unit/spritelist/test_spritelist_draw.py index eea6a3a5c8..ca24765447 100644 --- a/tests/unit/spritelist/test_spritelist_draw.py +++ b/tests/unit/spritelist/test_spritelist_draw.py @@ -1,4 +1,5 @@ import pytest + import arcade from arcade.gl import Geometry diff --git a/tests/unit/spritelist/test_spritelist_lazy.py b/tests/unit/spritelist/test_spritelist_lazy.py index b373e8160c..b7daa05ba5 100644 --- a/tests/unit/spritelist/test_spritelist_lazy.py +++ b/tests/unit/spritelist/test_spritelist_lazy.py @@ -1,4 +1,5 @@ import pytest + import arcade from arcade import DefaultTextureAtlas diff --git a/tests/unit/test_arcade.py b/tests/unit/test_arcade.py index b6235dd776..ad4a8296b3 100644 --- a/tests/unit/test_arcade.py +++ b/tests/unit/test_arcade.py @@ -1,10 +1,10 @@ -from types import ModuleType -from copy import copy import logging +from copy import copy +from types import ModuleType + import arcade from arcade import * # noqa: F403 This test checks what a star import gives you - # TODO: double-check whether this is actually the right solution? builtin_types = frozenset((bool, str, int, ModuleType)) diff --git a/tests/unit/test_example_docstrings.py b/tests/unit/test_example_docstrings.py index 832a24dbc7..771a21a943 100644 --- a/tests/unit/test_example_docstrings.py +++ b/tests/unit/test_example_docstrings.py @@ -1,9 +1,9 @@ import ast import importlib -from pathlib import Path import pkgutil -import arcade.examples +from pathlib import Path +import arcade.examples EXAMPLE_ROOT = "arcade.examples" diff --git a/tests/unit/test_hexagon.py b/tests/unit/test_hexagon.py index 9ebe464103..19e73283fd 100644 --- a/tests/unit/test_hexagon.py +++ b/tests/unit/test_hexagon.py @@ -1,3 +1,5 @@ +from pyglet.math import Vec2 + from arcade.hexagon import ( HexTile, Layout, @@ -8,7 +10,6 @@ pixel_to_hextile, pointy_orientation, ) -from pyglet.math import Vec2 # TODO: grab the rest of the tests from my main machine diff --git a/tests/unit/test_isometric.py b/tests/unit/test_isometric.py index 07cdc3b775..c87d328154 100644 --- a/tests/unit/test_isometric.py +++ b/tests/unit/test_isometric.py @@ -1,8 +1,8 @@ import arcade from arcade.isometric import ( + create_isometric_grid_lines, isometric_grid_to_screen, screen_to_isometric_grid, - create_isometric_grid_lines, ) diff --git a/tests/unit/test_math.py b/tests/unit/test_math.py index 8e382de610..a32cedcac6 100644 --- a/tests/unit/test_math.py +++ b/tests/unit/test_math.py @@ -8,6 +8,7 @@ import math from pytest import approx + from arcade.math import ( lerp, lerp_2d, diff --git a/tests/unit/test_shadertoy.py b/tests/unit/test_shadertoy.py index 1813e890ce..d59b60a944 100644 --- a/tests/unit/test_shadertoy.py +++ b/tests/unit/test_shadertoy.py @@ -1,4 +1,5 @@ import pytest + from arcade.experimental import Shadertoy, ShadertoyBuffer from arcade.gl import Program, Texture2D diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 6474fdd7f5..bb970811e8 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -5,7 +5,7 @@ python -m pytest tests/unit/test_utils.py """ -from typing import Callable, Any +from typing import Any, Callable from arcade import utils diff --git a/tests/unit/test_version.py b/tests/unit/test_version.py index 617ce28040..e11fd798d2 100644 --- a/tests/unit/test_version.py +++ b/tests/unit/test_version.py @@ -3,7 +3,8 @@ from unittest import mock import pytest -from arcade.version import _parse_python_friendly_version, _parse_py_version_from_file + +from arcade.version import _parse_py_version_from_file, _parse_python_friendly_version @pytest.mark.parametrize( diff --git a/tests/unit/text/test_text.py b/tests/unit/text/test_text.py index e3e4af5ec6..94c586bb6e 100644 --- a/tests/unit/text/test_text.py +++ b/tests/unit/text/test_text.py @@ -1,6 +1,7 @@ from typing import List import pytest + import arcade diff --git a/tests/unit/text/test_text_fonts.py b/tests/unit/text/test_text_fonts.py index 4f54767abe..d26ce48d63 100644 --- a/tests/unit/text/test_text_fonts.py +++ b/tests/unit/text/test_text_fonts.py @@ -1,10 +1,10 @@ """Tests for font names, paths to font files, and lists of them""" -import pyglet import pytest import arcade import arcade.text +import pyglet KENNEY = "Kenney Future" KENNEY_HANDLE = ":system:fonts/ttf/Kenney/Kenney_Future.ttf" diff --git a/tests/unit/text/test_text_instance_properties.py b/tests/unit/text/test_text_instance_properties.py index a7e129ad6b..efb1d421ca 100644 --- a/tests/unit/text/test_text_instance_properties.py +++ b/tests/unit/text/test_text_instance_properties.py @@ -1,4 +1,5 @@ import pytest + import arcade diff --git a/tests/unit/text/test_text_pool.py b/tests/unit/text/test_text_pool.py index b307cee809..e0ddd40e70 100644 --- a/tests/unit/text/test_text_pool.py +++ b/tests/unit/text/test_text_pool.py @@ -1,4 +1,5 @@ import pytest + import arcade diff --git a/tests/unit/texture/test_image_data.py b/tests/unit/texture/test_image_data.py index c10866f51f..e6c36879c6 100644 --- a/tests/unit/texture/test_image_data.py +++ b/tests/unit/texture/test_image_data.py @@ -1,6 +1,7 @@ -from arcade.texture import ImageData from PIL import Image +from arcade.texture import ImageData + def test_create_sha256(): ImageData.hash_func = "sha256" diff --git a/tests/unit/texture/test_sprite_sheet.py b/tests/unit/texture/test_sprite_sheet.py index feb2c37a53..ca9e825449 100644 --- a/tests/unit/texture/test_sprite_sheet.py +++ b/tests/unit/texture/test_sprite_sheet.py @@ -1,7 +1,8 @@ -from arcade.types.rect import LBWH import pytest from PIL import Image + import arcade +from arcade.types.rect import LBWH # 32x8 grid of 8x16 sprites SPRITE_SHEET_RESOURCE = ":resources:images/spritesheets/codepage_437.png" diff --git a/tests/unit/texture/test_texture.py b/tests/unit/texture/test_texture.py index 93488591c8..30c8b7d449 100644 --- a/tests/unit/texture/test_texture.py +++ b/tests/unit/texture/test_texture.py @@ -1,7 +1,8 @@ import pytest +from PIL import Image, ImageDraw + import arcade from arcade import hitbox -from PIL import Image, ImageDraw def test_create(): diff --git a/tests/unit/texture/test_texture_tools.py b/tests/unit/texture/test_texture_tools.py index bee7b94403..a0fb771687 100644 --- a/tests/unit/texture/test_texture_tools.py +++ b/tests/unit/texture/test_texture_tools.py @@ -1,9 +1,9 @@ from arcade.texture import ( - Texture, ImageData, - get_default_texture, - get_default_image, + Texture, default_texture_cache, + get_default_image, + get_default_texture, ) diff --git a/tests/unit/texture/test_texture_transform_render.py b/tests/unit/texture/test_texture_transform_render.py index c6603a494b..391d8900ad 100644 --- a/tests/unit/texture/test_texture_transform_render.py +++ b/tests/unit/texture/test_texture_transform_render.py @@ -2,16 +2,17 @@ Ensure we are emulating PIL's transforms correctly. """ -import arcade import pytest -from pyglet.math import Mat4 from PIL import Image, ImageDraw +from pyglet.math import Mat4 + +import arcade from arcade.texture.transforms import ( + FlipLeftRightTransform, + FlipTopBottomTransform, Rotate90Transform, Rotate180Transform, Rotate270Transform, - FlipLeftRightTransform, - FlipTopBottomTransform, TransposeTransform, TransverseTransform, ) diff --git a/tests/unit/texture/test_texture_transform_values.py b/tests/unit/texture/test_texture_transform_values.py index 9667b75993..05c3d50af3 100644 --- a/tests/unit/texture/test_texture_transform_values.py +++ b/tests/unit/texture/test_texture_transform_values.py @@ -1,9 +1,9 @@ from arcade.texture.transforms import ( + FlipLeftRightTransform, + FlipTopBottomTransform, Rotate90Transform, Rotate180Transform, Rotate270Transform, - FlipLeftRightTransform, - FlipTopBottomTransform, TransposeTransform, TransverseTransform, VertexOrder, diff --git a/tests/unit/tilemap/test_tilemap_objects.py b/tests/unit/tilemap/test_tilemap_objects.py index 2219934dc2..a3f97c5850 100644 --- a/tests/unit/tilemap/test_tilemap_objects.py +++ b/tests/unit/tilemap/test_tilemap_objects.py @@ -1,7 +1,9 @@ from math import isclose -import arcade + from pytiled_parser.common_types import Color +import arcade + # # Test size, rotation, alpha of tiles from a Tiled object layer # Also tests path traversal to get a layer within a layer group diff --git a/tests/unit/window/test_window.py b/tests/unit/window/test_window.py index 02d69fcb0e..47116db3dd 100644 --- a/tests/unit/window/test_window.py +++ b/tests/unit/window/test_window.py @@ -1,6 +1,7 @@ -import pytest import time +import pytest + import arcade From e8e27199183f446a59b3aabd010abec7cd0eda10 Mon Sep 17 00:00:00 2001 From: Paul V Craven Date: Wed, 7 Oct 2026 13:29:48 -0500 Subject: [PATCH 2/3] Lint the tests, and fail CI on ruff errors - Remove tests from ruff's lint exclude, and run ruff check and the import order check on tests as well as arcade in make.py. - The formatting and linting steps no longer continue on error, so a PR with ruff errors fails the Code Inspections check. Every step runs even if an earlier one fails, so all problems are reported together. Type checking still doesn't fail the check, since mypy and pyright have existing errors. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/code_quality.yml | 12 ++++++------ make.py | 7 ++++--- pyproject.toml | 1 - 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 5193418906..4174745e14 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -31,23 +31,23 @@ jobs: - name: Sync UV project run: uv sync + # Formatting and linting errors fail the check. The later steps still + # run when an earlier one fails, so every problem is reported at once. - name: Formatting (Ruff) - if: success() - continue-on-error: true run: uv run make.py format --check - name: Linting (Ruff) - if: success() - continue-on-error: true + if: ${{ !cancelled() }} run: uv run make.py ruff-check + # Type checking doesn't fail the check yet: there are existing errors - name: Type Checking (MyPy) - if: success() + if: ${{ !cancelled() }} continue-on-error: true run: uv run make.py mypy - name: Type Checking (Pyright) - if: success() + if: ${{ !cancelled() }} continue-on-error: true run: uv run make.py pyright diff --git a/make.py b/make.py index 6dba3e3a11..146a525ea3 100755 --- a/make.py +++ b/make.py @@ -47,7 +47,8 @@ def _resolve(p: PathLike, strict: bool = False) -> Path: RUFF = "ruff" RUFFOPTS = ["check"] RUFFOPTS_ISORT = ["check", "--select", "I"] -RUFFOPTS_PACKAGE = "arcade" +# Code checked by ruff check and import sorting +RUFF_PATHS = ["arcade", "tests"] MYPY = "mypy" MYPYOPTS = ["arcade"] PYRIGHT = "pyright" @@ -460,7 +461,7 @@ def lint(): @app.command(rich_help_panel="Code Quality - Advanced") def ruff_check(): """Run ruff check for code quality""" - run([RUFF, *RUFFOPTS, RUFFOPTS_PACKAGE]) + run([RUFF, *RUFFOPTS, *RUFF_PATHS]) @app.command(rich_help_panel="Code Quality") @@ -484,7 +485,7 @@ def ruff_isort(check: bool = False): """Sort imports with ruff""" if not check: RUFFOPTS_ISORT.append("--fix") - run([RUFF, *RUFFOPTS_ISORT, RUFFOPTS_PACKAGE]) + run([RUFF, *RUFFOPTS_ISORT, *RUFF_PATHS]) @app.command(rich_help_panel="Code Quality - Advanced") diff --git a/pyproject.toml b/pyproject.toml index b596d5b9b2..fdcb516513 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,6 @@ output-format = "full" lint.exclude = [ "venv", ".venv*", - "tests", "build", "doc", "util", From eac9eb71a07617501f312c0b78d986084ffd57a8 Mon Sep 17 00:00:00 2001 From: Paul V Craven Date: Wed, 7 Oct 2026 14:05:23 -0500 Subject: [PATCH 3/3] Sort pyglet imports as third party everywhere The pyglet clone in my checkout made ruff treat pyglet as first party, so the import order fixes grouped pyglet with arcade, and CI (with pyglet installed as a package) reported 14 files as unsorted. Tell ruff pyglet is third party, so the order doesn't depend on the checkout, and sort again. Checked in a clean worktree without the clone. Co-Authored-By: Claude Opus 5.5 --- arcade/application.py | 1 + arcade/cli/commands/info.py | 2 +- arcade/context.py | 2 +- arcade/experimental/input_manager_example.py | 2 +- arcade/future/video/video_player.py | 4 ++-- arcade/gl/backends/opengl/context.py | 2 +- arcade/gl/backends/webgl/context.py | 2 +- arcade/gl/context.py | 3 +-- arcade/gui/widgets/text.py | 2 +- arcade/input/manager.py | 2 +- arcade/sound.py | 2 +- arcade/text.py | 2 +- arcade/window_commands.py | 1 + pyproject.toml | 5 +++++ tests/unit/text/test_text_fonts.py | 2 +- 15 files changed, 20 insertions(+), 14 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 55697ef833..5cd102bd6a 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -12,6 +12,7 @@ from typing import TYPE_CHECKING import pyglet + from arcade.utils import is_pyodide if is_pyodide: diff --git a/arcade/cli/commands/info.py b/arcade/cli/commands/info.py index 84e0024144..ba1328d61d 100644 --- a/arcade/cli/commands/info.py +++ b/arcade/cli/commands/info.py @@ -2,9 +2,9 @@ import sys import PIL +import pyglet import arcade -import pyglet from .base import BaseCommand diff --git a/arcade/context.py b/arcade/context.py index 645bb9505f..c088fb5a68 100644 --- a/arcade/context.py +++ b/arcade/context.py @@ -9,11 +9,11 @@ from pathlib import Path from typing import Any +import pyglet from PIL import Image from pyglet.math import Mat4 import arcade -import pyglet from arcade.camera import Projector from arcade.camera.default import DefaultProjector from arcade.gl import BufferDescription, Context diff --git a/arcade/experimental/input_manager_example.py b/arcade/experimental/input_manager_example.py index 534160064b..2619d48ba0 100644 --- a/arcade/experimental/input_manager_example.py +++ b/arcade/experimental/input_manager_example.py @@ -9,10 +9,10 @@ import random from collections.abc import Sequence +import pyglet from pyglet.input import Controller import arcade -import pyglet from arcade.input import ActionState, ControllerButtons, ControllerSticks, InputManager, Keys WINDOW_WIDTH = 1280 diff --git a/arcade/future/video/video_player.py b/arcade/future/video/video_player.py index 3fc55b956a..35bdc35838 100644 --- a/arcade/future/video/video_player.py +++ b/arcade/future/video/video_player.py @@ -7,11 +7,11 @@ from pathlib import Path -import arcade - # import sys import pyglet +import arcade + class VideoPlayer: """ diff --git a/arcade/gl/backends/opengl/context.py b/arcade/gl/backends/opengl/context.py index 3349cae2f1..81cbe78e06 100644 --- a/arcade/gl/backends/opengl/context.py +++ b/arcade/gl/backends/opengl/context.py @@ -1,9 +1,9 @@ from ctypes import c_char_p, c_float, c_int, cast from typing import Dict, Iterable, List, Sequence, Tuple +import pyglet from pyglet.graphics.api import gl -import pyglet from arcade.context import ArcadeContext from arcade.gl import enums from arcade.gl.context import Context, Info diff --git a/arcade/gl/backends/webgl/context.py b/arcade/gl/backends/webgl/context.py index f5d8a8112b..7902fcd622 100644 --- a/arcade/gl/backends/webgl/context.py +++ b/arcade/gl/backends/webgl/context.py @@ -1,8 +1,8 @@ from typing import TYPE_CHECKING, Dict, Iterable, List, Sequence, Tuple +import pyglet import pyglet.graphics.api -import pyglet from arcade.context import ArcadeContext from arcade.gl import enums from arcade.gl.context import Context, Info diff --git a/arcade/gl/context.py b/arcade/gl/context.py index 6d07d20a59..2466715cbf 100644 --- a/arcade/gl/context.py +++ b/arcade/gl/context.py @@ -18,9 +18,8 @@ overload, ) -from pyglet.window import Window - import pyglet +from pyglet.window import Window from ..types import BufferProtocol from . import enums diff --git a/arcade/gui/widgets/text.py b/arcade/gui/widgets/text.py index 2fe9bed6e8..da85614958 100644 --- a/arcade/gui/widgets/text.py +++ b/arcade/gui/widgets/text.py @@ -3,6 +3,7 @@ from dataclasses import dataclass from typing import Literal +import pyglet from pyglet.event import EVENT_HANDLED, EVENT_UNHANDLED from pyglet.text import LinearGradient from pyglet.text.caret import Caret @@ -10,7 +11,6 @@ from typing_extensions import override import arcade -import pyglet from arcade import uicolor from arcade.gui.events import ( UIEvent, diff --git a/arcade/input/manager.py b/arcade/input/manager.py index 368820ab11..e8d35d300e 100644 --- a/arcade/input/manager.py +++ b/arcade/input/manager.py @@ -5,11 +5,11 @@ from enum import Enum from typing import Any, TypeVar +import pyglet from pyglet.input.base import Controller from typing_extensions import TypedDict import arcade -import pyglet from arcade.input import inputs from arcade.input.input_mapping import ( Action, diff --git a/arcade/sound.py b/arcade/sound.py index 95d8f6bfdd..09c70ce321 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -5,9 +5,9 @@ import os from pathlib import Path +import pyglet from pyglet.media import Source -import pyglet from arcade.resources import resolve from arcade.utils import is_pyodide diff --git a/arcade/text.py b/arcade/text.py index deececee55..9dc2ed0394 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -10,6 +10,7 @@ import PIL.Image import PIL.ImageChops +import pyglet from pyglet.enums import Style, Weight # Pyright can't figure out the dynamic backend imports in pyglet.graphics @@ -18,7 +19,6 @@ from pyglet.text import LinearGradient import arcade -import pyglet from arcade.clock import GLOBAL_CLOCK from arcade.exceptions import NoArcadeWindowError, PerformanceWarning, warning from arcade.resources import resolve diff --git a/arcade/window_commands.py b/arcade/window_commands.py index c6516361f6..13dc5c5533 100644 --- a/arcade/window_commands.py +++ b/arcade/window_commands.py @@ -13,6 +13,7 @@ from typing import TYPE_CHECKING import pyglet + from arcade.exceptions import NoArcadeWindowError from arcade.types import RGBA255, Color diff --git a/pyproject.toml b/pyproject.toml index fdcb516513..05b2e45704 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,6 +122,11 @@ lint.select = [ docstring-code-format = false exclude = ["arcade/examples/*", "benchmarks/*", "doc/*"] +[tool.ruff.lint.isort] +# A pyglet checkout next to arcade would otherwise make ruff treat pyglet as +# first party, and sort its imports differently than in CI +known-third-party = ["pyglet"] + # This ignores __init__.py files and examples for import sorting [tool.ruff.lint.per-file-ignores] "__init__.py" = ["I"] diff --git a/tests/unit/text/test_text_fonts.py b/tests/unit/text/test_text_fonts.py index d26ce48d63..4f54767abe 100644 --- a/tests/unit/text/test_text_fonts.py +++ b/tests/unit/text/test_text_fonts.py @@ -1,10 +1,10 @@ """Tests for font names, paths to font files, and lists of them""" +import pyglet import pytest import arcade import arcade.text -import pyglet KENNEY = "Kenney Future" KENNEY_HANDLE = ":system:fonts/ttf/Kenney/Kenney_Future.ttf"