Skip to content

Code formatting #1989

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 3 commits into from
Feb 24, 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
1 change: 1 addition & 0 deletions arcade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def configure_logging(level: Optional[int] = None):
ch.setFormatter(logging.Formatter('%(relativeCreated)s %(name)s %(levelname)s - %(message)s'))
LOG.addHandler(ch)


# The following is used to load ffmpeg libraries.
# Currently Arcade is only shipping binaries for Mac OS
# as ffmpeg is not needed for support on Windows and Linux.
Expand Down
4 changes: 2 additions & 2 deletions arcade/cache/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ def put(
name = texture.cache_name
if strong:
self._strong_entries.put(name, texture)
if self._strong_file_entries.get(file_path): # type: ignore # pending https://github.com/pythonarcade/arcade/issues/1752
if self._strong_file_entries.get(file_path): # type: ignore # pending https://github.com/pythonarcade/arcade/issues/1752
raise ValueError(f"File path {file_path} already in cache")
if file_path:
self._strong_file_entries.put(str(file_path), texture)
else:
self._weak_entires.put(name, texture)
if self._weak_file_entries.get(file_path): # type: ignore # pending https://github.com/pythonarcade/arcade/issues/1752
if self._weak_file_entries.get(file_path): # type: ignore # pending https://github.com/pythonarcade/arcade/issues/1752
raise ValueError(f"File path {file_path} already in cache")
if file_path:
self._weak_file_entries.put(str(file_path), texture)
Expand Down
1 change: 1 addition & 0 deletions arcade/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

__all__ = ["ArcadeContext"]


class ArcadeContext(Context):
"""
An OpenGL context implementation for Arcade with added custom features.
Expand Down
2 changes: 1 addition & 1 deletion arcade/examples/gl/bindless_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(self):
resource_cycle = cycle(resources)

# Load enough textures to cover for each point/sprite
for i in range(16 * 9):
for i in range(16 * 9):
texture = self.ctx.load_texture(next(resource_cycle))
texture.wrap_x = self.ctx.CLAMP_TO_EDGE
texture.wrap_y = self.ctx.CLAMP_TO_EDGE
Expand Down
2 changes: 2 additions & 0 deletions arcade/examples/net_process_animal_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ def start(self) -> int:

class Facts:
"""Base class for fact providers"""

def get_fact(self) -> str:
raise NotImplementedError()

def get_image(self) -> arcade.Texture:
raise NotImplementedError()

Expand Down
1 change: 0 additions & 1 deletion arcade/examples/shape_list_demo_skylines.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
ShapeElementList,
create_rectangle_filled,
create_polygon,
create_rectangle_filled,
create_rectangles_filled_with_colors,
)

Expand Down
2 changes: 1 addition & 1 deletion arcade/experimental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
])

except ImportError:
pass
pass
2 changes: 1 addition & 1 deletion arcade/experimental/query_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, width, height, title):
self.sprites.draw() # Force the list to build

self.sprites.program = self.ctx.sprite_list_program_no_cull
print(f"Initialization time: {time.time() -start}")
print(f"Initialization time: {time.time() - start}")

self.query = self.ctx.query()
self.frames = 0
Expand Down
1 change: 0 additions & 1 deletion arcade/experimental/video_cv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def update(self, delta_time: float) -> None:
self.video.set(cv2.CAP_PROP_POS_FRAMES, 0)



class CV2PlayerView(arcade.View):
"""
A simple view to hold a video player using cv2.
Expand Down
1 change: 1 addition & 0 deletions arcade/experimental/video_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def get_video_size(self) -> Tuple[int, int]:
height /= video_format.sample_aspect
return width, height


class VideoPlayerView(arcade.View):
def __init__(self, path: Union[str, Path]) -> None:
super().__init__()
Expand Down
2 changes: 1 addition & 1 deletion arcade/gl/compute_shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, ctx: "Context", glsl_source: str) -> None:
f"---- [compute shader] ---\n"
)
+ "\n".join(
f"{str(i+1).zfill(3)}: {line} "
f"{str(i + 1).zfill(3)}: {line} "
for i, line in enumerate(self._source.split("\n"))
)
)
Expand Down
4 changes: 2 additions & 2 deletions arcade/gl/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,10 +1315,10 @@ def __init__(self, ctx):
warn("Error happened while querying of limits. Moving on ..")

@overload
def get_int_tuple(self, enum: GLenumLike, length: Literal[2]) -> Tuple[int, int]:...
def get_int_tuple(self, enum: GLenumLike, length: Literal[2]) -> Tuple[int, int]: ...

@overload
def get_int_tuple(self, enum: GLenumLike, length: int) -> Tuple[int, ...]:...
def get_int_tuple(self, enum: GLenumLike, length: int) -> Tuple[int, ...]: ...

def get_int_tuple(self, enum: GLenumLike, length: int):
"""Get an enum as an int tuple"""
Expand Down
4 changes: 2 additions & 2 deletions arcade/gl/framebuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def _use(self, *, force: bool = False):

