Skip to content

Missing type hints #2143

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 1 commit into from
Jun 27, 2024
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
161 changes: 89 additions & 72 deletions arcade/application.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion arcade/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ArcadeContext(Context):

def __init__(
self, window: pyglet.window.Window, gc_mode: str = "context_gc", gl_api: str = "gl"
):
) -> None:

super().__init__(window, gc_mode=gc_mode, gl_api=gl_api)

Expand Down
64 changes: 35 additions & 29 deletions arcade/draw_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def draw_arc_filled(
end_angle: float,
tilt_angle: float = 0,
num_segments: int = 128,
):
) -> None:
"""
Draw a filled in arc. Useful for drawing pie-wedges, or Pac-Man.

Expand Down Expand Up @@ -164,7 +164,7 @@ def draw_arc_outline(
border_width: float = 1,
tilt_angle: float = 0,
num_segments: int = 128,
):
) -> None:
"""
Draw the outside edge of an arc. Useful for drawing curved lines.

Expand Down Expand Up @@ -228,7 +228,7 @@ def draw_parabola_filled(
height: float,
color: RGBA255,
tilt_angle: float = 0,
):
) -> None:
"""
Draws a filled in parabola.

Expand Down Expand Up @@ -256,7 +256,7 @@ def draw_parabola_outline(
color: RGBA255,
border_width: float = 1,
tilt_angle: float = 0,
):
) -> None:
"""
Draws the outline of a parabola.

Expand Down Expand Up @@ -300,7 +300,7 @@ def draw_circle_filled(
color: RGBA255,
tilt_angle: float = 0,
num_segments: int = -1,
):
) -> None:
"""
Draw a filled-in circle.

Expand Down Expand Up @@ -334,7 +334,7 @@ def draw_circle_outline(
border_width: float = 1,
tilt_angle: float = 0,
num_segments: int = -1,
):
) -> None:
"""
Draw the outline of a circle.

Expand Down Expand Up @@ -377,7 +377,7 @@ def draw_ellipse_filled(
color: RGBA255,
tilt_angle: float = 0,
num_segments: int = -1,
):
) -> None:
"""
Draw a filled in ellipse.

Expand Down Expand Up @@ -425,7 +425,7 @@ def draw_ellipse_outline(
border_width: float = 1,
tilt_angle: float = 0,
num_segments: int = -1,
):
) -> None:
"""
Draw the outline of an ellipse.

Expand Down Expand Up @@ -469,7 +469,9 @@ def draw_ellipse_outline(
# --- BEGIN LINE FUNCTIONS # # #


def _generic_draw_line_strip(point_list: PointList, color: RGBA255, mode: int = gl.GL_LINE_STRIP):
def _generic_draw_line_strip(
point_list: PointList, color: RGBA255, mode: int = gl.GL_LINE_STRIP
) -> None:
"""
Draw a line strip. A line strip is a set of continuously connected
line segments.
Expand Down Expand Up @@ -512,7 +514,7 @@ def _generic_draw_line_strip(point_list: PointList, color: RGBA255, mode: int =
geometry.render(program, mode=mode)


def draw_line_strip(point_list: PointList, color: RGBA255, line_width: float = 1):
def draw_line_strip(point_list: PointList, color: RGBA255, line_width: float = 1) -> None:
"""
Draw a multi-point line.

Expand Down Expand Up @@ -545,7 +547,7 @@ def draw_line(
end_y: float,
color: RGBA255,
line_width: float = 1,
):
) -> None:
"""
Draw a line.

Expand Down Expand Up @@ -576,7 +578,7 @@ def draw_line(
geometry.render(program, mode=gl.GL_LINES, vertices=2)


def draw_lines(point_list: PointList, color: RGBA255, line_width: float = 1):
def draw_lines(point_list: PointList, color: RGBA255, line_width: float = 1) -> None:
"""
Draw a set of lines.

Expand Down Expand Up @@ -619,7 +621,7 @@ def draw_lines(point_list: PointList, color: RGBA255, line_width: float = 1):
# --- BEGIN POINT FUNCTIONS # # #


def draw_point(x: float, y: float, color: RGBA255, size: float):
def draw_point(x: float, y: float, color: RGBA255, size: float) -> None:
"""
Draw a point.

Expand All @@ -632,7 +634,7 @@ def draw_point(x: float, y: float, color: RGBA255, size: float):
draw_rect_filled(XYWH(x, y, size, size), color)


def draw_points(point_list: PointList, color: RGBA255, size: float = 1):
def draw_points(point_list: PointList, color: RGBA255, size: float = 1) -> None:
"""
Draw a set of points.

Expand Down Expand Up @@ -675,7 +677,7 @@ def draw_points(point_list: PointList, color: RGBA255, size: float = 1):
# --- BEGIN POLYGON FUNCTIONS # # #


def draw_polygon_filled(point_list: Point2List, color: RGBA255):
def draw_polygon_filled(point_list: Point2List, color: RGBA255) -> None:
"""
Draw a polygon that is filled in.

Expand All @@ -688,7 +690,7 @@ def draw_polygon_filled(point_list: Point2List, color: RGBA255):
_generic_draw_line_strip(flattened_list, color, gl.GL_TRIANGLES)


def draw_polygon_outline(point_list: Point2List, color: RGBA255, line_width: float = 1):
def draw_polygon_outline(point_list: Point2List, color: RGBA255, line_width: float = 1) -> None:
"""
Draw a polygon outline. Also known as a "line loop."

