diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3d5d6d2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +name: Lint +on: [push, pull_request] +jobs: + lint: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: ["3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements_dev.txt + - name: Analysing the code with mypy + run: | + mypy $(git ls-files '*.py') + - name: Analysing the code with ruff + run: | + ruff check $(git ls-files '*.py') diff --git a/pyproject.toml b/pyproject.toml index 905b468..f7ae139 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,19 +11,19 @@ readme = "README.md" requires-python = ">=3.11" license = { file = "LICENSE" } dependencies = [ - "attrs==23.1.0", - "loguru==0.7.2", - "numpy==1.26.3", - "pygame-ce==2.4.0", - "toml==0.10.2", + "attrs==23.1.0", + "loguru==0.7.2", + "numpy==1.26.3", + "pygame-ce==2.4.0", + "toml==0.10.2", ] keywords = ["tetris", "game", "pygame"] classifiers = [ - "Development Status :: 3 - Alpha", - "License :: OSI Approved :: GPLv3 License", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: GPLv3 License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] [project.urls] @@ -45,40 +45,41 @@ warn_unused_configs = true [tool.ruff] extend-select = [ - "B", - "BLE", - "C4", - "ERA", - "I", - "ICN", - "INP", - "ISC", - "N", - "NPY", - "PGH", - "PIE", - # "PTH", - "Q", - "RET", - "RSE", - "RUF", - "S", - "SIM", - "T20", - "TCH", - "TID", - "YTT", + "B", + "BLE", + "C4", + "ERA", + "I", + "ICN", + "INP", + "ISC", + "N", + "NPY", + "PGH", + "PIE", + # "PTH", + "Q", + "RET", + "RSE", + "RUF", + "S", + "SIM", + "T20", + "TCH", + "TID", + "YTT", ] ignore = ["E741"] show-fixes = true line-length = 120 indent-width = 4 -target-version = "py38" +target-version = "py310" [tool.ruff.lint] extend-select = ["I"] preview = true +fixable = ["ALL"] [tool.ruff.format] quote-style = "double" diff --git a/requirements_dev.txt b/requirements_dev.txt index f3bc67b..fa4853f 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,3 +1,4 @@ mypy==1.8.0 pytest==7.4.3 ruff==0.1.9 +types-toml==0.10.8.7 diff --git a/src/game/screens/tetris.py b/src/game/screens/tetris.py index 40b5d63..5764d21 100644 --- a/src/game/screens/tetris.py +++ b/src/game/screens/tetris.py @@ -355,10 +355,10 @@ class Tetris(BaseScreen): def _initialize_timers(self) -> None: """Initialize game timers.""" self.timers = Timers( - Timer(self.initial_block_speed, True, self.move_down), - Timer(CONFIG.game.movment_delay), - Timer(CONFIG.game.rotation_delay), - Timer(CONFIG.game.drop_delay), + Timer(self.initial_block_speed, True, self.move_down), # type: ignore + Timer(CONFIG.game.movment_delay), # type: ignore + Timer(CONFIG.game.rotation_delay), # type: ignore + Timer(CONFIG.game.drop_delay), # type: ignore ) self.timers.vertical.activate() diff --git a/tetris/__main__.py b/tetris/__main__.py index a47c87b..6152b49 100755 --- a/tetris/__main__.py +++ b/tetris/__main__.py @@ -57,10 +57,10 @@ def run() -> None: game.Main(GameMode.PLAYER).run() -def main(args: argparse.ArgumentParser) -> None: - if args.debug: +def main(args) -> None: + if args.debug: # type: ignore level = "debug" - elif args.verbose: + elif args.verbose: # type: ignore level = "info" else: level = "warning" @@ -72,4 +72,4 @@ def main(args: argparse.ArgumentParser) -> None: if __name__ == "__main__": args = parser.parse_args() - main(args) + main(args) # type: ignore