Skip to content

Commit 2c92196

Browse files
committed
More typing fixes
1 parent 6f76219 commit 2c92196

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

arcade/examples/gui/exp_controller_inventory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ def on_draw_before_ui(self):
412412

413413
if __name__ == "__main__":
414414
# pixelate the font
415-
pyglet.font.base.Font.texture_min_filter = GL_NEAREST
416-
pyglet.font.base.Font.texture_mag_filter = GL_NEAREST
415+
pyglet.font.base.Font.texture_min_filter = GL_NEAREST # type: ignore
416+
pyglet.font.base.Font.texture_mag_filter = GL_NEAREST # type: ignore
417417

418418
load_kenney_fonts()
419419

arcade/examples/input_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
# type: ignore
12
"""
23
Example for handling input using the Arcade InputManager
34
45
If Python and Arcade are installed, this example can be run from the command line with:
56
python -m arcade.examples.input_manager
67
"""
7-
# type: ignore
88
import random
99
from collections.abc import Sequence
1010

arcade/future/video/video_player.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ def get_video_size(self) -> tuple[int, int]:
7777
width = video_format.width
7878
height = video_format.height
7979
if video_format.sample_aspect > 1:
80-
width *= video_format.sample_aspect
80+
width = int(width * video_format.sample_aspect)
8181
elif video_format.sample_aspect < 1:
82-
height /= video_format.sample_aspect
83-
return int(width), int(height)
82+
height = int(height / video_format.sample_aspect)
83+
return width, height
8484

8585

8686
class VideoPlayerView(arcade.View):

arcade/perf_graph.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import random
22

33
import pyglet.clock
4-
from pyglet.graphics import Batch
4+
5+
# Pyright can't figure out the dynamic import for the backends in Pyglet
6+
from pyglet.graphics import Batch # type: ignore
57
from pyglet.shapes import Line
68

79
import arcade

arcade/pymunk_physics_engine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ def check_grounding(self, sprite: Sprite) -> dict:
776776
"""
777777
grounding = {
778778
"normal": pymunk.Vec2d.zero(),
779-
"penetration": pymunk.Vec2d.zero(),
779+
"penetration": 0.0,
780780
"impulse": pymunk.Vec2d.zero(),
781781
"position": pymunk.Vec2d.zero(),
782782
"body": None,
@@ -806,7 +806,9 @@ def f(arbiter: pymunk.Arbiter):
806806
):
807807
grounding["normal"] = n
808808
grounding["penetration"] = -arbiter.contact_point_set.points[0].distance
809-
grounding["body"] = arbiter.shapes[1].body
809+
# Mypy is making bad inferences about what this is based on the other elements
810+
# and this doesn't particularly feel worth a TypedDict
811+
grounding["body"] = arbiter.shapes[1].body # type: ignore
810812
grounding["impulse"] = arbiter.total_impulse
811813
grounding["position"] = arbiter.contact_point_set.points[0].point_b
812814

arcade/text.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
import pyglet
99
from pyglet.enums import Style, Weight
1010

11+
# Pyright can't figure out the dynamic backend imports in pyglet.graphics
12+
# right now. Maybe can fix in future Pyglet version
13+
from pyglet.graphics import Batch, Group # type: ignore
14+
1115
import arcade
1216
from arcade.exceptions import PerformanceWarning, warning
1317
from arcade.resources import resolve
@@ -216,8 +220,8 @@ def __init__(
216220
anchor_y: str = "baseline",
217221
multiline: bool = False,
218222
rotation: float = 0,
219-
batch: pyglet.graphics.Batch | None = None,
220-
group: pyglet.graphics.Group | None = None,
223+
batch: Batch | None = None,
224+
group: Group | None = None,
221225
z: float = 0,
222226
**kwargs,
223227
):
@@ -297,19 +301,19 @@ def __exit__(self, exc_type, exc_val, exc_tb):
297301
self.label.end_update()
298302

299303
@property
300-
def batch(self) -> pyglet.graphics.Batch | None:
304+
def batch(self) -> Batch | None:
301305
"""The batch this text is in, if any.
302306
303307
Can be unset by setting to ``None``.
304308
"""
305309
return self.label.batch
306310

307311
@batch.setter
308-
def batch(self, batch: pyglet.graphics.Batch):
312+
def batch(self, batch: Batch):
309313
self.label.batch = batch
310314

311315
@property
312-
def group(self) -> pyglet.graphics.Group | None:
316+
def group(self) -> Group | None:
313317
"""
314318
The specific group in a batch the text should belong to.
315319
@@ -320,7 +324,7 @@ def group(self) -> pyglet.graphics.Group | None:
320324
return self.label.group
321325

322326
@group.setter
323-
def group(self, group: pyglet.graphics.Group):
327+
def group(self, group: Group):
324328
self.label.group = group
325329

326330
@property

tests/unit/test_example_docstrings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def check_submodules(parent_module_absolute_name: str) -> None:
6262

6363
# Check all modules nested immediately inside it on the file system
6464
for finder, child_module_name, is_pkg in pkgutil.iter_modules(parent_module_file_path):
65+
if is_pkg:
66+
continue
6567
child_module_file_path = Path(finder.path) / f"{child_module_name}.py"
6668
child_module_absolute_name = f"{parent_module_absolute_name}.{child_module_name}"
6769

0 commit comments

Comments
 (0)