Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the type signature of collision check methods. #2578

Merged

Conversation

sjrd
Copy link
Contributor

@sjrd sjrd commented Feb 21, 2025

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.


I don't think this can be tested per se? The tests don't seem to be checked by mypy, are they?

FWIW, changing sprite_list: SpriteList to SpriteList[BasicSprite] (only) did report type errors inside check_collision_with_sprite_list. It previously passed the type checker only because it was inferred as SpriteList[Unknown], which it was happy to assign to Iterable[SpriteType].

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 pythonarcade#2576.
Copy link
Member

@pushfoo pushfoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of merging since:

  1. The SpriteList is more crucial than the physics engines
  2. The physics engine annotations are sort of kludgy
  3. Completely overhaul Arcade's physics engines, and physics engine dependencies. #2580

@pushfoo pushfoo merged commit 21fe980 into pythonarcade:development Feb 26, 2025
8 checks passed
@sjrd sjrd deleted the fix-type-sig-of-collision-checks branch February 26, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check_for_collision_with_list does not return the right SpriteType
2 participants