From c387717ffe20f05accf3f906a86b7bbf3fbdd12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Fri, 21 Feb 2025 10:39:58 +0100 Subject: [PATCH] Fix the type signature of collision check methods. The type of the sprites in the result never depend on the first argument single sprite. Instead, it depends on the type of sprites in the given `sprite_list`. Previously, some signatures did not accurately reflect those properties. This commit fixes them. Fixes #2576. --- arcade/sprite/base.py | 4 ++-- arcade/sprite_list/collision.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arcade/sprite/base.py b/arcade/sprite/base.py index d8ff67bc6e..c4a5a75872 100644 --- a/arcade/sprite/base.py +++ b/arcade/sprite/base.py @@ -801,7 +801,7 @@ def collides_with_point(self, point: Point2) -> bool: x, y = point return is_point_in_polygon(x, y, self.hit_box.get_adjusted_points()) - def collides_with_sprite(self: SpriteType, other: SpriteType) -> bool: + def collides_with_sprite(self, other: BasicSprite) -> bool: """Will check if a sprite is overlapping (colliding) another Sprite. Args: @@ -813,7 +813,7 @@ def collides_with_sprite(self: SpriteType, other: SpriteType) -> bool: return check_for_collision(self, other) - def collides_with_list(self: SpriteType, sprite_list: "SpriteList") -> list[SpriteType]: + def collides_with_list(self, sprite_list: SpriteList[SpriteType]) -> list[SpriteType]: """Check if current sprite is overlapping with any other sprite in a list Args: diff --git a/arcade/sprite_list/collision.py b/arcade/sprite_list/collision.py index 914320d0fa..118e115775 100644 --- a/arcade/sprite_list/collision.py +++ b/arcade/sprite_list/collision.py @@ -187,8 +187,8 @@ def _get_nearby_sprites( def check_for_collision_with_list( - sprite: SpriteType, - sprite_list: SpriteList, + sprite: BasicSprite, + sprite_list: SpriteList[SpriteType], method: int = 0, ) -> List[SpriteType]: """