Skip to content

Modernize packaging and CI: pyproject.toml, uv, ruff#3

Open
abizer wants to merge 3 commits into
py314-lineno-fixfrom
py314-modernize-tooling
Open

Modernize packaging and CI: pyproject.toml, uv, ruff#3
abizer wants to merge 3 commits into
py314-lineno-fixfrom
py314-modernize-tooling

Conversation

@abizer

@abizer abizer commented Apr 14, 2026

Copy link
Copy Markdown
Owner

Summary

Modernizes packaging and CI tooling after #2 lands the actual fix. Stacked on `py314-lineno-fix`; rebase onto master once that merges.

  • Migrates from legacy `setup.py` to PEP 621 `pyproject.toml` using the `uv_build` backend (flat layout preserved via `module-root = ""`).
  • Switches both workflows from `actions/setup-python` + `pip` to `astral-sh/setup-uv` + `uv sync` / `uv build`.
  • Replaces `flake8` with `ruff` for linting.
  • Bumps `actions/checkout` to v6 and pins `astral-sh/setup-uv` to v8.0.0 (setup-uv v8 dropped floating major tags, so exact pin required).
  • Tightens `source_inspection.annotate`'s input validation from `assert` to `TypeError` so the check survives `python -O`.

Commits

  1. Raise TypeError instead of asserting input types in `annotate()` — `assert isinstance(...)` gets stripped under `python -O`. Replaces the three asserts with a loop that raises `TypeError` naming the offending argument.
  2. Migrate packaging from setup.py to pyproject.toml with uv — creates `pyproject.toml`, deletes `setup.py`, rewrites both workflows to use `astral-sh/setup-uv` + `uv sync`/`uv build`, bumps `actions/checkout@v6` and pins `astral-sh/setup-uv@v8.0.0`, gitignores `uv.lock`. Metadata carried over verbatim; `requires-python` tightened from the aspirational `>=3.4` to `>=3.8` (matches the real CI matrix).
  3. Replace flake8 with ruff for linting — with `uv sync` creating an in-tree `.venv/`, `flake8 .` was descending into `.venv/site-packages/` and linting the dev deps themselves, failing every matrix job. Ruff auto-excludes virtualenv-like directories. Lint selection is scoped to the same rules the old flake8 "fail build" pass used (`E9`, `F63`, `F7`, `F82`), so this is a drop-in tool swap, not an expanded lint gate.

Test plan

  • `uv build` produces a correct wheel (flat `stackprinter/` layout, LICENSE embedded, all 8 source files)
  • `uv run ruff check` passes with zero violations
  • `uv run pytest` passes on Python 3.11, 3.12, and 3.14 (8/8)
  • Watch CI run on the PR across the 3.8–3.14 matrix

Notes

setup-uv v8 stopped publishing floating major/minor tags starting with 8.0.0 — the only valid refs are exact version tags or commit SHAs. The workflow pins `@v8.0.0` directly; dependabot will bump on each patch release.

🤖 Generated with Claude Code

abizer and others added 3 commits April 14, 2026 01:49
`assert` statements are stripped when Python runs under `-O`, which
would silently accept bad input and produce broken source maps
downstream. Replace the three isinstance asserts with an explicit
TypeError that names the offending argument, so the failure mode is
the same regardless of optimization level and the error message
actually points at the cause.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the legacy setup.py with a PEP 621 pyproject.toml using the
uv_build backend (flat layout preserved via module-root = ""), and
switches both GitHub workflows to astral-sh/setup-uv:

- build.yml installs via `uv sync --group dev` and runs lint/tests
  via `uv run`, across the 3.8–3.14 matrix.
- upload_pypi.yml builds with `uv build` instead of `python -m build`
  before handing dist artifacts to pypa/gh-action-pypi-publish.

Action pins are brought to current latest as part of the rewrite:
actions/checkout@v6 (v6.0.2, 2026-01-09) and astral-sh/setup-uv@v8.0.0
(2026-03-29). setup-uv v8 dropped floating major/minor tags, so the
pin is to the exact v8.0.0 tag rather than @v8.

Metadata is carried over verbatim from setup.py (name, version,
description, author, URL, MIT license) plus explicit Python-version
classifiers matching the CI matrix. `requires-python` is tightened
from the aspirational `>=3.4` in the old setup.py to `>=3.8`, which
matches the versions that are actually tested.

Dev tools (pytest, numpy, flake8) move to [dependency-groups].dev,
and uv.lock is gitignored since this is a library — consumers pin via
their own resolver, not ours.

Verified: `uv build` produces a correct wheel (flat stackprinter/
layout, LICENSE embedded) and `uv run pytest` passes on Python 3.11,
3.12, and 3.14.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
With `uv sync` creating an in-tree .venv/, `flake8 .` walks into
.venv/site-packages and flags undefined names in flake8's own sources
and numpy internals, failing every CI job. Ruff auto-excludes .venv,
.venv*, and other virtualenv-like directories by default, so
`uv run ruff check` just works without adding explicit excludes.

Lint selection is scoped to the same rules the old flake8 "fail build"
pass used — E9 (syntax errors), F63 (invalid comparisons/assertions),
F7 (break/return/continue outside block), F82 (undefined names) — so
this is a drop-in tool swap, not an expanded lint gate. Verified
locally: `uv run ruff check` passes with zero violations on the
existing codebase.

The old flake8 also ran a second `--exit-zero` pass for complexity
warnings that never gated the build and just produced stderr noise.
Dropped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
abizer added a commit that referenced this pull request Apr 14, 2026
Squash of py314-modernize-tooling onto the 0.2.13 release branch for
internal consumption ahead of the corresponding upstream PR
(#3) merging.

- Replaces legacy setup.py with a PEP 621 pyproject.toml using the
  uv_build backend (flat layout preserved via module-root = "").
- Switches both GitHub workflows from actions/setup-python + pip to
  astral-sh/setup-uv + uv sync / uv build, and from flake8 to ruff
  for linting. Lint selection scoped to the old flake8 "fail build"
  rules (E9, F63, F7, F82) so this is a drop-in tool swap.
- Bumps actions/checkout to v6 and pins astral-sh/setup-uv to v8.0.0
  (v8+ dropped floating major tags, so exact pin required).
- Tightens source_inspection.annotate input validation from
  assert to TypeError so the check survives python -O.
- Tightens requires-python from the aspirational >=3.4 in the old
  setup.py to >=3.8, matching the tested matrix.
- Dev tools (pytest, numpy, ruff) move to [dependency-groups].dev;
  uv.lock is gitignored since this is a library.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant