-
Notifications
You must be signed in to change notification settings - Fork 350
Add missing type hints #1720
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
Closed
Closed
Add missing type hints #1720
Changes from all commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
f9de04d
1st version
4cc412c
Add more Type Hints
2c4ecc8
Fix cspotcode's review
0d166e4
Add types to sprite.py
3076ed4
Try to fix some issues
97cb872
Fixed more github stuff
c3c590f
Fix easing.py somewhat
ffedb28
Mics changes bc tests are breaking
be086d0
.
06b6ddd
Changes bc git complained
171af9b
Fixes problems in 4 files
9623b62
Attempt to fix git again
a432ca6
type hint problems in property.py
5294ea1
attempts to fix property.py
5b0d1f0
I was misunderstanding the test error messages
211f6a2
.
3698b0f
Attempt to fix property
51a15eb
.
71ef4b2
.
7de2f68
Check changes in mixins.py
7873b18
Address no slots in View
f50d5e7
Partially added __slots__
4b3789d
Role back __slots__
8563913
.
18c7c2c
.
857ec84
Merge branch 'pythonarcade:development' into AddMissingTypeHints
gran4 8d4fdd0
(View)
98fe26e
Merge branch 'AddMissingTypeHints' of https://github.com/gran4/arcade…
545fde1
.
bfc4bc8
.
cb74764
.
3d52f73
.
5c6e5d6
.
f581cbf
.
2d44801
.
a2097f1
.
30b5b26
Add imports to mixins
9ee32fb
Change import in mixins
b8ab035
Fix shape_list.py
b17ffb5
Changed pyproject.toml as @pushfoo sugested
a2c6f5c
Revert pyproject change
f2ffcab
Add # type: ignore
b386371
Small errors fixed
9ba0c55
.
1ce4b19
Merge branch 'development' into AddMissingTypeHints
gran4 16cccf6
Update arcade/application.py
gran4 5a8e8fb
Update arcade/gui/property.py
gran4 60b6f3d
cspotcode's fixes
0034450
//
a81a701
Merge branch 'AddMissingTypeHints' of https://github.com/gran4/arcade…
1c0af3c
lol
93761b6
added future immport annotations
5fe6a23
Remove generics
7f6de70
Requested fixes
a3e51d4
correct import in application
a5a6fc7
Add # type: ignore to speed it up
58805a7
Line was too long
3e867fa
Fixes
971e8f5
Merge branch 'pythonarcade:development' into AddMissingTypeHints
gran4 29e8632
..
99595de
Merge branch 'AddMissingTypeHints' of https://github.com/gran4/arcade…
6a0a779
...
135f7ca
..
4b344bf
.
aeb3819
.
gran4 929d87f
.
gran4 eb1f7d7
.
gran4 53237fa
.
gran4 21f3a8b
.
gran4 bc472c2
Update draw_commands.py
gran4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ def draw_arc_filled(center_x: float, center_y: float, | |
color: RGBA255, | ||
start_angle: float, end_angle: float, | ||
tilt_angle: float = 0, | ||
num_segments: int = 128): | ||
num_segments: int = 128) -> None: | ||
""" | ||
Draw a filled in arc. Useful for drawing pie-wedges, or Pac-Man. | ||
|
||
|
@@ -109,7 +109,7 @@ def draw_arc_outline(center_x: float, center_y: float, width: float, | |
height: float, color: RGBA255, | ||
start_angle: float, end_angle: float, | ||
border_width: float = 1, tilt_angle: float = 0, | ||
num_segments: int = 128): | ||
num_segments: int = 128) -> None: | ||
""" | ||
Draw the outside edge of an arc. Useful for drawing curved lines. | ||
|
||
|
@@ -165,7 +165,7 @@ def draw_arc_outline(center_x: float, center_y: float, width: float, | |
|
||
def draw_parabola_filled(start_x: float, start_y: float, end_x: float, | ||
height: float, color: RGBA255, | ||
tilt_angle: float = 0): | ||
tilt_angle: float = 0) -> None: | ||
""" | ||
Draws a filled in parabola. | ||
|
||
|
@@ -188,7 +188,7 @@ def draw_parabola_filled(start_x: float, start_y: float, end_x: float, | |
|
||
def draw_parabola_outline(start_x: float, start_y: float, end_x: float, | ||
height: float, color: RGBA255, | ||
border_width: float = 1, tilt_angle: float = 0): | ||
border_width: float = 1, tilt_angle: float = 0) -> None: | ||
""" | ||
Draws the outline of a parabola. | ||
|
||
|
@@ -216,9 +216,8 @@ def draw_parabola_outline(start_x: float, start_y: float, end_x: float, | |
# --- BEGIN CIRCLE FUNCTIONS # # # | ||
|
||
def draw_circle_filled(center_x: float, center_y: float, radius: float, | ||
color: RGBA255, | ||
tilt_angle: float = 0, | ||
num_segments: int = -1): | ||
color: RGBA255, tilt_angle: float = 0, | ||
num_segments: int = -1) -> None: | ||
""" | ||
Draw a filled-in circle. | ||
|
||
|
@@ -240,8 +239,7 @@ def draw_circle_filled(center_x: float, center_y: float, radius: float, | |
|
||
def draw_circle_outline(center_x: float, center_y: float, radius: float, | ||
color: RGBA255, border_width: float = 1, | ||
tilt_angle: float = 0, | ||
num_segments: int = -1): | ||
tilt_angle: float = 0, num_segments: int = -1) -> None: | ||
""" | ||
Draw the outline of a circle. | ||
|
||
|
@@ -272,7 +270,7 @@ def draw_circle_outline(center_x: float, center_y: float, radius: float, | |
|
||
def draw_ellipse_filled(center_x: float, center_y: float, | ||
width: float, height: float, color: RGBA255, | ||
tilt_angle: float = 0, num_segments: int = -1): | ||
tilt_angle: float = 0, num_segments: int = -1) -> None: | ||
""" | ||
Draw a filled in ellipse. | ||
|
||
|
@@ -315,11 +313,9 @@ def draw_ellipse_filled(center_x: float, center_y: float, | |
|
||
|
||
def draw_ellipse_outline(center_x: float, center_y: float, | ||
width: float, | ||
height: float, color: RGBA255, | ||
border_width: float = 1, | ||
tilt_angle: float = 0, | ||
num_segments: int = -1): | ||
width: float, height: float, color: RGBA255, | ||
border_width: float = 1, tilt_angle: float = 0, | ||
num_segments: int = -1) -> None: | ||
""" | ||
Draw the outline of an ellipse. | ||
|
||
|
@@ -366,9 +362,8 @@ def draw_ellipse_outline(center_x: float, center_y: float, | |
# --- 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. | ||
|
@@ -404,8 +399,8 @@ def _generic_draw_line_strip(point_list: PointList, | |
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. | ||
|
||
|
@@ -430,7 +425,7 @@ def draw_line_strip(point_list: PointList, | |
|
||
|
||
def draw_line(start_x: float, start_y: float, end_x: float, end_y: float, | ||
color: RGBA255, line_width: float = 1): | ||
color: RGBA255, line_width: float = 1) -> None: | ||
""" | ||
Draw a line. | ||
|
||
|
@@ -463,9 +458,8 @@ def draw_line(start_x: float, start_y: float, end_x: float, end_y: float, | |
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. | ||
|
||
|
@@ -505,7 +499,7 @@ def draw_lines(point_list: PointList, | |
# --- 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. | ||
|
||
|
@@ -518,7 +512,7 @@ def draw_point(x: float, y: float, color: RGBA255, size: float): | |
draw_rectangle_filled(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. | ||
|
||
|
@@ -558,8 +552,7 @@ def draw_points(point_list: PointList, color: RGBA255, size: float = 1): | |
# --- BEGIN POLYGON FUNCTIONS # # # | ||
|
||
|
||
def draw_polygon_filled(point_list: PointList, | ||
color: RGBA255): | ||
def draw_polygon_filled(point_list: PointList, color: RGBA255) -> None: | ||
""" | ||
Draw a polygon that is filled in. | ||
|
||
|
@@ -571,9 +564,8 @@ def draw_polygon_filled(point_list: PointList, | |
flattened_list = tuple(i for g in triangle_points for i in g) | ||
_generic_draw_line_strip(flattened_list, color, gl.GL_TRIANGLES) | ||
|
||
|
||
def draw_polygon_outline(point_list: PointList, | ||
color: RGBA255, line_width: float = 1): | ||
def draw_polygon_outline(point_list: PointList, color: RGBA255, | ||
line_width: float = 1) -> None: | ||
""" | ||
Draw a polygon outline. Also known as a "line loop." | ||
|
||
|
@@ -587,24 +579,25 @@ def draw_polygon_outline(point_list: PointList, | |
new_point_list.append(point_list[0]) | ||
|
||
triangle_point_list = [] | ||
# This needs a lot of improvement | ||
last_point = None | ||
for point in new_point_list: | ||
if last_point is not None: | ||
points = get_points_for_thick_line(last_point[0], last_point[1], point[0], point[1], line_width) | ||
reordered_points = points[1], points[0], points[2], points[3] | ||
triangle_point_list.extend(reordered_points) | ||
last_point = point | ||
|
||
points = get_points_for_thick_line(new_point_list[0][0], new_point_list[0][1], new_point_list[1][0], | ||
new_point_list[1][1], line_width) | ||
triangle_point_list.append(points[1]) | ||
for i in range(len(point_list) - 1): | ||
point1 = point_list[i] | ||
point2 = point_list[i + 1] | ||
|
||
points = get_points_for_thick_line(point1[0], point1[1], point2[0], point2[1], line_width) | ||
triangle_point_list.extend([points[1], points[0], points[2], points[3]]) | ||
|
||
# Handle the last segment (connecting back to the start) | ||
point1 = point_list[-1] | ||
point2 = point_list[0] | ||
points = get_points_for_thick_line(point1[0], point1[1], point2[0], point2[1], line_width) | ||
triangle_point_list.extend([points[1], points[0], points[2], points[3]]) | ||
Comment on lines
+582
to
+593
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If this is a needed improvement. If it works, this should be in another, separate PR. |
||
_generic_draw_line_strip(triangle_point_list, color, gl.GL_TRIANGLE_STRIP) | ||
|
||
|
||
def draw_triangle_filled(x1: float, y1: float, | ||
x2: float, y2: float, | ||
x3: float, y3: float, color: RGBA255): | ||
x3: float, y3: float, | ||
color: RGBA255) -> None: | ||
""" | ||
Draw a filled in triangle. | ||
|
||
|
@@ -629,7 +622,7 @@ def draw_triangle_outline(x1: float, y1: float, | |
x2: float, y2: float, | ||
x3: float, y3: float, | ||
color: RGBA255, | ||
border_width: float = 1): | ||
border_width: float = 1) -> None: | ||
""" | ||
Draw a the outline of a triangle. | ||
|
||
|
@@ -663,7 +656,7 @@ def draw_triangle_outline(x1: float, y1: float, | |
) | ||
def draw_lrtb_rectangle_outline(left: float, right: float, top: float, | ||
bottom: float, color: RGBA255, | ||
border_width: float = 1): | ||
border_width: float = 1) -> None: | ||
""" | ||
Draw a rectangle by specifying left, right, top and bottom edges. | ||
|
||
|
@@ -697,7 +690,7 @@ def draw_lrtb_rectangle_outline(left: float, right: float, top: float, | |
|
||
|
||
def draw_lrbt_rectangle_outline(left: float, right: float, bottom: float, top: float, color: RGBA255, | ||
border_width: float = 1): | ||
border_width: float = 1) -> None: | ||
""" | ||
Draw a rectangle by specifying left, right, bottom and top edges. | ||
|
||
|
@@ -729,7 +722,7 @@ def draw_lrbt_rectangle_outline(left: float, right: float, bottom: float, top: f | |
def draw_xywh_rectangle_outline(bottom_left_x: float, bottom_left_y: float, | ||
width: float, height: float, | ||
color: RGBA255, | ||
border_width: float = 1): | ||
border_width: float = 1) -> None: | ||
""" | ||
Draw a rectangle extending from bottom left to top right | ||
|
||
|
@@ -749,7 +742,7 @@ def draw_xywh_rectangle_outline(bottom_left_x: float, bottom_left_y: float, | |
|
||
def draw_rectangle_outline(center_x: float, center_y: float, width: float, | ||
height: float, color: RGBA255, | ||
border_width: float = 1, tilt_angle: float = 0): | ||
border_width: float = 1, tilt_angle: float = 0) -> None: | ||
""" | ||
Draw a rectangle outline. | ||
|
||
|
@@ -789,7 +782,7 @@ def draw_rectangle_outline(center_x: float, center_y: float, width: float, | |
new_name="draw_lrbt_rectangle_filled" | ||
) | ||
def draw_lrtb_rectangle_filled(left: float, right: float, top: float, | ||
bottom: float, color: RGBA255): | ||
bottom: float, color: RGBA255) -> None: | ||
""" | ||
Draw a rectangle by specifying left, right, top and bottom edges. | ||
|
||
|
@@ -817,7 +810,7 @@ def draw_lrtb_rectangle_filled(left: float, right: float, top: float, | |
draw_rectangle_filled(center_x, center_y, width, height, color) | ||
|
||
|
||
def draw_lrbt_rectangle_filled(left: float, right: float, bottom: float, top: float, color: RGBA255): | ||
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. | ||
|
||
|
@@ -843,7 +836,7 @@ def draw_lrbt_rectangle_filled(left: float, right: float, bottom: float, top: fl | |
|
||
def draw_xywh_rectangle_filled(bottom_left_x: float, bottom_left_y: float, | ||
width: float, height: float, | ||
color: RGBA255): | ||
color: RGBA255) -> None: | ||
""" | ||
Draw a filled rectangle extending from bottom left to top right | ||
|
||
|
@@ -861,7 +854,7 @@ def draw_xywh_rectangle_filled(bottom_left_x: float, bottom_left_y: float, | |
|
||
def draw_rectangle_filled(center_x: float, center_y: float, width: float, | ||
height: float, color: RGBA255, | ||
tilt_angle: float = 0): | ||
tilt_angle: float = 0) -> None: | ||
""" | ||
Draw a filled-in rectangle. | ||
|
||
|
@@ -898,7 +891,7 @@ def draw_scaled_texture_rectangle(center_x: float, center_y: float, | |
texture: Texture, | ||
scale: float = 1.0, | ||
angle: float = 0, | ||
alpha: int = 255): | ||
alpha: int = 255) -> None: | ||
""" | ||
Draw a textured rectangle on-screen. | ||
|
||
|
@@ -933,7 +926,7 @@ def draw_texture_rectangle(center_x: float, center_y: float, | |
height: float, | ||
texture: Texture, | ||
angle: float = 0, | ||
alpha: int = 255): | ||
alpha: int = 255) -> None: | ||
""" | ||
Draw a textured rectangle on-screen. | ||
|
||
|
@@ -948,11 +941,13 @@ def draw_texture_rectangle(center_x: float, center_y: float, | |
texture.draw_sized(center_x, center_y, width, height, angle, alpha) | ||
|
||
|
||
def draw_lrwh_rectangle_textured(bottom_left_x: float, bottom_left_y: float, | ||
def draw_lrwh_rectangle_textured(bottom_left_x: float, | ||
bottom_left_y: float, | ||
width: float, | ||
height: float, | ||
texture: Texture, angle: float = 0, | ||
alpha: int = 255): | ||
texture: Texture, | ||
angle: float = 0, | ||
alpha: int = 255) -> None: | ||
""" | ||
Draw a texture extending from bottom left to top right. | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.