From 12776ee1811016d37f4582ead56eb68d32036d29 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Mon, 8 Jan 2024 18:46:23 +0200 Subject: [PATCH] revert --- src/game/screens/base.py | 5 +---- src/game/screens/base_button.py | 5 +---- src/game/screens/button.py | 5 +---- src/game/screens/game.py | 11 ++--------- src/game/screens/main.py | 9 ++------- src/game/screens/preview.py | 7 +------ src/game/screens/tetris.py | 9 ++------- src/game/sprites/block.py | 8 ++------ src/game/sprites/tetromino.py | 10 +++------- src/game/timer.py | 5 +---- src/utils/config.py | 9 ++------- src/utils/figure.py | 6 ++---- src/utils/settings.py | 7 ++----- src/utils/tuples.py | 5 +---- 14 files changed, 23 insertions(+), 78 deletions(-) diff --git a/src/game/screens/base.py b/src/game/screens/base.py index ad2f9c4..acdb47a 100644 --- a/src/game/screens/base.py +++ b/src/game/screens/base.py @@ -1,8 +1,5 @@ from abc import ABC, ABCMeta, abstractmethod -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from typing import Any +from typing import Any class BaseScreen(ABC, metaclass=ABCMeta): diff --git a/src/game/screens/base_button.py b/src/game/screens/base_button.py index 231e19f..237a43c 100644 --- a/src/game/screens/base_button.py +++ b/src/game/screens/base_button.py @@ -1,8 +1,5 @@ from abc import ABC, ABCMeta, abstractmethod -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from typing import Any, Callable, Optional +from typing import Any, Callable, Optional import pygame diff --git a/src/game/screens/button.py b/src/game/screens/button.py index 0d86ec4..bfbcee4 100644 --- a/src/game/screens/button.py +++ b/src/game/screens/button.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING +from typing import Any, Callable, Optional import pygame from utils import CONFIG @@ -6,9 +6,6 @@ from utils import CONFIG from .base import BaseScreen, SceenElement, TextScreen from .base_button import BaseButton -if TYPE_CHECKING: - from typing import Any, Callable, Optional - class Button(BaseButton, BaseScreen, SceenElement, TextScreen): def __init__(self, text: str, action: Optional[Callable[[], Optional[Any]]]) -> None: diff --git a/src/game/screens/game.py b/src/game/screens/game.py index f374ec3..db11dc0 100644 --- a/src/game/screens/game.py +++ b/src/game/screens/game.py @@ -1,18 +1,13 @@ -from typing import TYPE_CHECKING +from typing import Any import pygame -from utils import CONFIG, GameMode +from utils import CONFIG, Figure, GameMode from .base import BaseScreen from .preview import Preview from .score import Score from .tetris import Tetris -if TYPE_CHECKING: - from typing import Any - - from utils import Figure - class Game(BaseScreen): """ @@ -56,14 +51,12 @@ class Game(BaseScreen): def run(self) -> None: """Run a single iteration of the game loop.""" - self.draw() self.tetris.run() self.score.run() self.preview.update(self.next_figure) self.preview.run() - self.draw() self.clock.tick(CONFIG.game.fps) def mute(self) -> None: diff --git a/src/game/screens/main.py b/src/game/screens/main.py index 3e98147..8d38995 100644 --- a/src/game/screens/main.py +++ b/src/game/screens/main.py @@ -1,19 +1,14 @@ import sys -from typing import TYPE_CHECKING +from typing import Optional import pygame from loguru import logger -from utils import CONFIG, read_settings +from utils import CONFIG, GameMode, read_settings from .base import BaseScreen, SceenElement, TextScreen from .button import Button from .game import Game -if TYPE_CHECKING: - from typing import Optional - - from utils import GameMode - class Main(BaseScreen, SceenElement, TextScreen): """ diff --git a/src/game/screens/preview.py b/src/game/screens/preview.py index 6a766ef..3a761dc 100644 --- a/src/game/screens/preview.py +++ b/src/game/screens/preview.py @@ -1,13 +1,8 @@ -from typing import TYPE_CHECKING - import pygame -from utils import CONFIG +from utils import CONFIG, Figure from .base import BaseScreen, SceenElement -if TYPE_CHECKING: - from utils import Figure - class Preview(BaseScreen, SceenElement): """ diff --git a/src/game/screens/tetris.py b/src/game/screens/tetris.py index 3e6277f..40b5d63 100644 --- a/src/game/screens/tetris.py +++ b/src/game/screens/tetris.py @@ -1,20 +1,15 @@ -from typing import TYPE_CHECKING +from typing import Any, Callable, Optional import numpy as np import pygame from loguru import logger from utils import CONFIG, Direction, Figure, GameMode, Rotation -from game.sprites import Tetromino +from game.sprites import Block, Tetromino from game.timer import Timer, Timers from .base import BaseScreen -if TYPE_CHECKING: - from typing import Any, Callable, Optional - - from game.sprites import Block - class Tetris(BaseScreen): """ diff --git a/src/game/sprites/block.py b/src/game/sprites/block.py index 2076cac..432c57c 100644 --- a/src/game/sprites/block.py +++ b/src/game/sprites/block.py @@ -1,13 +1,9 @@ -from typing import TYPE_CHECKING +from typing import Any, Optional +import numpy as np import pygame from utils import CONFIG, Rotation -if TYPE_CHECKING: - from typing import Any, Optional - - import numpy as np - class Block(pygame.sprite.Sprite): """ diff --git a/src/game/sprites/tetromino.py b/src/game/sprites/tetromino.py index acf25f6..7b5c1cc 100644 --- a/src/game/sprites/tetromino.py +++ b/src/game/sprites/tetromino.py @@ -1,14 +1,10 @@ -from typing import TYPE_CHECKING +from typing import Any, Callable, Optional +import numpy as np import pygame from utils import CONFIG, Direction, Figure, Rotation -if TYPE_CHECKING: - from typing import Any, Callable, Optional - - import numpy as np - - from .block import Block +from .block import Block class Tetromino: diff --git a/src/game/timer.py b/src/game/timer.py index 60d9603..1df5ce1 100644 --- a/src/game/timer.py +++ b/src/game/timer.py @@ -1,11 +1,8 @@ -from typing import TYPE_CHECKING +from typing import Any, Callable, NamedTuple, Optional import pygame from attrs import define, field -if TYPE_CHECKING: - from typing import Any, Callable, NamedTuple, Optional - @define class Timer: diff --git a/src/utils/config.py b/src/utils/config.py index e2cc182..9365a84 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -1,6 +1,7 @@ -from typing import TYPE_CHECKING +from pathlib import Path from attr import define +from pygame import Vector2 as Vec2 from .colors import COLOR_DICT, TokyoNightNight from .colors.tokyonight.base import Color @@ -8,12 +9,6 @@ from .path import BASE_PATH from .settings import read_settings from .tuples import Size -if TYPE_CHECKING: - from pathlib import Path - - from pygame import Vector2 as Vec2 - - PADDING = 20 diff --git a/src/utils/figure.py b/src/utils/figure.py index fb6b8fc..061ee8e 100644 --- a/src/utils/figure.py +++ b/src/utils/figure.py @@ -1,15 +1,13 @@ import random from enum import Enum -from typing import TYPE_CHECKING, NamedTuple +from typing import NamedTuple import pygame +from pygame import Vector2 as Vec2 from .colors import TokyoNightNight from .path import BASE_PATH -if TYPE_CHECKING: - from pygame import Vector2 as Vec2 - class FigureConfig(NamedTuple): """ diff --git a/src/utils/settings.py b/src/utils/settings.py index a349bce..b59b9f2 100644 --- a/src/utils/settings.py +++ b/src/utils/settings.py @@ -1,14 +1,11 @@ -from typing import TYPE_CHECKING +from pathlib import Path +from typing import Any import toml from loguru import logger from .path import BASE_PATH -if TYPE_CHECKING: - from pathlib import Path - from typing import Any - def save_settings(settings: dict[str, Any], file_path: Path) -> None: """ diff --git a/src/utils/tuples.py b/src/utils/tuples.py index 1ca516a..27e6e0a 100644 --- a/src/utils/tuples.py +++ b/src/utils/tuples.py @@ -1,7 +1,4 @@ -from typing import TYPE_CHECKING, NamedTuple - -if TYPE_CHECKING: - from typing import Union +from typing import NamedTuple, Union class Size(NamedTuple):