Add type hints to KDE Python build scripts #2

Merged
vokhactri merged 1 commits from refactor/add-python-type-hints into main 2026-11-02 15:18:44 +07:00
vokhactri commented 2026-11-02 15:18:00 +07:00 (Migrated from github.com)

Summary

  • Add parameter and return type hints to kde/theme/build.py, kde/spectacle/apply.py and kde/fastfetch/build.py.
  • Add Color and ColorFn aliases in kde/theme/build.py using the Python 3.12 type statement.
  • Annotate variables mypy cannot infer, such as seen, chain, path, colors, families, pins and shortcuts.
  • Add # type: ignore[method-assign,assignment] to the optionxform = str lines, which mypy --strict rejects.
  • Target Python 3.12 or newer, the lowest version shipped by Fedora 40, Kubuntu 25.04 and Arch. No from __future__ import annotations is needed.
  • No runtime behavior changes.

Testing

  • mypy --strict on Python 3.12 reports no issues for all three scripts.
  • kde/theme/build.py run with Python 3.12 leaves the committed output files unchanged.
  • kde/spectacle/apply.py: Not run, because it needs a live KDE session.
  • kde/fastfetch/build.py: Not run, because it needs vipsthumbnail.
## Summary - Add parameter and return type hints to `kde/theme/build.py`, `kde/spectacle/apply.py` and `kde/fastfetch/build.py`. - Add `Color` and `ColorFn` aliases in `kde/theme/build.py` using the Python 3.12 `type` statement. - Annotate variables mypy cannot infer, such as `seen`, `chain`, `path`, `colors`, `families`, `pins` and `shortcuts`. - Add `# type: ignore[method-assign,assignment]` to the `optionxform = str` lines, which `mypy --strict` rejects. - Target Python 3.12 or newer, the lowest version shipped by Fedora 40, Kubuntu 25.04 and Arch. No `from __future__ import annotations` is needed. - No runtime behavior changes. ## Testing - `mypy --strict` on Python 3.12 reports no issues for all three scripts. - `kde/theme/build.py` run with Python 3.12 leaves the committed output files unchanged. - `kde/spectacle/apply.py`: Not run, because it needs a live KDE session. - `kde/fastfetch/build.py`: Not run, because it needs `vipsthumbnail`.
Sign in to join this conversation.