Skip to content

Commit

Permalink
chore: fix pylint issues + black
Browse files Browse the repository at this point in the history
  • Loading branch information
koen1711 committed May 29, 2024
1 parent f3ab0ac commit 020e74c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
5 changes: 3 additions & 2 deletions play/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import pygame

pygame.init()

from .generators import *
from .events import *
from .utils import *
from .random import *


pygame.init() # pylint: disable=no-member
9 changes: 4 additions & 5 deletions play/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

import pygame # pylint: disable=import-error

from ..globals import all_sprites
from ..utils.async_helpers import _make_async
from ..utils import color_name_to_rgb as _color_name_to_rgb
from ..globals import all_sprites, backdrop
from ..io import screen, PYGAME_DISPLAY
from ..io.keypress import (
pygame_key_to_name as _pygame_key_to_name,
Expand All @@ -23,7 +21,8 @@
from ..objects.line import Line
from ..objects.sprite import point_touching_sprite
from ..physics import simulate_physics
from ..globals import BACKDROP
from ..utils import color_name_to_rgb as _color_name_to_rgb
from ..utils.async_helpers import _make_async

_when_program_starts_callbacks = []
_clock = pygame.time.Clock()
Expand Down Expand Up @@ -128,7 +127,7 @@ def _game_loop():
# 10. render sprites (with correct z-order)
# 11. call event loop again

PYGAME_DISPLAY.fill(_color_name_to_rgb(BACKDROP))
PYGAME_DISPLAY.fill(_color_name_to_rgb(backdrop))

# BACKGROUND COLOR
# note: cannot use screen.fill((1, 1, 1)) because pygame's screen
Expand Down
5 changes: 1 addition & 4 deletions play/api/generators.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Generators for creating new objects."""

import asyncio as _asyncio
import random as _random

from ..objects import Box, Circle, Line, Text, Group
from ..objects import Box, Circle, Line, Text


def new_text( # pylint: disable=too-many-arguments
Expand Down
5 changes: 5 additions & 0 deletions play/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import asyncio as _asyncio
import logging as _logging

import pygame # pylint: disable=import-error

from .events import _when_program_starts_callbacks, _game_loop, _loop
from ..utils import color_name_to_rgb as _color_name_to_rgb
from ..globals import backdrop as _backdrop

BACKDROP = _backdrop


def start_program():
Expand Down
2 changes: 1 addition & 1 deletion play/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

_walls = []

BACKDROP = (255, 255, 255)
backdrop = (255, 255, 255)

COLOR_NAMES = {
"aliceblue": (240, 248, 255),
Expand Down
4 changes: 2 additions & 2 deletions play/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, width=800, height=600):
self._width = width
self._height = height
PYGAME_DISPLAY = pygame.display.set_mode(
(width, height), pygame.DOUBLEBUF
(width, height), pygame.DOUBLEBUF # pylint: disable=no-member
) # pylint: disable=no-member
pygame.display.set_caption("Python Play")
self._fullscreen = False
Expand Down Expand Up @@ -96,7 +96,7 @@ def enable_fullscreen(self):
else:
PYGAME_DISPLAY = pygame.display.set_mode(
(self.width, self.height),
SCALED + NOFRAME + FULLSCREEN,
SCALED + NOFRAME + FULLSCREEN, # pylint: disable=undefined-variable
32, # pylint: disable=undefined-variable
) # all flags are necessary

Expand Down
10 changes: 5 additions & 5 deletions play/objects/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _compute_primary_surface(self):
height = self.thickness + 1

self._primary_pygame_surface = pygame.Surface(
(width, height), pygame.SRCALPHA
(width, height), pygame.SRCALPHA # pylint: disable=no-member
) # pylint: disable=no-member
# self._primary_pygame_surface.set_colorkey((255,255,255, 255)) # set background to transparent

Expand All @@ -79,17 +79,17 @@ def _compute_primary_surface(self):
self._compute_secondary_surface(force=True)

def _compute_secondary_surface(self, force=False):
self._secondary_pygame_surface = (
self._secondary_pygame_surface = ( # pylint: disable=attribute-defined-outside-init
self._primary_pygame_surface.copy()
) # pylint: disable=attribute-defined-outside-init
)

if force or self._transparency != 100:
self._secondary_pygame_surface.set_alpha(
round((self._transparency / 100.0) * 255)
)

self._should_recompute_secondary_surface = (
False # pylint: disable=attribute-defined-outside-init
self._should_recompute_secondary_surface = ( # pylint: disable=attribute-defined-outside-init
False
)

##### color #####
Expand Down

0 comments on commit 020e74c

Please sign in to comment.