From 4c0feb51e1e51dddb90ddc509fcc75ebf91b5c7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:45:34 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7badadae..718837ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: fix-byte-order-marker - id: detect-private-key - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.2 + rev: v0.3.2 hooks: - id: ruff args: [--fix-only, --exit-non-zero-on-fix] From 396f279204b0f4b972cb856d5f8c8a35034f857e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:45:41 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- build_libtcod.py | 1 + build_sdl.py | 1 + examples/audio_tone.py | 1 + examples/cavegen.py | 1 + examples/distribution/PyInstaller/main.py | 1 + examples/distribution/cx_Freeze/main.py | 1 + examples/eventget.py | 1 + examples/framerate.py | 1 + examples/samples_tcod.py | 1 + examples/sdl-hello-world.py | 1 + examples/thread_jobs.py | 1 + examples/ttf.py | 1 + libtcodpy.py | 1 + scripts/generate_charmap_table.py | 1 + scripts/get_release_description.py | 1 + scripts/tag_release.py | 1 + setup.py | 1 + tcod/__init__.py | 1 + tcod/__pyinstaller/__init__.py | 1 + tcod/__pyinstaller/hook-tcod.py | 1 + tcod/_internal.py | 1 + tcod/bsp.py | 1 + tcod/cffi.py | 1 + tcod/color.py | 1 + tcod/console.py | 1 + tcod/constants.py | 1 + tcod/context.py | 1 + tcod/event.py | 24 ++++------------------- tcod/image.py | 1 + tcod/libtcodpy.py | 9 ++------- tcod/los.py | 1 + tcod/map.py | 1 + tcod/noise.py | 1 + tcod/path.py | 1 + tcod/random.py | 1 + tcod/sdl/__init__.py | 1 + tcod/sdl/_internal.py | 1 + tcod/sdl/audio.py | 1 + tcod/sdl/joystick.py | 1 + tcod/sdl/mouse.py | 1 + tcod/sdl/render.py | 1 + tcod/sdl/video.py | 1 + tcod/tcod.py | 1 + tcod/tileset.py | 1 + tests/conftest.py | 1 + tests/test_console.py | 1 + tests/test_deprecated.py | 1 + tests/test_libtcodpy.py | 1 + tests/test_noise.py | 1 + tests/test_parser.py | 1 + tests/test_random.py | 1 + tests/test_sdl.py | 1 + tests/test_sdl_audio.py | 1 + tests/test_tcod.py | 1 + tests/test_tileset.py | 1 + 55 files changed, 59 insertions(+), 27 deletions(-) diff --git a/build_libtcod.py b/build_libtcod.py index 56161182..2ffe6aad 100755 --- a/build_libtcod.py +++ b/build_libtcod.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Parse and compile libtcod and SDL sources for CFFI.""" + from __future__ import annotations import contextlib diff --git a/build_sdl.py b/build_sdl.py index 56fa87de..629c98f4 100755 --- a/build_sdl.py +++ b/build_sdl.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Build script to parse SDL headers and generate CFFI bindings.""" + from __future__ import annotations import io diff --git a/examples/audio_tone.py b/examples/audio_tone.py index 052f8a39..22f21133 100755 --- a/examples/audio_tone.py +++ b/examples/audio_tone.py @@ -3,6 +3,7 @@ Opens an audio device using SDL and plays a square wave for 1 second. """ + import math import time from typing import Any diff --git a/examples/cavegen.py b/examples/cavegen.py index 4ae22ac3..8b95d3fc 100755 --- a/examples/cavegen.py +++ b/examples/cavegen.py @@ -6,6 +6,7 @@ This will print the result to the console, so be sure to run this from the command line. """ + from typing import Any import numpy as np diff --git a/examples/distribution/PyInstaller/main.py b/examples/distribution/PyInstaller/main.py index 51e31e79..b2767fed 100755 --- a/examples/distribution/PyInstaller/main.py +++ b/examples/distribution/PyInstaller/main.py @@ -4,6 +4,7 @@ # example script. This work is published from: United States. # https://creativecommons.org/publicdomain/zero/1.0/ """PyInstaller main script example.""" + import sys from pathlib import Path diff --git a/examples/distribution/cx_Freeze/main.py b/examples/distribution/cx_Freeze/main.py index 0c85ca83..79846377 100755 --- a/examples/distribution/cx_Freeze/main.py +++ b/examples/distribution/cx_Freeze/main.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """cx_Freeze main script example.""" + import tcod.console import tcod.context import tcod.event diff --git a/examples/eventget.py b/examples/eventget.py index 0af84d04..ada61668 100755 --- a/examples/eventget.py +++ b/examples/eventget.py @@ -4,6 +4,7 @@ # published from: United States. # https://creativecommons.org/publicdomain/zero/1.0/ """An demonstration of event handling using the tcod.event module.""" + from typing import List, Set import tcod.context diff --git a/examples/framerate.py b/examples/framerate.py index a51f83ff..25a1dd3f 100755 --- a/examples/framerate.py +++ b/examples/framerate.py @@ -4,6 +4,7 @@ # published from: United States. # https://creativecommons.org/publicdomain/zero/1.0/ """A system to control time since the original libtcod tools are deprecated.""" + import statistics import time from collections import deque diff --git a/examples/samples_tcod.py b/examples/samples_tcod.py index 7baf6af2..d2a8cb86 100755 --- a/examples/samples_tcod.py +++ b/examples/samples_tcod.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """This code demonstrates various usages of python-tcod.""" + # To the extent possible under law, the libtcod maintainers have waived all # copyright and related or neighboring rights to these samples. # https://creativecommons.org/publicdomain/zero/1.0/ diff --git a/examples/sdl-hello-world.py b/examples/sdl-hello-world.py index b9c07547..4e314805 100644 --- a/examples/sdl-hello-world.py +++ b/examples/sdl-hello-world.py @@ -1,4 +1,5 @@ """Hello world using tcod's SDL API and using Pillow for the TTF rendering.""" + from pathlib import Path import numpy as np diff --git a/examples/thread_jobs.py b/examples/thread_jobs.py index fa99a465..0c616bba 100755 --- a/examples/thread_jobs.py +++ b/examples/thread_jobs.py @@ -13,6 +13,7 @@ Typically the field-of-view tasks run good but not great, and the path-finding tasks run poorly. """ + import concurrent.futures import multiprocessing import platform diff --git a/examples/ttf.py b/examples/ttf.py index fb0336cb..3e13a837 100755 --- a/examples/ttf.py +++ b/examples/ttf.py @@ -5,6 +5,7 @@ pip install freetype-py """ + # To the extent possible under law, the libtcod maintainers have waived all # copyright and related or neighboring rights to this example script. # https://creativecommons.org/publicdomain/zero/1.0/ diff --git a/libtcodpy.py b/libtcodpy.py index 7947f394..76317e99 100644 --- a/libtcodpy.py +++ b/libtcodpy.py @@ -1,4 +1,5 @@ """Deprecated module alias for tcod.libtcodpy, use 'import tcod as libtcodpy' instead.""" + import warnings from tcod.libtcodpy import * # noqa: F403 diff --git a/scripts/generate_charmap_table.py b/scripts/generate_charmap_table.py index c4137e8a..50b6a779 100755 --- a/scripts/generate_charmap_table.py +++ b/scripts/generate_charmap_table.py @@ -3,6 +3,7 @@ Uses the tabulate module from PyPI. """ + from __future__ import annotations import argparse diff --git a/scripts/get_release_description.py b/scripts/get_release_description.py index 547f8ca6..889feced 100755 --- a/scripts/get_release_description.py +++ b/scripts/get_release_description.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Print the description used for GitHub Releases.""" + from __future__ import annotations import re diff --git a/scripts/tag_release.py b/scripts/tag_release.py index 7b946513..2155aaae 100755 --- a/scripts/tag_release.py +++ b/scripts/tag_release.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Automate tagged releases of this project.""" + from __future__ import annotations import argparse diff --git a/setup.py b/setup.py index 6e17d0f8..29f9cb3d 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Python-tcod setup script.""" + from __future__ import annotations import platform diff --git a/tcod/__init__.py b/tcod/__init__.py index b8ea0d25..63335ebc 100644 --- a/tcod/__init__.py +++ b/tcod/__init__.py @@ -6,6 +6,7 @@ Read the documentation online: https://python-tcod.readthedocs.io/en/latest/ """ + from __future__ import annotations from pkgutil import extend_path diff --git a/tcod/__pyinstaller/__init__.py b/tcod/__pyinstaller/__init__.py index 7224bb10..2b67c1c0 100644 --- a/tcod/__pyinstaller/__init__.py +++ b/tcod/__pyinstaller/__init__.py @@ -1,4 +1,5 @@ """PyInstaller entry point for tcod.""" + from __future__ import annotations from pathlib import Path diff --git a/tcod/__pyinstaller/hook-tcod.py b/tcod/__pyinstaller/hook-tcod.py index 9790d583..b0cabf38 100644 --- a/tcod/__pyinstaller/hook-tcod.py +++ b/tcod/__pyinstaller/hook-tcod.py @@ -5,6 +5,7 @@ If this hook is ever modified then the contributed hook needs to be removed from: https://github.com/pyinstaller/pyinstaller-hooks-contrib """ + from PyInstaller.utils.hooks import collect_dynamic_libs # type: ignore hiddenimports = ["_cffi_backend"] diff --git a/tcod/_internal.py b/tcod/_internal.py index ef6305bf..cebe249e 100644 --- a/tcod/_internal.py +++ b/tcod/_internal.py @@ -1,4 +1,5 @@ """Internal helper functions used by the rest of the library.""" + from __future__ import annotations import functools diff --git a/tcod/bsp.py b/tcod/bsp.py index cfb6c021..030bb04b 100644 --- a/tcod/bsp.py +++ b/tcod/bsp.py @@ -24,6 +24,7 @@ else: print('Dig a room for %s.' % node) """ + from __future__ import annotations from typing import Any, Iterator diff --git a/tcod/cffi.py b/tcod/cffi.py index d733abea..19a597b6 100644 --- a/tcod/cffi.py +++ b/tcod/cffi.py @@ -1,4 +1,5 @@ """This module handles loading of the libtcod cffi API.""" + from __future__ import annotations import logging diff --git a/tcod/color.py b/tcod/color.py index 37312413..ef75bfb8 100644 --- a/tcod/color.py +++ b/tcod/color.py @@ -1,4 +1,5 @@ """Old libtcod color management.""" + from __future__ import annotations import warnings diff --git a/tcod/console.py b/tcod/console.py index 3512c893..5cd80c3b 100644 --- a/tcod/console.py +++ b/tcod/console.py @@ -4,6 +4,7 @@ To render a console you need a tileset and a window to render to. See :ref:`getting-started` for info on how to set those up. """ + from __future__ import annotations import warnings diff --git a/tcod/constants.py b/tcod/constants.py index f0a596dc..98f1ef1f 100644 --- a/tcod/constants.py +++ b/tcod/constants.py @@ -2,6 +2,7 @@ This module is auto-generated by `build_libtcod.py`. """ + from tcod.color import Color FOV_BASIC = 0 diff --git a/tcod/context.py b/tcod/context.py index 8d5e5259..f22c78de 100644 --- a/tcod/context.py +++ b/tcod/context.py @@ -22,6 +22,7 @@ .. versionadded:: 11.12 """ + from __future__ import annotations import copy diff --git a/tcod/event.py b/tcod/event.py index 41623a93..cb48b047 100644 --- a/tcod/event.py +++ b/tcod/event.py @@ -79,6 +79,7 @@ .. versionadded:: 8.4 """ + from __future__ import annotations import enum @@ -444,12 +445,7 @@ def tile(self, xy: tuple[int, int]) -> None: self._tile = Point(*xy) def __repr__(self) -> str: - return ("tcod.event.{}(position={!r}, tile={!r}, state={})").format( - self.__class__.__name__, - tuple(self.position), - tuple(self.tile), - MouseButtonMask(self.state), - ) + return f"tcod.event.{self.__class__.__name__}(position={tuple(self.position)!r}, tile={tuple(self.tile)!r}, state={MouseButtonMask(self.state)})" def __str__(self) -> str: return ("<%s, position=(x=%i, y=%i), tile=(x=%i, y=%i), state=%s>") % ( @@ -554,14 +550,7 @@ def from_sdl_event(cls, sdl_event: Any) -> MouseMotion: return self def __repr__(self) -> str: - return ("tcod.event.{}(position={!r}, motion={!r}, tile={!r}, tile_motion={!r}, state={!r})").format( - self.__class__.__name__, - tuple(self.position), - tuple(self.motion), - tuple(self.tile), - tuple(self.tile_motion), - MouseButtonMask(self.state), - ) + return f"tcod.event.{self.__class__.__name__}(position={tuple(self.position)!r}, motion={tuple(self.motion)!r}, tile={tuple(self.tile)!r}, tile_motion={tuple(self.tile_motion)!r}, state={MouseButtonMask(self.state)!r})" def __str__(self) -> str: return ("<%s, motion=(x=%i, y=%i), tile_motion=(x=%i, y=%i)>") % ( @@ -621,12 +610,7 @@ def from_sdl_event(cls, sdl_event: Any) -> Any: return self def __repr__(self) -> str: - return "tcod.event.{}(position={!r}, tile={!r}, button={!r})".format( - self.__class__.__name__, - tuple(self.position), - tuple(self.tile), - MouseButton(self.button), - ) + return f"tcod.event.{self.__class__.__name__}(position={tuple(self.position)!r}, tile={tuple(self.tile)!r}, button={MouseButton(self.button)!r})" def __str__(self) -> str: return " str: ) def __repr__(self) -> str: - return "{}(nb_dices={!r},nb_faces={!r},multiplier={!r},addsub={!r})".format( - self.__class__.__name__, - self.nb_dices, - self.nb_faces, - self.multiplier, - self.addsub, - ) + return f"{self.__class__.__name__}(nb_dices={self.nb_dices!r},nb_faces={self.nb_faces!r},multiplier={self.multiplier!r},addsub={self.addsub!r})" # reverse lookup table for KEY_X attributes, used by Key.__repr__ diff --git a/tcod/los.py b/tcod/los.py index d6cd1362..6d30d0b8 100644 --- a/tcod/los.py +++ b/tcod/los.py @@ -1,4 +1,5 @@ """This modules holds functions for NumPy-based line of sight algorithms.""" + from __future__ import annotations from typing import Any diff --git a/tcod/map.py b/tcod/map.py index b339cee1..fc3c24cf 100644 --- a/tcod/map.py +++ b/tcod/map.py @@ -1,4 +1,5 @@ """libtcod map attributes and field-of-view functions.""" + from __future__ import annotations import warnings diff --git a/tcod/noise.py b/tcod/noise.py index 66cba1d1..22f5d9c2 100644 --- a/tcod/noise.py +++ b/tcod/noise.py @@ -31,6 +31,7 @@ [ 76, 54, 85, 144, 164], [ 63, 94, 159, 209, 203]], dtype=uint8) """ + from __future__ import annotations import enum diff --git a/tcod/path.py b/tcod/path.py index f708a072..5765f233 100644 --- a/tcod/path.py +++ b/tcod/path.py @@ -15,6 +15,7 @@ All path-finding functions now respect the NumPy array shape (if a NumPy array is used.) """ + from __future__ import annotations import functools diff --git a/tcod/random.py b/tcod/random.py index 148331df..73121578 100644 --- a/tcod/random.py +++ b/tcod/random.py @@ -6,6 +6,7 @@ However, you will need to use these generators to get deterministic results from the :any:`Noise` and :any:`BSP` classes. """ + from __future__ import annotations import os diff --git a/tcod/sdl/__init__.py b/tcod/sdl/__init__.py index 8133948b..22e82845 100644 --- a/tcod/sdl/__init__.py +++ b/tcod/sdl/__init__.py @@ -1,4 +1,5 @@ """tcod.sdl package.""" + from pkgutil import extend_path __path__ = extend_path(__path__, __name__) diff --git a/tcod/sdl/_internal.py b/tcod/sdl/_internal.py index 761ca9a1..8ea5e13f 100644 --- a/tcod/sdl/_internal.py +++ b/tcod/sdl/_internal.py @@ -1,4 +1,5 @@ """tcod.sdl private functions.""" + from __future__ import annotations import logging diff --git a/tcod/sdl/audio.py b/tcod/sdl/audio.py index 8ed3fd38..33356132 100644 --- a/tcod/sdl/audio.py +++ b/tcod/sdl/audio.py @@ -41,6 +41,7 @@ .. versionadded:: 13.5 """ + from __future__ import annotations import enum diff --git a/tcod/sdl/joystick.py b/tcod/sdl/joystick.py index b65d7339..d5c66713 100644 --- a/tcod/sdl/joystick.py +++ b/tcod/sdl/joystick.py @@ -2,6 +2,7 @@ .. versionadded:: 13.8 """ + from __future__ import annotations import enum diff --git a/tcod/sdl/mouse.py b/tcod/sdl/mouse.py index d212afb6..fefd71d7 100644 --- a/tcod/sdl/mouse.py +++ b/tcod/sdl/mouse.py @@ -6,6 +6,7 @@ .. versionadded:: 13.5 """ + from __future__ import annotations import enum diff --git a/tcod/sdl/render.py b/tcod/sdl/render.py index 2e879c4d..c57d2242 100644 --- a/tcod/sdl/render.py +++ b/tcod/sdl/render.py @@ -2,6 +2,7 @@ .. versionadded:: 13.4 """ + from __future__ import annotations import enum diff --git a/tcod/sdl/video.py b/tcod/sdl/video.py index 41fec458..53a8e2db 100644 --- a/tcod/sdl/video.py +++ b/tcod/sdl/video.py @@ -6,6 +6,7 @@ .. versionadded:: 13.4 """ + from __future__ import annotations import enum diff --git a/tcod/tcod.py b/tcod/tcod.py index 6fab4ff4..8181da79 100644 --- a/tcod/tcod.py +++ b/tcod/tcod.py @@ -6,6 +6,7 @@ Read the documentation online: https://python-tcod.readthedocs.io/en/latest/ """ + from __future__ import annotations import warnings diff --git a/tcod/tileset.py b/tcod/tileset.py index 4f1aeef8..846aed32 100644 --- a/tcod/tileset.py +++ b/tcod/tileset.py @@ -10,6 +10,7 @@ `_ while continuing to use python-tcod's pathfinding and field-of-view algorithms. """ + from __future__ import annotations import itertools diff --git a/tests/conftest.py b/tests/conftest.py index 83e2dc8e..2998b4ae 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Test directory configuration.""" + import random import warnings from typing import Callable, Iterator, Union diff --git a/tests/test_console.py b/tests/test_console.py index cd6df8f7..e329fe6f 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -1,4 +1,5 @@ """Tests for tcod.console.""" + import pickle from pathlib import Path diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index 356de7d3..869c2b36 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -1,4 +1,5 @@ """Test deprecated features.""" + from __future__ import annotations import numpy as np diff --git a/tests/test_libtcodpy.py b/tests/test_libtcodpy.py index 50c8be7e..676ab2bc 100644 --- a/tests/test_libtcodpy.py +++ b/tests/test_libtcodpy.py @@ -1,4 +1,5 @@ """Tests for the libtcodpy API.""" + from pathlib import Path from typing import Any, Callable, Iterator, List, Optional, Tuple, Union diff --git a/tests/test_noise.py b/tests/test_noise.py index 0f64d5fe..72149062 100644 --- a/tests/test_noise.py +++ b/tests/test_noise.py @@ -1,4 +1,5 @@ """Tests for the tcod.noise module.""" + import copy import pickle diff --git a/tests/test_parser.py b/tests/test_parser.py index ce200166..07f736a1 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,4 +1,5 @@ """Test old libtcodpy parser.""" + from pathlib import Path from typing import Any diff --git a/tests/test_random.py b/tests/test_random.py index e6b64e1e..5bed9d95 100644 --- a/tests/test_random.py +++ b/tests/test_random.py @@ -1,4 +1,5 @@ """Test random number generators.""" + import copy import pickle from pathlib import Path diff --git a/tests/test_sdl.py b/tests/test_sdl.py index 709d3647..f22b7a72 100644 --- a/tests/test_sdl.py +++ b/tests/test_sdl.py @@ -1,4 +1,5 @@ """Test SDL specific features.""" + import sys import numpy as np diff --git a/tests/test_sdl_audio.py b/tests/test_sdl_audio.py index 6441bda1..f7e55093 100644 --- a/tests/test_sdl_audio.py +++ b/tests/test_sdl_audio.py @@ -1,4 +1,5 @@ """Test tcod.sdl.audio module.""" + import contextlib import sys import time diff --git a/tests/test_tcod.py b/tests/test_tcod.py index aee98c0c..d15b145d 100644 --- a/tests/test_tcod.py +++ b/tests/test_tcod.py @@ -1,4 +1,5 @@ """Tests for newer tcod API.""" + import copy import pickle from typing import Any, NoReturn diff --git a/tests/test_tileset.py b/tests/test_tileset.py index aba88b98..dd272fe7 100644 --- a/tests/test_tileset.py +++ b/tests/test_tileset.py @@ -1,4 +1,5 @@ """Test for tcod.tileset module.""" + import tcod.tileset # ruff: noqa: D103