Skip to content

Commit f0ba0a5

Browse files
committed
ruff
1 parent e70d005 commit f0ba0a5

30 files changed

Lines changed: 70 additions & 36 deletions

‎.github/workflows/python-app.yml‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,23 @@ jobs:
1616

1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@v6
19+
uses: actions/checkout@v4
2020

2121
- name: Set up Python
22-
uses: actions/setup-python@v6
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
25+
cache: pip
2526

2627
- name: Install dependencies
2728
run: |
28-
python -m pip install --upgrade pip
2929
pip install ruff pytest
30-
pip install pygame-ce pytmx
3130
pip install .
3231
33-
- name: Lint with ruff
32+
- name: Lint with Ruff
3433
run: |
35-
ruff check .
36-
ruff format --check .
34+
ruff check --output-format=github .
35+
ruff format --check
3736
3837
- name: Run tests
3938
run: pytest tests

‎Makefile‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PACKAGE_NAME := pyscroll
22

3-
.PHONY: build clean publish install lint format test
3+
.PHONY: build clean publish install lint fix format test all
44

55
build:
66
python3 -m build
@@ -15,8 +15,15 @@ install:
1515
pip install -e .
1616

1717
lint:
18-
-python -m ruff check . --fix
19-
python -m ruff format .
18+
ruff check .
19+
20+
fix:
21+
ruff check . --fix --unsafe-fixes
22+
23+
format:
24+
ruff format .
2025

2126
test:
2227
pytest tests/
28+
29+
all: fix format lint

‎apps/demo/camera_demo.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from pygame.math import Vector2
88
from pygame.sprite import Sprite
99
from pygame.surface import Surface
10+
from pytmx.util_pygame import load_pygame # type: ignore
11+
1012
from pyscroll.camera import (
1113
BasicCamera,
1214
CutsceneCamera,
@@ -18,7 +20,6 @@
1820
from pyscroll.data import MapAggregator, TiledMapData
1921
from pyscroll.group import PyscrollGroup
2022
from pyscroll.orthographic import BufferedRenderer
21-
from pytmx.util_pygame import load_pygame # type: ignore
2223

2324
CURRENT_DIR = Path(__file__).parent
2425
RESOURCES_DIR = CURRENT_DIR
@@ -112,9 +113,11 @@ def handle_input(self):
112113

113114
elif event.key == pygame.locals.K_EQUALS:
114115
self.map_layer.zoom += ZOOM_STEP
115-
elif event.key == pygame.locals.K_MINUS:
116-
if self.map_layer.zoom - ZOOM_STEP > 0:
117-
self.map_layer.zoom -= ZOOM_STEP
116+
elif (
117+
event.key == pygame.locals.K_MINUS
118+
and self.map_layer.zoom - ZOOM_STEP > 0
119+
):
120+
self.map_layer.zoom -= ZOOM_STEP
118121

119122
elif event.type == pygame.locals.VIDEORESIZE:
120123
self.screen = pygame.display.set_mode(

‎apps/demo/demo-stitched.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
from pygame.rect import Rect
3030
from pygame.sprite import Sprite
3131
from pygame.surface import Surface
32+
from pytmx.util_pygame import load_pygame # type: ignore
33+
3234
from pyscroll.camera import FollowCamera
3335
from pyscroll.data import MapAggregator, TiledMapData
3436
from pyscroll.group import PyscrollGroup
3537
from pyscroll.orthographic import BufferedRenderer
36-
from pytmx.util_pygame import load_pygame # type: ignore
3738

3839
# define configuration variables here
3940
CURRENT_DIR = Path(__file__).parent

‎apps/demo/demo.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import logging
1515
from collections import deque
1616
from pathlib import Path
17-
from typing import Deque
1817

1918
import pygame
2019
from pygame.font import Font
@@ -34,9 +33,10 @@
3433
)
3534
from pygame.math import Vector2
3635
from pygame.surface import Surface
36+
from pytmx.util_pygame import load_pygame # type: ignore
37+
3738
from pyscroll.data import TiledMapData
3839
from pyscroll.orthographic import BufferedRenderer
39-
from pytmx.util_pygame import load_pygame # type: ignore
4040

4141
logger = logging.getLogger(__name__)
4242
logger.setLevel(logging.INFO)
@@ -136,7 +136,7 @@ def update(self, dt: float) -> None:
136136
def run(self) -> None:
137137
clock = pygame.time.Clock()
138138
self.running = True
139-
fps_log: Deque[float] = deque(maxlen=20)
139+
fps_log: deque[float] = deque(maxlen=20)
140140

141141
while self.running:
142142
clock.tick(120)

‎apps/demo/procedural.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# around with. Think of it as a quick visual smoke test rather than a full game.
55

66
import pygame
7+
78
from pyscroll.data import ProceduralData
89
from pyscroll.orthographic import BufferedRenderer
910

‎apps/demo/tile_animation_enhanced.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import pygame
1515
from pygame.locals import QUIT
16+
1617
from pyscroll.animation import AnimationFrame, AnimationToken
1718

1819

‎apps/demo/tile_animation_group.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import pygame
1717
from pygame.locals import QUIT
18+
1819
from pyscroll.animation import AnimationFrame, AnimationToken
1920

2021

‎apps/demo/tile_animation_simple.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import pygame
1414
from pygame.locals import QUIT
15+
1516
from pyscroll.animation import AnimationFrame, AnimationToken
1617

1718

‎apps/demo/translate_buffered.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
from pygame.rect import Rect
1212
from pygame.sprite import Group, Sprite
1313
from pygame.surface import Surface
14+
from pytmx.util_pygame import load_pygame # type: ignore
15+
1416
from pyscroll.data import TiledMapData
1517
from pyscroll.orthographic import BufferedRenderer
16-
from pytmx.util_pygame import load_pygame # type: ignore
1718

1819
# Constants
1920
RESOURCES_DIR = Path(__file__).parent

0 commit comments

Comments
 (0)