Skip to content

Commit 0608a78

Browse files
authored
Merge pull request #1854 from DragonMoffon/fix-SimpleSprite-Issue
Fixed PyRight issues.
2 parents a5dbe33 + b6aa75a commit 0608a78

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

arcade/gui/widgets/text.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from arcade.types import RGBA255, Color, RGBOrA255, RGB
2424

2525

26-
2726
class UILabel(UIWidget):
2827
"""A simple text label. This widget is meant to display user instructions or
2928
information. This label supports multiline text.
@@ -488,8 +487,10 @@ def __init__(
488487

489488
# Set how fast the mouse scroll wheel will scroll text in the pane.
490489
# Measured in pixels per 'click'
491-
self.scroll_speed = scroll_speed if scroll_speed is not None \
492-
else font_size
490+
self.scroll_speed = (
491+
scroll_speed if scroll_speed is not None
492+
else font_size
493+
)
493494

494495
self.doc: AbstractDocument = pyglet.text.decode_text(text)
495496
self.doc.set_style(
@@ -551,7 +552,7 @@ def do_render(self, surface: Surface):
551552
def on_event(self, event: UIEvent) -> Optional[bool]:
552553
if isinstance(event, UIMouseScrollEvent):
553554
if self.rect.collide_with_point(event.x, event.y):
554-
self.layout.view_y += event.scroll_y * self.scroll_speed
555+
self.layout.view_y += event.scroll_y * self.scroll_speed # type: ignore # pending https://github.com/pyglet/pyglet/issues/916
555556
self.trigger_full_render()
556557

557558
if super().on_event(event):

arcade/physics_engines.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
# pylint: disable=too-many-arguments, too-many-locals, too-few-public-methods
55

66
import math
7-
from typing import Iterable, List, Optional, Union
7+
from typing import Iterable, List, Optional, Union, cast
88

99
from arcade import (
10+
BasicSprite,
1011
Sprite,
1112
SpriteList,
13+
SpriteType,
1214
check_for_collision,
1315
check_for_collision_with_lists
1416
)
@@ -53,7 +55,7 @@ def _circular_check(player: Sprite, walls: List[SpriteList]):
5355
vary *= 2
5456

5557

56-
def _move_sprite(moving_sprite: Sprite, walls: List[SpriteList], ramp_up: bool) -> List[Sprite]:
58+
def _move_sprite(moving_sprite: Sprite, walls: List[SpriteList[SpriteType]], ramp_up: bool) -> List[SpriteType]:
5759

5860
# See if we are starting this turn with a sprite already colliding with us.
5961
if len(check_for_collision_with_lists(moving_sprite, walls)) > 0:
@@ -109,7 +111,7 @@ def _move_sprite(moving_sprite: Sprite, walls: List[SpriteList], ramp_up: bool)
109111

110112
# NOTE: Not all sprites have velocity
111113
if getattr(item, "change_x", 0.0) != 0:
112-
moving_sprite.center_x += item.change_x
114+
moving_sprite.center_x += item.change_x # type: ignore
113115

114116
# print(f"Spot Y ({self.player_sprite.center_x}, {self.player_sprite.center_y})")
115117
else:
@@ -230,12 +232,12 @@ class PhysicsEngineSimple:
230232
This can be one or multiple spritelists.
231233
"""
232234

233-
def __init__(self, player_sprite: Sprite, walls: Union[SpriteList, Iterable[SpriteList]]):
235+
def __init__(self, player_sprite: Sprite, walls: Union[SpriteList[BasicSprite], Iterable[SpriteList[BasicSprite]]]):
234236
assert isinstance(player_sprite, Sprite)
235237

236238
if walls:
237239
if isinstance(walls, SpriteList):
238-
self.walls = [walls]
240+
self.walls = [cast(SpriteList[BasicSprite], walls)]
239241
else:
240242
self.walls = list(walls)
241243
else:

arcade/sprite_list/collision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_closest_sprite(
5959
return sprite_list[min_pos], min_distance
6060

6161

62-
def check_for_collision(sprite1: SpriteType, sprite2: SpriteType) -> bool:
62+
def check_for_collision(sprite1: BasicSprite, sprite2: BasicSprite) -> bool:
6363
"""
6464
Check for a collision between two sprites.
6565

0 commit comments

Comments
 (0)