def clear(
self,
color: Union[RGBOrA255, RGBOrANormalized] =(0.0, 0.0, 0.0, 0.0),
color: Union[RGBOrA255, RGBOrANormalized] = (0.0, 0.0, 0.0, 0.0),
*,
depth: float = 1.0,
normalized: bool = False,
Expand Down Expand Up @@ -393,7 +393,7 @@ def clear(
# mypy does not understand that color[3] is guaranteed to work in this codepath, pyright does.
# We can remove this type: ignore if we switch to pyright.
gl.glClearColor(
color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255 # type: ignore
color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255 # type: ignore
)

if self.depth_attachment:
Expand Down
2 changes: 1 addition & 1 deletion arcade/gl/glsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _find_glsl_version(self) -> int:
pass

source = "\n".join(
f"{str(i+1).zfill(3)}: {line} " for i, line in enumerate(self._lines)
f"{str(i + 1).zfill(3)}: {line} " for i, line in enumerate(self._lines)
)

raise ShaderException(
Expand Down
2 changes: 1 addition & 1 deletion arcade/gl/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def compile_shader(source: str, shader_type: PyGLenum) -> gl.GLuint:
f"---- [{SHADER_TYPE_NAMES[shader_type]}] ---\n"
)
+ "\n".join(
f"{str(i+1).zfill(3)}: {line} "
f"{str(i + 1).zfill(3)}: {line} "
for i, line in enumerate(source.split("\n"))
)
)
Expand Down
3 changes: 2 additions & 1 deletion arcade/gui/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

P = TypeVar("P")


class _Obs(Generic[P]):
"""
Internal holder for Property value and change listeners
Expand Down Expand Up @@ -78,7 +79,7 @@ def __set_name__(self, owner, name):

def __get__(self, instance, owner) -> P:
if instance is None:
return self # type: ignore
return self # type: ignore
return self.get(instance)

def __set__(self, instance, value):
Expand Down
1 change: 1 addition & 0 deletions arcade/gui/widgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from arcade.gui.property import Property, bind
from arcade.gui.style import UIStyleBase, UIStyledWidget


@dataclass
class UISliderStyle(UIStyleBase):
"""
Expand Down
4 changes: 2 additions & 2 deletions arcade/hitbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_adjusted_points(self) -> Sequence[Point]:
* After properties affecting adjusted position were changed
"""
if not self._adjusted_cache_dirty:
return self._adjusted_points # type: ignore
return self._adjusted_points # type: ignore

def _adjust_point(point) -> Point:
x, y = point
Expand All @@ -233,7 +233,7 @@ def _adjust_point(point) -> Point:

self._adjusted_points = [_adjust_point(point) for point in self.points]
self._adjusted_cache_dirty = False
return self._adjusted_points # type: ignore [return-value]
return self._adjusted_points # type: ignore [return-value]


class RotatableHitBox(HitBox):
Expand Down
2 changes: 1 addition & 1 deletion arcade/joysticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_joysticks() -> List[Joystick]:

:return: List of game controllers
"""
return pyglet.input.get_joysticks() # type: ignore # pending https://github.com/pyglet/pyglet/issues/842
return pyglet.input.get_joysticks() # type: ignore # pending https://github.com/pyglet/pyglet/issues/842


def get_game_controllers() -> List[Joystick]:
Expand Down
1 change: 1 addition & 0 deletions arcade/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"get_angle_radians",
]


def round_fast(value: float, precision: int) -> float:
"""
A high performance version of python's built-in round() function.
Expand Down
2 changes: 1 addition & 1 deletion arcade/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def recalculate(self):
def astar_calculate_path(start_point: Point,
end_point: Point,
astar_barrier_list: AStarBarrierList,
diagonal_movement: bool=True) -> Optional[List[Point]]:
diagonal_movement: bool = True) -> Optional[List[Point]]:
"""
Calculates the path using AStarSearch Algorithm and returns the path

