From 6c8d83908eb1a2e5ced8148f7876464f35ed32e3 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 03:47:56 -0400 Subject: [PATCH 01/45] Bump to pyglet == 2.1dev3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 752e518c4a..2753c750f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ - "pyglet == 2.1dev2", + "pyglet == 2.1dev3", "pillow~=10.2.0", "pymunk~=6.6.0", "pytiled-parser~=2.2.5", From d92fee16caf4395ee2e5820f562a90cb8f79f555 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 03:50:04 -0400 Subject: [PATCH 02/45] Remove del trick for getting future vec behavior --- arcade/__init__.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index 3e28337481..1793c1ad06 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -58,17 +58,6 @@ def configure_logging(level: Optional[int] = None): # noinspection PyPep8 import pyglet -# TODO: Remove ASAP after pyglet >= 2.1dev2 is out -if pyglet.version == "2.1.dev2": - # Temporary monkeypatch via deletion since dev2 still includes - # overly-specific __eq__ behavior. Later pyglet commits restore - # equality with same-valued tuples by deleting the __eq__ methods. - from pyglet import math as _pyglet_math - - del _pyglet_math.Vec2.__eq__ - del _pyglet_math.Vec3.__eq__ - del _pyglet_math.Vec4.__eq__ - # Env variable shortcut for headless mode if os.environ.get("ARCADE_HEADLESS"): pyglet.options["headless"] = True From 9d1a9165b85ef6dcc0eed54eee038a69adaba003 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 03:55:31 -0400 Subject: [PATCH 03/45] Update to options object --- arcade/sound.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arcade/sound.py b/arcade/sound.py index ac6d203967..fe1a1b9069 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -15,11 +15,11 @@ from arcade.resources import resolve if os.environ.get("ARCADE_SOUND_BACKENDS"): - pyglet.options["audio"] = tuple( + pyglet.options.audio = tuple( v.strip() for v in os.environ["ARCADE_SOUND_BACKENDS"].split(",") ) else: - pyglet.options["audio"] = ("openal", "xaudio2", "directsound", "pulse", "silent") + pyglet.options.audio = ("openal", "xaudio2", "directsound", "pulse", "silent") import pyglet.media as media From d5aa0a38753ca6342cecbf21eb025ff6b200590a Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:24:40 -0400 Subject: [PATCH 04/45] Switch arcade/__init__.py to use OOP options object --- arcade/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index 1793c1ad06..83aa16dbda 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -60,13 +60,13 @@ def configure_logging(level: Optional[int] = None): # Env variable shortcut for headless mode if os.environ.get("ARCADE_HEADLESS"): - pyglet.options["headless"] = True + pyglet.options.headless = True from arcade import utils # Disable shadow window on macs and in headless mode. if sys.platform == "darwin" or os.environ.get("ARCADE_HEADLESS") or utils.is_raspberry_pi(): - pyglet.options["shadow_window"] = False + pyglet.options.shadow_window = False # Use the old gdi fonts on windows until directwrite is fast/stable # pyglet.options['win32_gdi_font'] = True @@ -141,7 +141,7 @@ def configure_logging(level: Optional[int] = None): from .screenshot import get_pixel # We don't have joysticks game controllers in headless mode -if not pyglet.options["headless"]: +if not pyglet.options.headless: from .joysticks import get_game_controllers from .joysticks import get_joysticks from .controller import ControllerManager @@ -396,7 +396,7 @@ def configure_logging(level: Optional[int] = None): # Piggyback on pyglet's doc run detection if not getattr(sys, "is_pyglet_doc_run", False): # Load additional game controller mappings to Pyglet - if not pyglet.options["headless"]: + if not pyglet.options.headless: try: import pyglet.input.controller From f6349262f9af9ebcc134d4491301db515d1de783 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:29:19 -0400 Subject: [PATCH 05/45] Convert applications.py to OOP pyglet options --- arcade/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/application.py b/arcade/application.py index d6d202137d..614bd848ea 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -291,7 +291,7 @@ def __init__( if enable_polling: self.keyboard = pyglet.window.key.KeyStateHandler() - if pyglet.options["headless"]: + if pyglet.options.headless: self.push_handlers(self.keyboard) else: From 446ee04a47c49f796ee8ca06c93d2024e3257461 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:32:45 -0400 Subject: [PATCH 06/45] Convert doc on headless to use options object --- doc/programming_guide/headless.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/programming_guide/headless.rst b/doc/programming_guide/headless.rst index 82f19648a2..471e57528d 100644 --- a/doc/programming_guide/headless.rst +++ b/doc/programming_guide/headless.rst @@ -32,7 +32,11 @@ This can be done in the following ways: import os os.environ["ARCADE_HEADLESS"] = "True" -This means you can configure headless externally. + # The above is a shortcut for + import pyglet + pyglet.options.headless = True + +This of course also means you can configure headless externally. .. code:: bash @@ -178,10 +182,10 @@ to a physical device (graphics card) or a virtual card/device. .. code:: py # Default setting - pyglet.options['headless_device'] = 0 + pyglet.options.headless_device = 0 # Use the second gpu/device - pyglet.options['headless_device'] = 1 + pyglet.options.headless_device = 1 Issues? ------- From c840695a202c9e5727685170be9259f1cb6201d9 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:34:08 -0400 Subject: [PATCH 07/45] Fix a comment in arcade/__init__.py --- arcade/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index 83aa16dbda..f063f0b240 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -69,7 +69,7 @@ def configure_logging(level: Optional[int] = None): pyglet.options.shadow_window = False # Use the old gdi fonts on windows until directwrite is fast/stable -# pyglet.options['win32_gdi_font'] = True +# pyglet.options.win32_gdi_font = True # Imports from modules that don't do anything circular From 8a2fce0fd1e9fd9668e1aea412697a9d1c5388e3 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:34:46 -0400 Subject: [PATCH 08/45] Update tests/__init__.py --- tests/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/__init__.py b/tests/__init__.py index ca0a59529b..40bd75a955 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -3,4 +3,4 @@ # Headless mode if os.environ.get("ARCADE_HEADLESS_TEST"): import pyglet - pyglet.options["headless"] = True + pyglet.options.headless = True From 5148b7adcf33394ed12b87c601a6c8f03ab0f858 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 06:28:23 -0400 Subject: [PATCH 09/45] Fix formatting --- arcade/sound.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arcade/sound.py b/arcade/sound.py index fe1a1b9069..cafab10f8b 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -15,9 +15,7 @@ from arcade.resources import resolve if os.environ.get("ARCADE_SOUND_BACKENDS"): - pyglet.options.audio = tuple( - v.strip() for v in os.environ["ARCADE_SOUND_BACKENDS"].split(",") - ) + pyglet.options.audio = tuple(v.strip() for v in os.environ["ARCADE_SOUND_BACKENDS"].split(",")) else: pyglet.options.audio = ("openal", "xaudio2", "directsound", "pulse", "silent") From 30efe0727629696ceb9fb59ed8cc2c880cfcd148 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 06:36:25 -0400 Subject: [PATCH 10/45] Type compatibility fix in controller db loading --- arcade/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index f063f0b240..c4f46c7318 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -401,6 +401,7 @@ def configure_logging(level: Optional[int] = None): import pyglet.input.controller mappings_file = resources.resolve(":system:gamecontrollerdb.txt") - pyglet.input.controller.add_mappings_from_file(mappings_file) + # TODO: remove string conversion once fixed upstream + pyglet.input.controller.add_mappings_from_file(str(mappings_file)) except AssertionError: pass From 760f1bafc132f1d5ed2597cda57a90682ecd8885 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 2 Jul 2024 07:36:38 -0400 Subject: [PATCH 11/45] Use pyglet.media.Source instead of a Union type --- arcade/sound.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arcade/sound.py b/arcade/sound.py index cafab10f8b..698b537da7 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -11,6 +11,7 @@ from typing import Optional, Union import pyglet +from pyglet.media import Source from arcade.resources import resolve @@ -37,7 +38,7 @@ def __init__(self, file_name: Union[str, Path], streaming: bool = False): raise FileNotFoundError(f"The sound file '{file_name}' is not a file or can't be read.") self.file_name = str(file_name) - self.source: Union[media.StaticSource, media.StreamingSource] = media.load( + self.source: Source = media.load( self.file_name, streaming=streaming ) From 9046d3d6dd81f71567eccd82ebb51035b7fda9e6 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:06:17 -0400 Subject: [PATCH 12/45] Fix color typing in arcade.Text --- arcade/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/text.py b/arcade/text.py index 928bccf92c..f276f49c41 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -386,7 +386,7 @@ def color(self) -> Color: """ Get or set the text color for the label """ - return self._label.color + return Color.from_iterable(self._label.color) @color.setter def color(self, color: RGBOrA255): From 7af7363ffb40db5b616238b09836f5b7cf15e505 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:16:29 -0400 Subject: [PATCH 13/45] Ignore over-strict pyright Literal opinion --- arcade/text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/text.py b/arcade/text.py index f276f49c41..6a478432d3 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -217,7 +217,7 @@ def __init__( anchor_y=anchor_y, # type: ignore color=Color.from_iterable(color), width=width, - align=align, + align=align, # type: ignore bold=bold, italic=italic, multiline=multiline, From 35f219fa83a2d1a15f58d6cad117316b73f401c0 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:32:31 -0400 Subject: [PATCH 14/45] Attempt to patch up the font loader --- arcade/text.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arcade/text.py b/arcade/text.py index 6a478432d3..51b308135f 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -45,9 +45,8 @@ def load_font(path: Union[str, Path]) -> None: FontNameOrNames = Union[str, tuple[str, ...]] -def _attempt_font_name_resolution(font_name: FontNameOrNames) -> FontNameOrNames: - """ - Attempt to resolve a tuple of font names. +def _attempt_font_name_resolution(font_name: FontNameOrNames) -> str: + """Attempt to resolve a font name. Preserves the original logic of this section, even though it doesn't seem to make sense entirely. Comments are an attempt @@ -83,8 +82,12 @@ def _attempt_font_name_resolution(font_name: FontNameOrNames) -> FontNameOrNames except FileNotFoundError: pass - # failed to find it ourselves, hope pyglet can make sense of it - return font_name + # failed to find it ourselves, hope pyglet can make sense of it + # Note this is the best approximation of what I unerstand the old + # behavior to have been. + return pyglet.font.load(font_list).name + + raise ValueError(f"Couldn't find a font for {font_name!r}") def _draw_pyglet_label(label: pyglet.text.Label) -> None: @@ -204,6 +207,7 @@ def __init__( ) adjusted_font = _attempt_font_name_resolution(font_name) + self._label = pyglet.text.Label( text=text, # pyglet is lying about what it takes here and float is entirely valid From 8ab09754cc36fad36d1ea11367b06741e791085e Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:43:01 -0400 Subject: [PATCH 15/45] Use new-style | None in application.Window.__init__ --- arcade/application.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 614bd848ea..3cea48290c 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -132,14 +132,14 @@ def __init__( self, width: int = 1280, height: int = 720, - title: Optional[str] = "Arcade Window", + title: str | None = "Arcade Window", fullscreen: bool = False, resizable: bool = False, update_rate: float = 1 / 60, antialiasing: bool = True, gl_version: tuple[int, int] = (3, 3), - screen: Optional[pyglet.display.Screen] = None, - style: Optional[str] = pyglet.window.Window.WINDOW_STYLE_DEFAULT, + screen: pyglet.display.Screen | None = None, + style: str | None = pyglet.window.Window.WINDOW_STYLE_DEFAULT, visible: bool = True, vsync: bool = False, gc_mode: str = "context_gc", @@ -149,7 +149,7 @@ def __init__( gl_api: str = "gl", draw_rate: float = 1 / 60, fixed_rate: float = 1.0 / 60.0, - fixed_frame_cap: Optional[int] = None, + fixed_frame_cap: int | None = None, ) -> None: # In certain environments we can't have antialiasing/MSAA enabled. # Detect replit environment From 482e7ca0eb1d42878872a650356cc7d3f4509563 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:51:06 -0400 Subject: [PATCH 16/45] Update some typing for set_fullscreen * Use new-style | None * Add casting and TODO on resolving screen coord issues upstream * Mention rounding issue in set_fullscreen --- arcade/application.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 3cea48290c..7b04e59728 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -412,10 +412,10 @@ def close(self) -> None: def set_fullscreen( self, fullscreen: bool = True, - screen: Optional["Window"] = None, - mode: Optional[ScreenMode] = None, - width: Optional[int] = None, - height: Optional[int] = None, + screen: pyglet.window.Window | None = None, + mode: ScreenMode | None = None, + width: float | None = None, + height: float | None = None, ) -> None: """ Change the fullscreen status of the window. @@ -442,6 +442,13 @@ def set_fullscreen( height (int, optional): Override the height of the window """ super().set_fullscreen(fullscreen, screen, mode, width, height) + # fmt: off + super().set_fullscreen( + fullscreen, screen, mode, + # TODO: resolve the upstream int / float screen coord issue + None if width is None else int(width), + None if height is None else int(height)) + # fmt: on def center_window(self) -> None: """Center the window on your desktop.""" From 497dadbdba85132acbfd595fdda25ef4d58b154b Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:55:19 -0400 Subject: [PATCH 17/45] Add temporary type ignore for font_size --- arcade/text.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arcade/text.py b/arcade/text.py index 51b308135f..688b3464f4 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -215,7 +215,8 @@ def __init__( y=y, # type: ignore z=z, # type: ignore font_name=adjusted_font, - font_size=font_size, + # TODO: Fix this upstream (Mac & Linux seem to allow float) + font_size=font_size, # type: ignore # use type: ignore since cast is slow & pyglet used Literal anchor_x=anchor_x, # type: ignore anchor_y=anchor_y, # type: ignore From 5bb81c6aa77022c7d8fe4097f34636b19da34ddf Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sun, 7 Jul 2024 11:03:34 -0400 Subject: [PATCH 18/45] Update type + doc for arcade.text bold support * Update top-level docstring * Update bold setter & getter * Update bold return types --- arcade/text.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/arcade/text.py b/arcade/text.py index 688b3464f4..789331eda3 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -135,7 +135,8 @@ class Text: :param width: A width limit in pixels :param align: Horizontal alignment; values other than "left" require width to be set :param Union[str, tuple[str, ...]] font_name: A font name, path to a font file, or list of names - :param bold: Whether to draw the text as bold + :param bold: Whether to draw the text as bold, and if a string, + how bold. See :py:attr:`.bold` to learn more. :param italic: Whether to draw the text as italic :param anchor_x: How to calculate the anchor point's x coordinate. Options: "left", "center", or "right" @@ -184,7 +185,7 @@ def __init__( width: int | None = None, align: str = "left", font_name: FontNameOrNames = ("calibri", "arial"), - bold: bool = False, + bold: bool | str = False, italic: bool = False, anchor_x: str = "left", anchor_y: str = "baseline", @@ -490,14 +491,23 @@ def align(self, align: str): self._label.set_style("align", align) @property - def bold(self) -> bool: + def bold(self) -> bool | str: """ - Get or set bold state of the label + Get or set bold state of the label. + + The supported values include: + + * ``"black"`` + * ``"bold" (same as ``True``) + * ``"semibold"`` + * ``"semilight"`` + * ``"light"`` + """ return self._label.bold @bold.setter - def bold(self, bold: bool): + def bold(self, bold: bool | str): self._label.bold = bold @property @@ -593,7 +603,7 @@ def create_text_sprite( width: int | None = None, align: str = "left", font_name: FontNameOrNames = ("calibri", "arial"), - bold: bool = False, + bold: bool | str = False, italic: bool = False, anchor_x: str = "left", multiline: bool = False, @@ -684,7 +694,7 @@ def draw_text( width: int | None = None, align: str = "left", font_name: FontNameOrNames = ("calibri", "arial"), - bold: bool = False, + bold: bool | str = False, italic: bool = False, anchor_x: str = "left", anchor_y: str = "baseline", @@ -724,7 +734,8 @@ def draw_text( :param width: A width limit in pixels :param align: Horizontal alignment; values other than "left" require width to be set :param Union[str, tuple[str, ...]] font_name: A font name, path to a font file, or list of names - :param bold: Whether to draw the text as bold + :param bold: Whether to draw the text as bold, and if a :py:class:`str`, + how bold to draw it. See :py:attr:`.Text.bold` to learn more. :param italic: Whether to draw the text as italic :param anchor_x: How to calculate the anchor point's x coordinate :param anchor_y: How to calculate the anchor point's y coordinate From 323645dfb47dedb65e41cb5bf474eb9b153340fa Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 9 Jul 2024 03:05:51 -0400 Subject: [PATCH 19/45] Temporarily use pyglet development branch directly * Use development pyglet in rolling release mode + comment it * Add commented-out future pyglet == 2.1dev4 release we can swap to it later --- pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2753c750f8..583e72f2cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,11 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ - "pyglet == 2.1dev3", + # Use pyglet's development branch as a rolling release package + # at the cost of slow download and constant pip install -I -e .[dev] + "pyglet@git+https://github.com/pyglet/pyglet.git@development#egg=pyglet", + # Expected future dev preview release on PyPI (not yet released) + # pyglet == 2.1dev4 "pillow~=10.2.0", "pymunk~=6.6.0", "pytiled-parser~=2.2.5", From 25bdf04fb2564ab08d9bd17e36d38229582d7d87 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 9 Jul 2024 04:53:44 -0400 Subject: [PATCH 20/45] Formatting --- arcade/sound.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arcade/sound.py b/arcade/sound.py index 698b537da7..cb67d97b8e 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -38,9 +38,7 @@ def __init__(self, file_name: Union[str, Path], streaming: bool = False): raise FileNotFoundError(f"The sound file '{file_name}' is not a file or can't be read.") self.file_name = str(file_name) - self.source: Source = media.load( - self.file_name, streaming=streaming - ) + self.source: Source = media.load(self.file_name, streaming=streaming) if self.source.duration is None: raise ValueError( From f7f16d7947aa6575d039b5b3c4d52e17ed9df260 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:45:21 -0400 Subject: [PATCH 21/45] Use newly released pyglet==2.1dev4 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 583e72f2cf..fbb0f2cc65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,11 +19,11 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ - # Use pyglet's development branch as a rolling release package + # Fallback to use pyglet's development branch as a rolling release package # at the cost of slow download and constant pip install -I -e .[dev] - "pyglet@git+https://github.com/pyglet/pyglet.git@development#egg=pyglet", + #"pyglet@git+https://github.com/pyglet/pyglet.git@development#egg=pyglet", # Expected future dev preview release on PyPI (not yet released) - # pyglet == 2.1dev4 + 'pyglet == 2.1dev4', "pillow~=10.2.0", "pymunk~=6.6.0", "pytiled-parser~=2.2.5", From f312be0ce34871af9c181d85d3fcbedb3121c5ab Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:16:03 -0400 Subject: [PATCH 22/45] Projection funcs: remove inner tuple for Mat4 init --- arcade/camera/projection_functions.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arcade/camera/projection_functions.py b/arcade/camera/projection_functions.py index 25d648c76c..2d7dc2b1b1 100644 --- a/arcade/camera/projection_functions.py +++ b/arcade/camera/projection_functions.py @@ -27,12 +27,12 @@ def generate_view_matrix(camera_data: CameraData) -> Mat4: po = Vec3(*camera_data.position) # fmt: off - return Mat4(( + return Mat4( ri.x, up.x, -fo.x, 0.0, ri.y, up.y, -fo.y, 0.0, ri.z, up.z, -fo.z, 0.0, -ri.dot(po), -up.dot(po), fo.dot(po), 1.0 - )) + ) # fmt: on @@ -69,12 +69,12 @@ def generate_orthographic_matrix( tz = -(z_far + z_near) / depth # fmt: off - return Mat4(( + return Mat4( sx, 0.0, 0.0, 0.0, 0.0, sy, 0.0, 0.0, 0.0, 0.0, sz, 0.0, tx, ty, tz, 1.0 - )) + ) # fmt: on @@ -110,12 +110,12 @@ def generate_perspective_matrix( h = 2 * z_near / height # fmt: off - return Mat4(( + return Mat4( w, 0, 0, 0, 0, h, 0, 0, 0, 0, q, -1, 0, 0, qn, 0 - )) + ) # fmt: on From 70a70ca4132d838ea2cf8c51d2472d53e433497a Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:17:06 -0400 Subject: [PATCH 23/45] add dot to pyproject.toml (no idea why pip resolves that) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fbb0f2cc65..f654b800c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ dependencies = [ # at the cost of slow download and constant pip install -I -e .[dev] #"pyglet@git+https://github.com/pyglet/pyglet.git@development#egg=pyglet", # Expected future dev preview release on PyPI (not yet released) - 'pyglet == 2.1dev4', + 'pyglet == 2.1.dev4', "pillow~=10.2.0", "pymunk~=6.6.0", "pytiled-parser~=2.2.5", From 06cae35ee5b8914c3ed7c2f651e334d2d364f0a0 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:20:58 -0400 Subject: [PATCH 24/45] Use Vec3 for now in perspective example --- arcade/examples/perspective.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arcade/examples/perspective.py b/arcade/examples/perspective.py index 315c7e62a3..63dea6f7a6 100644 --- a/arcade/examples/perspective.py +++ b/arcade/examples/perspective.py @@ -18,7 +18,7 @@ from array import array import arcade -from pyglet.math import Mat4 +from pyglet.math import Mat4, Vec3 from arcade.gl import BufferDescription @@ -121,8 +121,8 @@ def on_draw(self): self.fbo.color_attachments[0].use(unit=0) # Move the plane into camera view and rotate it - translate = Mat4.from_translation((0, 0, -2)) - rotate = Mat4.from_rotation(self.time / 2, (1, 0, 0)) + translate = Mat4.from_translation(Vec3(0, 0, -2)) + rotate = Mat4.from_rotation(self.time / 2, Vec3(1, 0, 0)) self.program["model"] = translate @ rotate # Scroll the texture coordinates From 97eb731d58f95d20f29f8edd22119afedf65b347 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:25:50 -0400 Subject: [PATCH 25/45] Centralize headless + add some type: ignore * Centralize headless * Add some type: ignore since pyglet did vague .pyi --- arcade/__init__.py | 17 +++++++++++------ arcade/application.py | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index c4f46c7318..176ff295cb 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -10,7 +10,7 @@ # Error out if we import Arcade with an incompatible version of Python. import sys import os -from typing import Optional +from typing import Optional, Final from pathlib import Path @@ -58,15 +58,20 @@ def configure_logging(level: Optional[int] = None): # noinspection PyPep8 import pyglet + # Env variable shortcut for headless mode -if os.environ.get("ARCADE_HEADLESS"): - pyglet.options.headless = True +headless: Final[bool] = bool(os.environ.get("ARCADE_HEADLESS")) +if headless: + # TODO: fix once pyglet/__init__.pyi is fixed + pyglet.options.headless = headless # type: ignore + from arcade import utils # Disable shadow window on macs and in headless mode. if sys.platform == "darwin" or os.environ.get("ARCADE_HEADLESS") or utils.is_raspberry_pi(): - pyglet.options.shadow_window = False + # TODO: fix once pyglet/__init__.pyi is fixed + pyglet.options.shadow_window = False # type: ignore # Use the old gdi fonts on windows until directwrite is fast/stable # pyglet.options.win32_gdi_font = True @@ -141,7 +146,7 @@ def configure_logging(level: Optional[int] = None): from .screenshot import get_pixel # We don't have joysticks game controllers in headless mode -if not pyglet.options.headless: +if not headless: # type: ignore from .joysticks import get_game_controllers from .joysticks import get_joysticks from .controller import ControllerManager @@ -396,7 +401,7 @@ def configure_logging(level: Optional[int] = None): # Piggyback on pyglet's doc run detection if not getattr(sys, "is_pyglet_doc_run", False): # Load additional game controller mappings to Pyglet - if not pyglet.options.headless: + if not arcade.headless: try: import pyglet.input.controller diff --git a/arcade/application.py b/arcade/application.py index 7b04e59728..6ae8cf9ed7 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -161,7 +161,7 @@ def __init__( gl_version = 3, 1 gl_api = "gles" - self.headless: bool = pyglet.options.get("headless") is True + self.headless: bool = arcade.headless """If True, the window is running in headless mode.""" config = None @@ -291,7 +291,7 @@ def __init__( if enable_polling: self.keyboard = pyglet.window.key.KeyStateHandler() - if pyglet.options.headless: + if arcade.headless: self.push_handlers(self.keyboard) else: From 7a5d8338cda30d4abd41b0b5b8fec0a63a3caa79 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:32:13 -0400 Subject: [PATCH 26/45] type: ignore in sound.py --- arcade/sound.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arcade/sound.py b/arcade/sound.py index cb67d97b8e..426d745900 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -16,9 +16,11 @@ from arcade.resources import resolve if os.environ.get("ARCADE_SOUND_BACKENDS"): - pyglet.options.audio = tuple(v.strip() for v in os.environ["ARCADE_SOUND_BACKENDS"].split(",")) + pyglet.options.audio = tuple( # type: ignore + v.strip() for v in os.environ["ARCADE_SOUND_BACKENDS"].split(",")) else: - pyglet.options.audio = ("openal", "xaudio2", "directsound", "pulse", "silent") + pyglet.options.audio = ( # type: ignore + "openal", "xaudio2", "directsound", "pulse", "silent") import pyglet.media as media From 435f5d7c9f71d1ebca3ae96ca619f8985f6cc26a Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:34:04 -0400 Subject: [PATCH 27/45] Whoops, forgot what file I'm in --- arcade/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index 176ff295cb..73a6a61d79 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -401,7 +401,7 @@ def configure_logging(level: Optional[int] = None): # Piggyback on pyglet's doc run detection if not getattr(sys, "is_pyglet_doc_run", False): # Load additional game controller mappings to Pyglet - if not arcade.headless: + if not headless: try: import pyglet.input.controller From e72f2d22868bb8e3c0d22e8fadc0e1400b4f41a4 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:46:11 -0400 Subject: [PATCH 28/45] Replace todo with # type: ignore # pending syntax --- arcade/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index 73a6a61d79..52dff868df 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -62,16 +62,14 @@ def configure_logging(level: Optional[int] = None): # Env variable shortcut for headless mode headless: Final[bool] = bool(os.environ.get("ARCADE_HEADLESS")) if headless: - # TODO: fix once pyglet/__init__.pyi is fixed - pyglet.options.headless = headless # type: ignore + pyglet.options.headless = headless # type: ignore # pending https://github.com/pyglet/pyglet/issues/1164 from arcade import utils # Disable shadow window on macs and in headless mode. if sys.platform == "darwin" or os.environ.get("ARCADE_HEADLESS") or utils.is_raspberry_pi(): - # TODO: fix once pyglet/__init__.pyi is fixed - pyglet.options.shadow_window = False # type: ignore + pyglet.options.shadow_window = False # type: ignore # pending https://github.com/pyglet/pyglet/issues/1164 # Use the old gdi fonts on windows until directwrite is fast/stable # pyglet.options.win32_gdi_font = True From a1a1225e00dda8189b16447084b7cd2342f858c9 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:50:57 -0400 Subject: [PATCH 29/45] Awful temp fix for Text.font_name --- arcade/text.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arcade/text.py b/arcade/text.py index 789331eda3..5ef612f28d 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -336,11 +336,17 @@ def font_name(self) -> FontNameOrNames: """ Get or set the font name(s) for the label """ - return self._label.font_name + if not isinstance(self._label.font_name, str): + return tuple(self._label.font_name) + else: + return self._label.font_name @font_name.setter def font_name(self, font_name: FontNameOrNames) -> None: - self._label.font_name = font_name + if isinstance(font_name, str): + self._label.font_name = font_name + else: + self._label.font_name = list(font_name) @property def font_size(self) -> float: From 7a4d3d660cfbeeba48aa9bff271bfd273c576aad Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 05:53:47 -0400 Subject: [PATCH 30/45] Formatting for sound --- arcade/sound.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arcade/sound.py b/arcade/sound.py index 426d745900..a0d363b117 100644 --- a/arcade/sound.py +++ b/arcade/sound.py @@ -17,10 +17,10 @@ if os.environ.get("ARCADE_SOUND_BACKENDS"): pyglet.options.audio = tuple( # type: ignore - v.strip() for v in os.environ["ARCADE_SOUND_BACKENDS"].split(",")) + v.strip() for v in os.environ["ARCADE_SOUND_BACKENDS"].split(",") + ) else: - pyglet.options.audio = ( # type: ignore - "openal", "xaudio2", "directsound", "pulse", "silent") + pyglet.options.audio = ("openal", "xaudio2", "directsound", "pulse", "silent") # type: ignore import pyglet.media as media From ac9c046dffb8f40d37ca012c7fc58c02f9584422 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 06:10:58 -0400 Subject: [PATCH 31/45] Abomination of a test fix --- tests/unit/test_arcade.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_arcade.py b/tests/unit/test_arcade.py index e64c08291e..c4d826fed4 100644 --- a/tests/unit/test_arcade.py +++ b/tests/unit/test_arcade.py @@ -2,6 +2,7 @@ from copy import copy import logging import arcade +import inspect from arcade import * @@ -16,9 +17,13 @@ def test_import(): remaining = arcade_names - common for name in copy(remaining): attr = getattr(arcade, name) - if type(attr) is ModuleType: + if type(attr) is ModuleType or not inspect.isroutine(attr): remaining.remove(name) - elif not attr.__module__.startswith('arcade.'): + # Extra awful trick because: + # 1. attempting to get __module__ of bool members raises AttributeError + # 2. inspect.isbuiltin(bool) does not return True for bool + # 2. inspect.getmodule(bool) returns the builtins module + elif not inspect.getmodule(attr).__name__.startswith('arcade.'): remaining.remove(name) assert len(remaining) == 0 From 20ac3138aaec03b9132b2afe5e05458d4535fe36 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 06:11:49 -0400 Subject: [PATCH 32/45] Import sorting for arcade/__init__.py --- arcade/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/__init__.py b/arcade/__init__.py index 52dff868df..ad401effbd 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -10,7 +10,7 @@ # Error out if we import Arcade with an incompatible version of Python. import sys import os -from typing import Optional, Final +from typing import Final, Optional from pathlib import Path From 5056d91c18e148887bcdc32f05975c59ecbfaaf3 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Sat, 13 Jul 2024 06:26:32 -0400 Subject: [PATCH 33/45] Revert "Abomination of a test fix" (Test not actually fixed) This reverts commit c59d674c7aefc08cd1aee20eda24d20b598ac890. --- tests/unit/test_arcade.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/unit/test_arcade.py b/tests/unit/test_arcade.py index c4d826fed4..e64c08291e 100644 --- a/tests/unit/test_arcade.py +++ b/tests/unit/test_arcade.py @@ -2,7 +2,6 @@ from copy import copy import logging import arcade -import inspect from arcade import * @@ -17,13 +16,9 @@ def test_import(): remaining = arcade_names - common for name in copy(remaining): attr = getattr(arcade, name) - if type(attr) is ModuleType or not inspect.isroutine(attr): + if type(attr) is ModuleType: remaining.remove(name) - # Extra awful trick because: - # 1. attempting to get __module__ of bool members raises AttributeError - # 2. inspect.isbuiltin(bool) does not return True for bool - # 2. inspect.getmodule(bool) returns the builtins module - elif not inspect.getmodule(attr).__name__.startswith('arcade.'): + elif not attr.__module__.startswith('arcade.'): remaining.remove(name) assert len(remaining) == 0 From 9a85152c13095fa3f51e11afa0c737ae8698c71f Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Thu, 18 Jul 2024 05:13:17 -0400 Subject: [PATCH 34/45] Maybe fix the import test? --- tests/unit/test_arcade.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_arcade.py b/tests/unit/test_arcade.py index e64c08291e..56e05ac4a0 100644 --- a/tests/unit/test_arcade.py +++ b/tests/unit/test_arcade.py @@ -5,6 +5,10 @@ from arcade import * +# TODO: double-check whether this is actually the right solution? +builtin_types = frozenset((bool, str, int, ModuleType)) + + def test_import(): """Compare arcade.__all__ to the actual module contents""" import arcade @@ -16,7 +20,8 @@ def test_import(): remaining = arcade_names - common for name in copy(remaining): attr = getattr(arcade, name) - if type(attr) is ModuleType: + attr_type = type(attr) + if attr_type in builtin_types: remaining.remove(name) elif not attr.__module__.startswith('arcade.'): remaining.remove(name) From 33dc54f5cf4701ac0401507fe3e967d87628067d Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Thu, 18 Jul 2024 05:25:27 -0400 Subject: [PATCH 35/45] Temp fix for pyglet typing all things as float for some reason --- arcade/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/application.py b/arcade/application.py index 6ae8cf9ed7..fc9637d837 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -171,7 +171,7 @@ def __init__( config = pyglet.gl.Config( major_version=gl_version[0], minor_version=gl_version[1], - opengl_api=gl_api, + opengl_api=gl_api, # type: ignore # pending: upstream fix double_buffer=True, sample_buffers=1, samples=samples, From aa117eb87c82c72b3407b5b1ec951ff591174a0a Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Thu, 18 Jul 2024 05:27:59 -0400 Subject: [PATCH 36/45] Fix another instance of pyglet making everything a float --- arcade/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/application.py b/arcade/application.py index fc9637d837..619597ad83 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -195,7 +195,7 @@ def __init__( config = pyglet.gl.Config( major_version=gl_version[0], minor_version=gl_version[1], - opengl_api=gl_api, + opengl_api=gl_api, # type: ignore # pending: upstream fix double_buffer=True, depth_size=24, stencil_size=8, From d659c842f329d0293dc5f722d8d7847724eef041 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Thu, 18 Jul 2024 05:32:32 -0400 Subject: [PATCH 37/45] Out of patience for pyglet import / metaclass / method resolution --- arcade/application.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 619597ad83..50b3e7d13a 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -215,9 +215,10 @@ def __init__( visible=visible, style=style, ) - self.register_event_type("on_update") - self.register_event_type("on_action") - self.register_event_type("on_fixed_update") + # pending: weird import tricks resolved + self.register_event_type("on_update") # type: ignore + self.register_event_type("on_action") # type: ignore + self.register_event_type("on_fixed_update") # type: ignore except pyglet.window.NoSuchConfigException: raise NoOpenGLException( "Unable to create an OpenGL 3.3+ context. " From 75d9871f19d65d408dbcaac564180d4126f071d0 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Thu, 18 Jul 2024 05:35:41 -0400 Subject: [PATCH 38/45] Fix rebase issue in casting --- arcade/application.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 50b3e7d13a..8877db47bf 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -439,10 +439,11 @@ def set_fullscreen( have been obtained by enumerating `Screen.get_modes`. If None, an appropriate mode will be selected from the given `width` and `height`. - width (int, optional): Override the width of the window - height (int, optional): Override the height of the window + width: Override the width of the window. Will be rounded to + :py:attr:`int`. + height: Override the height of the window. Will be rounded to + :py:attr:`int`. """ - super().set_fullscreen(fullscreen, screen, mode, width, height) # fmt: off super().set_fullscreen( fullscreen, screen, mode, From bd3b7d9bdf63cf91ebccaed368f58fcd0a3378d8 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Thu, 18 Jul 2024 05:39:04 -0400 Subject: [PATCH 39/45] Type ignore window issues --- arcade/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/application.py b/arcade/application.py index 8877db47bf..a7bbf917f0 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -183,7 +183,7 @@ def __init__( alpha_size=8, ) display = pyglet.display.get_display() - screen = display.get_default_screen() + screen = display.get_default_screen() # type: ignore # pending: resolve upstream type tricks if screen: config = screen.get_best_config(config) except pyglet.window.NoSuchConfigException: From fdee4d143a8c9fbbd2eb6ae805c4cce2d9bb393e Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 18 Jul 2024 12:02:00 +0200 Subject: [PATCH 40/45] Tweak pyproject.toml --- pyproject.toml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f654b800c1..27378db38e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,10 +20,10 @@ classifiers = [ ] dependencies = [ # Fallback to use pyglet's development branch as a rolling release package - # at the cost of slow download and constant pip install -I -e .[dev] - #"pyglet@git+https://github.com/pyglet/pyglet.git@development#egg=pyglet", + # at the cost of slow download and constant pip install -I -e .[dev] + # "pyglet@git+https://github.com/pyglet/pyglet.git@development#egg=pyglet", # Expected future dev preview release on PyPI (not yet released) - 'pyglet == 2.1.dev4', + 'pyglet==2.1.dev4', "pillow~=10.2.0", "pymunk~=6.6.0", "pytiled-parser~=2.2.5", @@ -42,14 +42,14 @@ Book = "https://learn.arcade.academy" # Used for dev work dev = [ # --- Documentation: Sphinx 7 based currently - "sphinx==7.3.7", # April 2024 | Updated 2024-07-15, 7.4+ is broken with sphinx-autobuild - "sphinx_rtd_theme==2.0.0", # Nov 2023 + "sphinx==7.3.7", # April 2024 | Updated 2024-07-15, 7.4+ is broken with sphinx-autobuild + "sphinx_rtd_theme==2.0.0", # Nov 2023 "sphinx-rtd-dark-mode==1.3.0", - "sphinx-autobuild==2024.4.16", # April 2024 | Due to this, Python 3.10+ is required to serve docs - "sphinx-copybutton==0.5.2", # April 2023 - "sphinx-sitemap==2.6.0", # April 2024 - "pygments==2.17.2", # 2.18 has breaking changes in lexer - "docutils==0.20.1", # ? + "sphinx-autobuild==2024.4.16", # April 2024 | Due to this, Python 3.10+ is required to serve docs + "sphinx-copybutton==0.5.2", # April 2023 + "sphinx-sitemap==2.6.0", # April 2024 + "pygments==2.17.2", # 2.18 has breaking changes in lexer + "docutils==0.20.1", # ? # "pyyaml==6.0.1", # "readthedocs-sphinx-search==0.3.2", # "sphinx-autodoc-typehints==2.0.1", @@ -58,12 +58,12 @@ dev = [ "pytest-cov", "pytest-mock", "coverage", - "coveralls", # Do we really need this? + "coveralls", # Do we really need this? "black", "ruff", "mypy", - "pyright==1.1.355", - "typer[all]==0.11.0", # Needed for make.py + "pyright==1.1.355", + "typer[all]==0.11.0", # Needed for make.py "wheel", ] # Testing only From a592e973682f18ce0f984f4ce941453274316a3c Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 18 Jul 2024 12:58:13 +0200 Subject: [PATCH 41/45] Ignore pyglet Window type The class is dynamically assigned at runtime so pyright can't handle it. --- arcade/gl/context.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arcade/gl/context.py b/arcade/gl/context.py index 57945a93ed..7e1da7adac 100644 --- a/arcade/gl/context.py +++ b/arcade/gl/context.py @@ -183,7 +183,9 @@ class Context: _valid_apis = ("gl", "gles") def __init__( - self, window: pyglet.window.Window, gc_mode: str = "context_gc", gl_api: str = "gl" + self, window: pyglet.window.Window, # type: ignore + gc_mode: str = "context_gc", + gl_api: str = "gl", ): self._window_ref = weakref.ref(window) if gl_api not in self._valid_apis: From 2d073c21d34c21072024c0c7072a3c162ab11799 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 18 Jul 2024 13:01:33 +0200 Subject: [PATCH 42/45] Wrong typing for screen --- arcade/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arcade/application.py b/arcade/application.py index a7bbf917f0..93f3a2e9e4 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -413,7 +413,7 @@ def close(self) -> None: def set_fullscreen( self, fullscreen: bool = True, - screen: pyglet.window.Window | None = None, + screen=None, mode: ScreenMode | None = None, width: float | None = None, height: float | None = None, From 8700c3da9e5c39004963e2ef4815d9c535399d28 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 18 Jul 2024 13:05:50 +0200 Subject: [PATCH 43/45] format issue --- arcade/gl/context.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arcade/gl/context.py b/arcade/gl/context.py index 7e1da7adac..b540937c49 100644 --- a/arcade/gl/context.py +++ b/arcade/gl/context.py @@ -183,7 +183,8 @@ class Context: _valid_apis = ("gl", "gles") def __init__( - self, window: pyglet.window.Window, # type: ignore + self, + window: pyglet.window.Window, # type: ignore gc_mode: str = "context_gc", gl_api: str = "gl", ): From 389143f29ef6e8e2d4ff92926e490b932697246a Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 18 Jul 2024 13:10:49 +0200 Subject: [PATCH 44/45] Bump pyright --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 27378db38e..8386e0e030 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ dev = [ "black", "ruff", "mypy", - "pyright==1.1.355", + "pyright==1.1.372", "typer[all]==0.11.0", # Needed for make.py "wheel", ] From e048b63498078f2820284df6e42850434cd7938d Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 18 Jul 2024 13:51:15 +0200 Subject: [PATCH 45/45] Temp ignore EventDispatcher issue --- arcade/context.py | 5 ++++- arcade/gui/constructs.py | 4 ++-- arcade/gui/ui_manager.py | 2 +- arcade/gui/widgets/__init__.py | 6 +++--- arcade/gui/widgets/dropdown.py | 2 +- arcade/gui/widgets/slider.py | 2 +- arcade/gui/widgets/toggle.py | 2 +- arcade/text.py | 2 +- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/arcade/context.py b/arcade/context.py index f59c861207..dbb8e83958 100644 --- a/arcade/context.py +++ b/arcade/context.py @@ -48,7 +48,10 @@ class ArcadeContext(Context): atlas_size: tuple[int, int] = 512, 512 def __init__( - self, window: pyglet.window.Window, gc_mode: str = "context_gc", gl_api: str = "gl" + self, + window: pyglet.window.Window, # type: ignore + gc_mode: str = "context_gc", + gl_api: str = "gl", ) -> None: super().__init__(window, gc_mode=gc_mode, gl_api=gl_api) diff --git a/arcade/gui/constructs.py b/arcade/gui/constructs.py index ccd218a80c..75899f399d 100644 --- a/arcade/gui/constructs.py +++ b/arcade/gui/constructs.py @@ -46,7 +46,7 @@ def __init__( raise ValueError("At least a single value has to be available for `buttons`") super().__init__(size_hint=(1, 1)) - self.register_event_type("on_action") + self.register_event_type("on_action") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa space = 20 @@ -136,7 +136,7 @@ def __init__( space_between=space_between, style=style, ) - self.register_event_type("on_action") + self.register_event_type("on_action") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa self.button_factory = button_factory diff --git a/arcade/gui/ui_manager.py b/arcade/gui/ui_manager.py index 4005fbe62b..2c263dbb63 100644 --- a/arcade/gui/ui_manager.py +++ b/arcade/gui/ui_manager.py @@ -99,7 +99,7 @@ def __init__(self, window: Optional[arcade.Window] = None): self._render_to_surface_camera = arcade.Camera2D() # this camera is used for rendering the UI and should not be changed by the user - self.register_event_type("on_event") + self.register_event_type("on_event") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa def add(self, widget: W, *, index=None, layer=0) -> W: """ diff --git a/arcade/gui/widgets/__init__.py b/arcade/gui/widgets/__init__.py index ef38d6261e..495ac3d31f 100644 --- a/arcade/gui/widgets/__init__.py +++ b/arcade/gui/widgets/__init__.py @@ -99,8 +99,8 @@ def __init__( self.size_hint_min = size_hint_min self.size_hint_max = size_hint_max - self.register_event_type("on_event") - self.register_event_type("on_update") + self.register_event_type("on_event") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa + self.register_event_type("on_update") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa for child in children: self.add(child) @@ -516,7 +516,7 @@ def __init__( size_hint_max=size_hint_max, **kwargs, ) - self.register_event_type("on_click") + self.register_event_type("on_click") # type: ignore self.interaction_buttons = interaction_buttons diff --git a/arcade/gui/widgets/dropdown.py b/arcade/gui/widgets/dropdown.py index 8eca4449c8..3719d7e37a 100644 --- a/arcade/gui/widgets/dropdown.py +++ b/arcade/gui/widgets/dropdown.py @@ -100,7 +100,7 @@ def __init__( # add children after super class setup self.add(self._default_button) - self.register_event_type("on_change") + self.register_event_type("on_change") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa self.with_border(color=arcade.color.RED) diff --git a/arcade/gui/widgets/slider.py b/arcade/gui/widgets/slider.py index 185d3edf5f..d20a60d28f 100644 --- a/arcade/gui/widgets/slider.py +++ b/arcade/gui/widgets/slider.py @@ -76,7 +76,7 @@ def __init__( bind(self, "pressed", self.trigger_render) bind(self, "disabled", self.trigger_render) - self.register_event_type("on_change") + self.register_event_type("on_change") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa def _x_for_value(self, value: float): """Provides the x coordinate for the given value.""" diff --git a/arcade/gui/widgets/toggle.py b/arcade/gui/widgets/toggle.py index 647c712a2c..150658a36c 100644 --- a/arcade/gui/widgets/toggle.py +++ b/arcade/gui/widgets/toggle.py @@ -72,7 +72,7 @@ def __init__( ) self.value = value - self.register_event_type("on_change") + self.register_event_type("on_change") # type: ignore # https://github.com/pyglet/pyglet/pull/1173 # noqa bind(self, "value", self.trigger_render) bind(self, "value", self._dispatch_on_change_event) diff --git a/arcade/text.py b/arcade/text.py index 5ef612f28d..f662b376fb 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -517,7 +517,7 @@ def bold(self, bold: bool | str): self._label.bold = bold @property - def italic(self) -> bool: + def italic(self) -> bool | str: """ Get or set the italic state of the label """