Skip to content

Commit

Permalink
Pre-commit update
Browse files Browse the repository at this point in the history
Apply to files, update scripts for new formatting and ignore generated and manually aligned code
  • Loading branch information
HexDecimal committed Nov 25, 2024
1 parent 3d19e29 commit 5c8c41f
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: fix-byte-order-marker
- id: detect-private-key
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.8.0
hooks:
- id: ruff
args: [--fix-only, --exit-non-zero-on-fix]
Expand Down
5 changes: 3 additions & 2 deletions build_libtcod.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def walk_sources(directory: str) -> Iterator[str]:
This module is auto-generated by `build_libtcod.py`.
"""
from tcod.color import Color
'''
Expand Down Expand Up @@ -366,7 +367,7 @@ def write_library_constants() -> None:
f.write(f"{name[5:]} = {color!r}\n")

all_names_merged = ",\n ".join(f'"{name}"' for name in all_names)
f.write(f"\n__all__ = [\n {all_names_merged},\n]\n")
f.write(f"\n__all__ = [ # noqa: RUF022\n {all_names_merged},\n]\n")
update_module_all(Path("tcod/libtcodpy.py"), all_names_merged)

with Path("tcod/event_constants.py").open("w", encoding="utf-8") as f:
Expand All @@ -384,7 +385,7 @@ def write_library_constants() -> None:
f.write("\n# --- SDL wheel ---\n")
f.write("{}\n_REVERSE_WHEEL_TABLE = {}\n".format(*parse_sdl_attrs("SDL_MOUSEWHEEL", all_names)))
all_names_merged = ",\n ".join(f'"{name}"' for name in all_names)
f.write(f"\n__all__ = [\n {all_names_merged},\n]\n")
f.write(f"\n__all__ = [ # noqa: RUF022\n {all_names_merged},\n]\n")

event_py = Path("tcod/event.py").read_text(encoding="utf-8")

Expand Down
26 changes: 12 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,18 @@ select = [
"D", # pydocstyle
]
ignore = [
"E501", # line-too-long
"S101", # assert
"S301", # suspicious-pickle-usage
"S311", # suspicious-non-cryptographic-random-usage
"ANN101", # missing-type-self
"ANN102", # missing-type-cls
"D203", # one-blank-line-before-class
"D204", # one-blank-line-after-class
"D213", # multi-line-summary-second-line
"D407", # dashed-underline-after-section
"D408", # section-underline-after-name
"D409", # section-underline-matches-section-length
"D206", # indent-with-spaces
"W191", # tab-indentation
"E501", # line-too-long
"S101", # assert
"S301", # suspicious-pickle-usage
"S311", # suspicious-non-cryptographic-random-usage
"D203", # one-blank-line-before-class
"D204", # one-blank-line-after-class
"D213", # multi-line-summary-second-line
"D407", # dashed-underline-after-section
"D408", # section-underline-after-name
"D409", # section-underline-matches-section-length
"D206", # indent-with-spaces
"W191", # tab-indentation
]

[tool.ruff.lint.pydocstyle] # https://docs.astral.sh/ruff/settings/#lintpydocstyle
Expand Down
10 changes: 5 additions & 5 deletions tcod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
from tcod.version import __version__

__all__ = [
"__version__",
"Console",
"__sdl_version__",
"lib",
"ffi",
"__version__",
"bsp",
"color",
"console",
"context",
"event",
"tileset",
"ffi",
"image",
"lib",
"los",
"map",
"noise",
"path",
"random",
"tileset",
"Console",
"tileset",
]
2 changes: 1 addition & 1 deletion tcod/cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ def _libtcod_log_watcher(message: Any, userdata: None) -> None: # noqa: ANN401
lib.TCOD_set_log_callback(lib._libtcod_log_watcher, ffi.NULL)
lib.TCOD_set_log_level(0)

__all__ = ["ffi", "lib", "__sdl_version__"]
__all__ = ["__sdl_version__", "ffi", "lib"]
2 changes: 1 addition & 1 deletion tcod/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
white = Color(255, 255, 255)
yellow = Color(255, 255, 0)

__all__ = [
__all__ = [ # noqa: RUF022
"FOV_BASIC",
"FOV_DIAMOND",
"FOV_PERMISSIVE_0",
Expand Down
26 changes: 13 additions & 13 deletions tcod/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@
from tcod.cffi import ffi, lib

__all__ = (
"Context",
"new",
"new_window",
"new_terminal",
"SDL_WINDOW_FULLSCREEN",
"SDL_WINDOW_FULLSCREEN_DESKTOP",
"SDL_WINDOW_HIDDEN",
"SDL_WINDOW_BORDERLESS",
"SDL_WINDOW_RESIZABLE",
"SDL_WINDOW_MINIMIZED",
"SDL_WINDOW_MAXIMIZED",
"SDL_WINDOW_INPUT_GRABBED",
"SDL_WINDOW_ALLOW_HIGHDPI",
"RENDERER_OPENGL",
"RENDERER_OPENGL2",
"RENDERER_SDL",
"RENDERER_SDL2",
"RENDERER_XTERM",
"SDL_WINDOW_ALLOW_HIGHDPI",
"SDL_WINDOW_BORDERLESS",
"SDL_WINDOW_FULLSCREEN",
"SDL_WINDOW_FULLSCREEN_DESKTOP",
"SDL_WINDOW_HIDDEN",
"SDL_WINDOW_INPUT_GRABBED",
"SDL_WINDOW_MAXIMIZED",
"SDL_WINDOW_MINIMIZED",
"SDL_WINDOW_RESIZABLE",
"Context",
"new",
"new_terminal",
"new_window",
)

_Event = TypeVar("_Event", bound=tcod.event.Event)
Expand Down
2 changes: 1 addition & 1 deletion tcod/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2818,7 +2818,7 @@ def __getattr__(name: str) -> int:
return value


__all__ = [ # noqa: F405
__all__ = [ # noqa: F405 RUF022
"Modifier",
"Point",
"BUTTON_LEFT",
Expand Down
19 changes: 18 additions & 1 deletion tcod/event_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,24 @@
1027: "MOUSEWHEEL",
}

__all__ = [
__all__ = [ # noqa: RUF022
"KMOD_NONE",
"KMOD_LSHIFT",
"KMOD_RSHIFT",
"KMOD_SHIFT",
"KMOD_LCTRL",
"KMOD_RCTRL",
"KMOD_CTRL",
"KMOD_LALT",
"KMOD_RALT",
"KMOD_ALT",
"KMOD_LGUI",
"KMOD_RGUI",
"KMOD_GUI",
"KMOD_NUM",
"KMOD_CAPS",
"KMOD_MODE",
"KMOD_SCROLL",
"MOUSEWHEEL_NORMAL",
"MOUSEWHEEL_FLIPPED",
"MOUSEWHEEL",
Expand Down
2 changes: 1 addition & 1 deletion tcod/libtcodpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4281,7 +4281,7 @@ def __getattr__(name: str) -> Color:
raise AttributeError(msg) from None


__all__ = [ # noqa: F405
__all__ = [ # noqa: F405 RUF022
"Color",
"Bsp",
"NB_FOV_ALGORITHMS",
Expand Down
4 changes: 2 additions & 2 deletions tcod/sdl/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from tcod.sdl._internal import _check, _check_p, _required_version, _version_at_least

__all__ = (
"WindowFlags",
"FlashOperation",
"Window",
"new_window",
"WindowFlags",
"get_grabbed_window",
"new_window",
"screen_saver_allowed",
)

Expand Down
2 changes: 1 addition & 1 deletion tcod/tcod.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def __getattr__(name: str, stacklevel: int = 1) -> Any: # noqa: ANN401
"console",
"context",
"event",
"tileset",
"image",
"los",
"map",
"noise",
"path",
"random",
"tileset",
"tileset",
]

0 comments on commit 5c8c41f

Please sign in to comment.