Expand Down
4 changes: 2 additions & 2 deletions arcade/perf_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def update_graph(self, delta_time: float):
# Clear and return if timings are disabled
if not arcade.timings_enabled():
# Please forgive the ugly spacing. It makes type checking work.
with atlas.render_into( # type: ignore
with atlas.render_into( # type: ignore
self.minimap_texture, projection=self.proj) as fbo:
fbo.clear(color=(0, 0, 0, 255))
return
Expand Down Expand Up @@ -288,7 +288,7 @@ def update_graph(self, delta_time: float):

# Render to the internal texture
# This ugly spacing is intentional to make type checking work.
with atlas.render_into( # type: ignore
with atlas.render_into( # type: ignore
self.minimap_texture, projection=self.proj) as fbo:

# Set the background color
Expand Down
2 changes: 1 addition & 1 deletion arcade/perf_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def disable_timings() -> None:
raise ValueError("Timings are not enabled.")

# Restore the original pyglet dispatch event function
pyglet.window.BaseWindow.dispatch_event = _pyglets_dispatch_event # type: ignore
pyglet.window.BaseWindow.dispatch_event = _pyglets_dispatch_event # type: ignore

clear_timings()

Expand Down
2 changes: 2 additions & 0 deletions arcade/physics_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def _move_sprite(moving_sprite: Sprite, walls: List[SpriteList[SpriteType]], ram
# print(f"Move 2 - {end_time - start_time:7.4f} {loop_count}")

return complete_hit_list


class PhysicsEngineSimple:
"""
Simplistic physics engine for use in games without gravity, such as top-down
Expand Down
1 change: 1 addition & 0 deletions arcade/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def resolve(path: Union[str, Path]) -> Path:
except FileNotFoundError:
raise FileNotFoundError(f"Cannot locate resource : {path}")


def add_resource_handle(handle: str, path: Union[str, Path]) -> None:
"""
Add a resource handle or path to an existing handle.
Expand Down
6 changes: 3 additions & 3 deletions arcade/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def add_sprite_list(
sprite_list = SpriteList(use_spatial_hash=use_spatial_hash)
if name in self._name_mapping.keys():
self.remove_sprite_list_by_name(name)
warn("A Spritelist with the name: "+name+", is already in the scene, will override Spritelist")
warn(f"A Spritelist with the name: '{name}', is already in the scene, will override Spritelist")
self._name_mapping[name] = sprite_list
self._sprite_lists.append(sprite_list)

Expand Down Expand Up @@ -228,7 +228,7 @@ def add_sprite_list_before(
sprite_list = SpriteList(use_spatial_hash=use_spatial_hash)
if name in self._name_mapping.keys():
self.remove_sprite_list_by_name(name)
warn("A Spritelist with the name: "+name+", is already in the scene, will override Spritelist")
warn(f"A Spritelist with the name: '{name}', is already in the scene, will override Spritelist")
self._name_mapping[name] = sprite_list
before_list = self._name_mapping[before]
index = self._sprite_lists.index(before_list)
Expand Down Expand Up @@ -288,7 +288,7 @@ def add_sprite_list_after(
sprite_list = SpriteList(use_spatial_hash=use_spatial_hash)
if name in self._name_mapping.keys():
self.remove_sprite_list_by_name(name)
warn("A Spritelist with the name: "+name+", is already in the scene, will override Spritelist")
warn(f"A Spritelist with the name: '{name}', is already in the scene, will override Spritelist")
self._name_mapping[name] = sprite_list
after_list = self._name_mapping[after]
index = self._sprite_lists.index(after_list) + 1
Expand Down
3 changes: 1 addition & 2 deletions arcade/shape_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from collections import OrderedDict
import itertools
import math
from array import array
from typing import (
Dict,
List,
Expand Down Expand Up @@ -120,7 +119,7 @@ def draw(self):
if self.geometry is None:
self._init_geometry()

self.geometry.render(self.program, mode=self.mode) # pyright: ignore [reportOptionalMemberAccess]
self.geometry.render(self.program, mode=self.mode) # pyright: ignore [reportOptionalMemberAccess]


def create_line(
Expand Down
8 changes: 4 additions & 4 deletions arcade/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _on_player_eos():
media.Source._players.remove(player)
# There is a closure on player. To get the refcount to 0,
# we need to delete this function.
player.on_player_eos = None # type: ignore # pending https://github.com/pyglet/pyglet/issues/845
player.on_player_eos = None # type: ignore # pending https://github.com/pyglet/pyglet/issues/845

player.on_player_eos = _on_player_eos
return player
Expand All @@ -116,12 +116,12 @@ def stop(self, player: media.Player) -> None:
def get_length(self) -> float:
"""Get length of audio in seconds"""
# We validate that duration is known when loading the source
return self.source.duration # type: ignore
return self.source.duration # type: ignore

def is_complete(self, player: media.Player) -> bool:
"""Return true if the sound is done playing."""
# We validate that duration is known when loading the source
return player.time >= self.source.duration # type: ignore
return player.time >= self.source.duration # type: ignore

def is_playing(self, player: media.Player) -> bool:
"""
Expand All @@ -140,7 +140,7 @@ def get_volume(self, player: media.Player) -> float:
:param player: Player returned from :func:`play_sound`.
:returns: A float, 0 for volume off, 1 for full volume.
"""
return player.volume # type: ignore # pending https://github.com/pyglet/pyglet/issues/847
return player.volume # type: ignore # pending https://github.com/pyglet/pyglet/issues/847

def set_volume(self, volume, player: media.Player) -> None:
"""
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 @@ -92,7 +92,7 @@ def _check_for_collision(sprite1: BasicSprite, sprite2: BasicSprite) -> bool:
:returns: True if sprites overlap.
"""

#NOTE: for speed becuase attribute look ups are slow.
# NOTE: for speed because attribute look ups are slow.
sprite1_position = sprite1._position
sprite1_width = sprite1._width
sprite1_height = sprite1._height
Expand Down
Loading