diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 84be4718..8a87408d 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -30,8 +30,24 @@ permissions: contents: read jobs: - lint: + lint-pelican: runs-on: ubuntu-latest + # GitHub Actions log output is not a TTY, so tools that autodetect + # colors turn them off in CI. Force colorized output via the common + # `FORCE_COLOR` convention (honored by pylint, rich, uv, etc.) plus + # `PY_COLORS=1` which mypy's `rich`-based pretty printer picks up. + # The per-tool flags below (`--output-format=colorized`, + # `--color-output`) make the intent explicit and work even for + # tools that don't read the env vars. + env: + FORCE_COLOR: "1" + PY_COLORS: "1" + defaults: + run: + # Applies to every `run:` step in this job; `uses:` steps are + # unaffected, so setup-uv's `cache-dependency-glob` below still + # resolves from the repository root. + working-directory: pelican steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -42,21 +58,14 @@ jobs: with: python-version: '3.11' - - name: Install dependencies - run: | - pip list - cd pelican - pip install -r requirements.txt --no-deps # Explicit dependency-only installation - pip install mypy types-PyYAML types-requests types-beautifulsoup4 types-markdown pylint - pip list + - name: Set up uv + uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0 + with: + enable-cache: true + cache-dependency-glob: "pelican/uv.lock" - name: Type testing with mypy - run: | - cd pelican - mypy --cache-dir /tmp/ --install-types --non-interactive - mypy --cache-dir /tmp/ --ignore-missing-imports . + run: uv run mypy --color-output --pretty --ignore-missing-imports . - name: Code linting with pylint - run: | - cd pelican - pylint **/*.py + run: uv run pylint --output-format=colorized **/*.py diff --git a/pelican/plugin_paths.py b/pelican/plugin_paths.py index a9dd830f..b5b9b958 100755 --- a/pelican/plugin_paths.py +++ b/pelican/plugin_paths.py @@ -32,8 +32,8 @@ """ -import sys import json +import sys DEFAULT_PELCONF = 'pelicanconf.py' # in current dir diff --git a/pelican/pylintrc b/pelican/pylintrc index fb17ac18..d1bfb293 100644 --- a/pelican/pylintrc +++ b/pelican/pylintrc @@ -72,10 +72,6 @@ persistent=yes # the version used to run pylint. py-version=3.10 -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no diff --git a/pelican/pyproject.toml b/pelican/pyproject.toml index 2b5e6002..12c34fa6 100644 --- a/pelican/pyproject.toml +++ b/pelican/pyproject.toml @@ -62,12 +62,20 @@ dependencies = [ # but the runtime install does not: Pelican itself (installed by the action # at runtime via `uv tool install 'pelican[markdown]=='`, with the # version controlled by the action's `version` input rather than this file), -# plus linting and test tooling. +# plus linting, type-checking and test tooling. The `Linting and MyPy +# (Pelican)` workflow syncs this group via `uv sync --no-install-project` +# and runs mypy / pylint out of the resulting venv. [dependency-groups] dev = [ "pelican[markdown]>=4.11,<4.12", "ruff>=0.6", "pytest>=8", + "mypy>=1.10", + "pylint>=3", + "types-PyYAML>=6.0", + "types-requests>=2.33", + "types-beautifulsoup4>=4.12", + "types-markdown>=3.10", ] [project.urls]