diff --git a/arcade/__init__.py b/arcade/__init__.py index 1e63ccbb1..7caa51249 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -395,6 +395,7 @@ def configure_logging(level: Optional[int] = None): # Load additional game controller mappings to Pyglet if not pyglet.options['headless']: try: + import pyglet.input.controller mappings_file = resources.resolve(":system:gamecontrollerdb.txt") pyglet.input.controller.add_mappings_from_file(mappings_file) except AssertionError: diff --git a/arcade/application.py b/arcade/application.py index a9fdf075b..e2d96fc8a 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -10,6 +10,7 @@ import pyglet import pyglet.gl as gl +import pyglet.window.mouse from pyglet.canvas.base import ScreenMode import arcade diff --git a/arcade/gl/context.py b/arcade/gl/context.py index 01be837c7..25b1d4b08 100644 --- a/arcade/gl/context.py +++ b/arcade/gl/context.py @@ -875,7 +875,7 @@ def texture( data: Optional[BufferProtocol] = None, wrap_x: Optional[PyGLenum] = None, wrap_y: Optional[PyGLenum] = None, - filter: Optional[Tuple[GLenumLike, GLenumLike]] = None, + filter: Optional[Tuple[PyGLenum, PyGLenum]] = None, samples: int = 0, immutable: bool = False, ) -> Texture2D: diff --git a/arcade/gl/texture.py b/arcade/gl/texture.py index 685e8ca81..f43c40039 100644 --- a/arcade/gl/texture.py +++ b/arcade/gl/texture.py @@ -114,7 +114,7 @@ def __init__( components: int = 4, dtype: str = "f1", data: Optional[BufferProtocol] = None, - filter: Optional[Tuple[gl.GLuint, gl.GLuint]] = None, + filter: Optional[Tuple[PyGLuint, PyGLuint]] = None, wrap_x: Optional[PyGLuint] = None, wrap_y: Optional[PyGLuint] = None, target=gl.GL_TEXTURE_2D, diff --git a/arcade/gl/vertex_array.py b/arcade/gl/vertex_array.py index 2c8ffb030..e1e538b4e 100644 --- a/arcade/gl/vertex_array.py +++ b/arcade/gl/vertex_array.py @@ -593,7 +593,7 @@ def render_indirect( program: Program, buffer: Buffer, *, - mode: Optional[gl.GLuint] = None, + mode: Optional[GLuintLike] = None, count: int = -1, first: int = 0, stride: int = 0, diff --git a/arcade/gui/widgets/dropdown.py b/arcade/gui/widgets/dropdown.py index edea8be88..2f6ae9060 100644 --- a/arcade/gui/widgets/dropdown.py +++ b/arcade/gui/widgets/dropdown.py @@ -1,5 +1,5 @@ from copy import deepcopy -from typing import Optional, List +from typing import Optional, List, Union import arcade from arcade.gui.events import UIOnChangeEvent, UIOnClickEvent @@ -40,7 +40,7 @@ def __init__( width: float = 100, height: float = 100, default: Optional[str] = None, - options: Optional[List[str]] = None, + options: Optional[List[Union[str, None]]] = None, style=None, **kwargs ): if style is None: diff --git a/arcade/joysticks.py b/arcade/joysticks.py index 03cf20ace..9e3878a50 100644 --- a/arcade/joysticks.py +++ b/arcade/joysticks.py @@ -16,7 +16,7 @@ def get_joysticks() -> List[Joystick]: :return: List of game controllers """ - return pyglet.input.get_joysticks() + return pyglet.input.get_joysticks() # type: ignore # pending https://github.com/pyglet/pyglet/issues/842 def get_game_controllers() -> List[Joystick]: diff --git a/arcade/perf_graph.py b/arcade/perf_graph.py index 275a530aa..b64cb1a4e 100644 --- a/arcade/perf_graph.py +++ b/arcade/perf_graph.py @@ -127,7 +127,7 @@ def __init__( self._vertical_axis_text_objects.append( arcade.Text( "0", # Ensure the lowest y axis label is always 0 - self._left_x, y_level, + self._left_x, int(y_level), self._font_color, self._font_size, anchor_x="right", anchor_y="center")) self._grid_lines.append( diff --git a/arcade/sprite/colored.py b/arcade/sprite/colored.py index 582bc1616..c829e23cd 100644 --- a/arcade/sprite/colored.py +++ b/arcade/sprite/colored.py @@ -1,4 +1,5 @@ import PIL +import PIL.Image from arcade import cache, hitbox from arcade.texture import ( diff --git a/arcade/sprite_list/collision.py b/arcade/sprite_list/collision.py index 7edd6c0d1..f6c4f6abb 100644 --- a/arcade/sprite_list/collision.py +++ b/arcade/sprite_list/collision.py @@ -83,7 +83,7 @@ def check_for_collision(sprite1: SpriteType, sprite2: SpriteType) -> bool: return _check_for_collision(sprite1, sprite2) -def _check_for_collision(sprite1: SpriteType, sprite2: SpriteType) -> bool: +def _check_for_collision(sprite1: BasicSprite, sprite2: BasicSprite) -> bool: """ Check for collision between two sprites. @@ -130,7 +130,7 @@ def _check_for_collision(sprite1: SpriteType, sprite2: SpriteType) -> bool: ) -def _get_nearby_sprites(sprite: SpriteType, sprite_list: SpriteList) -> List[SpriteType]: +def _get_nearby_sprites(sprite: BasicSprite, sprite_list: SpriteList[SpriteType]) -> List[SpriteType]: sprite_count = len(sprite_list) if sprite_count == 0: return [] @@ -229,8 +229,8 @@ def check_for_collision_with_list( def check_for_collision_with_lists( - sprite: SpriteType, - sprite_lists: Iterable[SpriteList], + sprite: BasicSprite, + sprite_lists: Iterable[SpriteList[SpriteType]], method=1, ) -> List[SpriteType]: """ @@ -246,7 +246,9 @@ def check_for_collision_with_lists( """ if __debug__: if not isinstance(sprite, BasicSprite): - raise TypeError(f"Parameter 1 is not an instance of the Sprite class, it is an instance of {type(sprite)}.") + raise TypeError( + f"Parameter 1 is not an instance of the BasicSprite class, it is an instance of {type(sprite)}." + ) sprites: List[SpriteType] = [] sprites_to_check: Iterable[SpriteType] diff --git a/arcade/sprite_list/spatial_hash.py b/arcade/sprite_list/spatial_hash.py index 38a6ec870..14ce082a6 100644 --- a/arcade/sprite_list/spatial_hash.py +++ b/arcade/sprite_list/spatial_hash.py @@ -5,6 +5,7 @@ Dict, Generic, ) +from arcade.sprite.base import BasicSprite from arcade.types import Point, IPoint, Rect from arcade.sprite import SpriteType @@ -92,7 +93,7 @@ def remove(self, sprite: SpriteType) -> None: # Delete the sprite from the bucket tracker del self.buckets_for_sprite[sprite] - def get_sprites_near_sprite(self, sprite: SpriteType) -> Set[SpriteType]: + def get_sprites_near_sprite(self, sprite: BasicSprite) -> Set[SpriteType]: """ Get all the sprites that are in the same buckets as the given sprite. diff --git a/arcade/sprite_list/sprite_list.py b/arcade/sprite_list/sprite_list.py index cce2cf95c..d7951cea5 100644 --- a/arcade/sprite_list/sprite_list.py +++ b/arcade/sprite_list/sprite_list.py @@ -155,7 +155,7 @@ def __init__( from .spatial_hash import SpatialHash self._spatial_hash_cell_size = spatial_hash_cell_size - self.spatial_hash: Optional[SpatialHash] = None + self.spatial_hash: Optional[SpatialHash[SpriteType]] = None if use_spatial_hash: self.spatial_hash = SpatialHash(cell_size=self._spatial_hash_cell_size) diff --git a/arcade/text.py b/arcade/text.py index 646abd0d4..efe341766 100644 --- a/arcade/text.py +++ b/arcade/text.py @@ -178,8 +178,8 @@ class Text: def __init__( self, text: str, - start_x: float, - start_y: float, + start_x: int, + start_y: int, color: RGBOrA255 = arcade.color.WHITE, font_size: float = 12, width: Optional[int] = 0, @@ -193,7 +193,7 @@ def __init__( rotation: float = 0, batch: Optional[pyglet.graphics.Batch] = None, group: Optional[pyglet.graphics.Group] = None, - start_z: float = 0 + start_z: int = 0 ): if align != "center" and align != "left" and align != "right": raise ValueError("The 'align' parameter must be equal to 'left', 'right', or 'center'.") @@ -214,7 +214,7 @@ def __init__( bold=bold, italic=italic, multiline=multiline, - rotation=rotation, + rotation=rotation, # type: ignore # pending https://github.com/pyglet/pyglet/issues/843 batch=batch, group=group ) @@ -662,8 +662,8 @@ def create_text_sprite( ) def draw_text( text: Any, - start_x: float, - start_y: float, + start_x: int, + start_y: int, color: RGBA255 = arcade.color.WHITE, font_size: float = 12, width: int = 0, @@ -675,7 +675,7 @@ def draw_text( anchor_y: str = "baseline", multiline: bool = False, rotation: float = 0, - start_z: float = 0 + start_z: int = 0 ): """ A simple way for beginners to draw text. diff --git a/arcade/texture/texture.py b/arcade/texture/texture.py index 9135fc532..c6baad516 100644 --- a/arcade/texture/texture.py +++ b/arcade/texture/texture.py @@ -288,7 +288,7 @@ def file_path(self) -> Optional[Path]: return self._file_path @file_path.setter - def file_path(self, path: Path): + def file_path(self, path: Optional[Path]): self._file_path = path @property @@ -301,7 +301,7 @@ def crop_values(self) -> Optional[Tuple[int, int, int, int]]: return self._crop_values @crop_values.setter - def crop_values(self, crop: Tuple[int, int, int, int]): + def crop_values(self, crop: Optional[Tuple[int, int, int, int]]): self._crop_values = crop @property