Skip to content

Commit 21fe980

Browse files
authored
Fix the type signature of collision check methods. (#2578)
* Fix argument annotation for collides_with_list since the type of the sprites in the result depends on the type of sprites in the given `sprite_list`. * Fix argument annotation for collides_with_sprite * Closes #2576
1 parent 79defbf commit 21fe980

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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)