Expand Down Expand Up @@ -728,7 +730,7 @@ def draw_polygon_outline(point_list: Point2List, color: RGBA255, line_width: flo

def draw_triangle_filled(
x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: RGBA255
):
) -> None:
"""
Draw a filled in triangle.

Expand Down Expand Up @@ -758,7 +760,7 @@ def draw_triangle_outline(
y3: float,
color: RGBA255,
border_width: float = 1,
):
) -> None:
"""
Draw a the outline of a triangle.

Expand Down Expand Up @@ -793,7 +795,7 @@ def draw_lrbt_rectangle_outline(
top: float,
color: RGBA255,
border_width: float = 1,
):
) -> None:
"""
Draw a rectangle by specifying left, right, bottom and top edges.

Expand Down Expand Up @@ -822,7 +824,7 @@ def draw_lbwh_rectangle_outline(
height: float,
color: RGBA255,
border_width: float = 1,
):
) -> None:
"""
Draw a rectangle extending from bottom left to top right

Expand All @@ -840,7 +842,7 @@ def draw_lbwh_rectangle_outline(

def draw_lrbt_rectangle_filled(
left: float, right: float, bottom: float, top: float, color: RGBA255
):
) -> None:
"""
Draw a rectangle by specifying left, right, bottom and top edges.

Expand All @@ -866,7 +868,7 @@ def draw_lrbt_rectangle_filled(

def draw_lbwh_rectangle_filled(
left: float, bottom: float, width: float, height: float, color: RGBA255
):
) -> None:
"""
Draw a filled rectangle extending from bottom left to top right

Expand All @@ -888,7 +890,7 @@ def draw_scaled_texture_rectangle(
scale: float = 1.0,
angle: float = 0,
alpha: int = 255,
):
) -> None:
"""
Draw a textured rectangle on-screen.

Expand Down Expand Up @@ -926,7 +928,7 @@ def draw_texture_rectangle(
texture: Texture,
angle: float = 0,
alpha: int = 255,
):
) -> None:
"""
Draw a textured rectangle on-screen.

Expand All @@ -949,7 +951,7 @@ def draw_lbwh_rectangle_textured(
texture: Texture,
angle: float = 0,
alpha: int = 255,
):
) -> None:
"""
Draw a texture extending from bottom left to top right.

Expand All @@ -970,7 +972,9 @@ def draw_lbwh_rectangle_textured(
# Reference implementations: drawing of new Rect


def draw_rect_outline(rect: Rect, color: RGBA255, border_width: float = 1, tilt_angle: float = 0):
def draw_rect_outline(
rect: Rect, color: RGBA255, border_width: float = 1, tilt_angle: float = 0
) -> None:
"""
Draw a rectangle outline.

Expand Down Expand Up @@ -1007,7 +1011,7 @@ def draw_rect_outline(rect: Rect, color: RGBA255, border_width: float = 1, tilt_
_generic_draw_line_strip(point_list, color, gl.GL_TRIANGLE_STRIP)


def draw_rect_filled(rect: Rect, color: RGBA255, tilt_angle: float = 0):
def draw_rect_filled(rect: Rect, color: RGBA255, tilt_angle: float = 0) -> None:
"""
Draw a filled-in rectangle.

Expand Down Expand Up @@ -1038,12 +1042,14 @@ def draw_rect_filled(rect: Rect, color: RGBA255, tilt_angle: float = 0):

def draw_rect_outline_kwargs(
color: RGBA255 = WHITE, border_width: int = 1, tilt_angle: float = 0, **kwargs: AsFloat
):
) -> None:
rect = Rect.from_kwargs(**kwargs)
draw_rect_outline(rect, color, border_width, tilt_angle)


def draw_rect_filled_kwargs(color: RGBA255 = WHITE, tilt_angle: float = 0, **kwargs: AsFloat):
def draw_rect_filled_kwargs(
color: RGBA255 = WHITE, tilt_angle: float = 0, **kwargs: AsFloat
) -> None:
rect = Rect.from_kwargs(**kwargs)
draw_rect_filled(rect, color, tilt_angle)

Expand Down
12 changes: 8 additions & 4 deletions arcade/easing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EasingData:
end_value: float
ease_function: Callable

def reset(self):
def reset(self) -> None:
self.cur_period = self.start_period


Expand Down Expand Up @@ -211,7 +211,9 @@ def ease_angle_update(easing_data: EasingData, delta_time: float) -> Tuple:
return done, angle


def ease_value(start_value: float, end_value: float, *, time=None, rate=None, ease_function=linear):
def ease_value(
start_value: float, end_value: float, *, time=None, rate=None, ease_function=linear
) -> EasingData:
"""
Get an easing value
"""
Expand All @@ -233,7 +235,9 @@ def ease_value(start_value: float, end_value: float, *, time=None, rate=None, ea
return easing_data


def ease_position(start_position, end_position, *, time=None, rate=None, ease_function=linear):
def ease_position(
start_position, end_position, *, time=None, rate=None, ease_function=linear
) -> Tuple[EasingData, EasingData]:
"""
Get an easing position
"""
Expand All @@ -252,7 +256,7 @@ def ease_position(start_position, end_position, *, time=None, rate=None, ease_fu
return easing_data_x, easing_data_y


def ease_update(easing_data: EasingData, delta_time: float) -> Tuple:
def ease_update(easing_data: EasingData, delta_time: float) -> Tuple[bool, float]:
"""
Update easing between two values/
"""
Expand Down
Loading
Loading