Skip to content

Fixed PyRight issues. #1854

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions arcade/gui/widgets/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from arcade.types import RGBA255, Color, RGBOrA255, RGB



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

# Set how fast the mouse scroll wheel will scroll text in the pane.
# Measured in pixels per 'click'
self.scroll_speed = scroll_speed if scroll_speed is not None \
else font_size
self.scroll_speed = (
scroll_speed if scroll_speed is not None
else font_size
)

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

if super().on_event(event):
Expand Down
12 changes: 7 additions & 5 deletions arcade/physics_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
# pylint: disable=too-many-arguments, too-many-locals, too-few-public-methods

import math
from typing import Iterable, List, Optional, Union
from typing import Iterable, List, Optional, Union, cast

from arcade import (
BasicSprite,
Sprite,
SpriteList,
SpriteType,
check_for_collision,
check_for_collision_with_lists
)
Expand Down Expand Up @@ -53,7 +55,7 @@ def _circular_check(player: Sprite, walls: List[SpriteList]):
vary *= 2


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

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

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

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

def __init__(self, player_sprite: Sprite, walls: Union[SpriteList, Iterable[SpriteList]]):
def __init__(self, player_sprite: Sprite, walls: Union[SpriteList[BasicSprite], Iterable[SpriteList[BasicSprite]]]):
assert isinstance(player_sprite, Sprite)

if walls:
if isinstance(walls, SpriteList):
self.walls = [walls]
self.walls = [cast(SpriteList[BasicSprite], walls)]
else:
self.walls = list(walls)
else:
Expand Down
2 changes: 1 addition & 1 deletion arcade/sprite_list/collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_closest_sprite(
return sprite_list[min_pos], min_distance


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

Expand Down