From f7608e22a37a94a6ce5a9e3b653675cde5cd95f9 Mon Sep 17 00:00:00 2001 From: Filip Lange Date: Wed, 30 Aug 2023 20:13:40 +0200 Subject: [PATCH] Fix type errors --- trainfinity2/camera.py | 2 +- trainfinity2/graphics/drawer.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/trainfinity2/camera.py b/trainfinity2/camera.py index 8e374f2..a0d0be1 100644 --- a/trainfinity2/camera.py +++ b/trainfinity2/camera.py @@ -14,7 +14,7 @@ def __init__(self): self.right = self.original_right self.bottom = self.original_bottom self.top = self.original_top - self._old_viewport = (0, 0, 0, 0) + self._old_viewport = (0.0, 0.0, 0.0, 0.0) self._is_active = False def __enter__(self): diff --git a/trainfinity2/graphics/drawer.py b/trainfinity2/graphics/drawer.py index 1f0eac9..8edfa73 100644 --- a/trainfinity2/graphics/drawer.py +++ b/trainfinity2/graphics/drawer.py @@ -3,7 +3,7 @@ from typing import Any, Collection, Iterable import arcade -from arcade import color +from arcade import Shape, color from pyglet.math import Vec2 from trainfinity2.graphics.rail_shapes import get_rail_shapes @@ -42,7 +42,7 @@ class _ShapeElementList: if trying to draw an empty list.""" def __init__(self) -> None: - self._list = arcade.ShapeElementList() + self._list = arcade.ShapeElementList[Shape]() def __len__(self) -> int: return len(self._list) @@ -119,7 +119,7 @@ def _remove(self, object: Any): del self._signal_shapes_from_object_id[id(object)] def _create_grid(self, grid: Grid): - self._grid_shape_list = arcade.ShapeElementList() + self._grid_shape_list = _ShapeElementList() for x in range(grid.left, grid.right + 1, GRID_BOX_SIZE): self._grid_shape_list.append( arcade.create_line( @@ -310,7 +310,7 @@ def _remove_iron(self, position: Vec2, amount: int): def _show_rails_being_built(self, rails: set[Rail]): if rails != self._rails_being_built: - self.rails_being_built_shape_element_list = arcade.ShapeElementList() + self.rails_being_built_shape_element_list = _ShapeElementList() for rail in rails: color = ( BUILDING_RAIL_COLOR if rail.legal else BUILDING_ILLEGAL_RAIL_COLOR @@ -325,7 +325,7 @@ def _create_rail(self, rail: Rail): self._add_rail_shape(rail_shape, rail) def highlight(self, positions: Iterable[Vec2]): - self.highlight_shape_element_list = arcade.ShapeElementList() + self.highlight_shape_element_list = _ShapeElementList() for position in positions: shape = arcade.create_rectangle_filled( position.x + GRID_BOX_SIZE / 2,