Skip to content

Commit c387717

Browse files
committed
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.
1 parent 5743504 commit c387717

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

arcade/sprite/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ def collides_with_point(self, point: Point2) -> bool:
801801
x, y = point
802802
return is_point_in_polygon(x, y, self.hit_box.get_adjusted_points())
803803

804-
def collides_with_sprite(self: SpriteType, other: SpriteType) -> bool:
804+
def collides_with_sprite(self, other: BasicSprite) -> bool:
805805
"""Will check if a sprite is overlapping (colliding) another Sprite.
806806
807807
Args:
@@ -813,7 +813,7 @@ def collides_with_sprite(self: SpriteType, other: SpriteType) -> bool:
813813

814814
return check_for_collision(self, other)
815815

816-
def collides_with_list(self: SpriteType, sprite_list: "SpriteList") -> list[SpriteType]:
816+
def collides_with_list(self, sprite_list: SpriteList[SpriteType]) -> list[SpriteType]:
817817
"""Check if current sprite is overlapping with any other sprite in a list
818818
819819
Args:

arcade/sprite_list/collision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def _get_nearby_sprites(
187187

188188

189189
def check_for_collision_with_list(
190-
sprite: SpriteType,
191-
sprite_list: SpriteList,
190+
sprite: BasicSprite,
191+
sprite_list: SpriteList[SpriteType],
192192
method: int = 0,
193193
) -> List[SpriteType]:
194194
"""

0 commit comments

Comments
 (0)