Skip to content

build(workspace): self-contained per-project mypy; run checks via uv --project + python -m - #683

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:workspace-mypy-per-project
Jul 3, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:workspace-mypy-per-project

Conversation

@potiuk

@potiuk potiuk commented Jul 3, 2026

Copy link
Copy Markdown
Member

What

Makes every uv-workspace sub-project self-contained for static analysis
and tests, and fixes the workspace-mypy pre-commit hook that could not
find mypy.

Why the mypy hook was broken

run-workspace-check.sh invoked uv run --directory <member> mypy, but
only two members declared mypy (at two different versions), so the tool
was expected to leak in from the shared root venv. It didn't reliably:
the mypy console script in the shared venv had a shebang pointing
at another repo's venv (#!/…/airflow-steward/.venv/bin/python3), so
exec'ing it failed with ENOENT — while python -m mypy worked fine.

Changes

  • mypy in every member's [dependency-groups] dev, unified at
    >=2.1.0 (same lower bound as the workspace root). pytest (>=9.1.1)
    and ruff (>=0.15.18) are declared alongside it so each sub-project's
    environment is complete on its own — no dependence on tools leaking in
    from the shared root venv.
  • run-workspace-check.sh runs every check through uv against the
    member's own project:
    uv run --directory <member> --project . …
    — --directory sets cwd (so ruff/mypy/pytest find the member's
    config), --project . selects that member's environment.
  • mypy and pytest run as python -m <tool>, bypassing the
    console-script shebang so a stale cross-repo interpreter path can
    never break them again.
  • Drops the Apple-Silicon _NATIVE_PYTHON arch shim — uv run
    already resolves a native interpreter, and python -m removed the
    console-script failure the shim worked around.
  • Root pyproject.toml comment updated; root + standalone member
    lockfiles regenerated.

Verification

Full pre-commit suite green, including the previously-failing hook:

ruff check (workspace) ......... Passed
ruff format (workspace) ........ Passed
mypy (workspace) ............... Passed   (18 applicable members)
pytest (workspace) ............. Passed   (24 applicable members)

…a uv -m

Each workspace member now declares the full static-analysis + test
toolchain (mypy, pytest, ruff) in its own `[dependency-groups] dev`,
pinned to the same lower bounds as the workspace root, so every
sub-project's environment is self-contained rather than depending on
tools leaking in from the shared root venv. mypy is unified at
`>=2.1.0` across all members (previously declared in only two, at two
different versions).

`tools/dev/run-workspace-check.sh` now runs every check through uv
against the member's own project:

  uv run --directory <member> --project . [python -m] <tool>

- `--directory` puts cwd at the member so ruff/mypy/pytest resolve
  their config relative to the member root;
- `--project .` selects that member's environment (its pyproject.toml
  + dev group);
- mypy and pytest are invoked as `python -m <tool>` to bypass their
  console-script shebangs, which bake an absolute interpreter path and
  fail to spawn when the shared workspace venv is reused across repos
  (a stale `#!/…/other-repo/.venv/bin/python3`). This was why the
  workspace-mypy hook could not find mypy.

Drops the Apple-Silicon `_NATIVE_PYTHON` arch shim: `uv run` already
resolves a native interpreter, and the `python -m` form removed the
console-script failure the shim was working around.
@potiuk
potiuk merged commit 20020c3 into apache:main Jul 3, 2026
33 checks passed
@potiuk potiuk added contract:body-field contract:cve-authority Tool capability: CVE allocation / record management / publication contract:mail-archive Tool capability: mailing-list / forum archive reads contract:mail-create Tool capability: outbound mail composition (editable draft; sending is a separate human step) contract:mail-source Tool capability: inbound-mail ingestion (mbox / IMAP / ...) contract:people contract:security-tracker Tool capability: security-tracker backend for embargoed reports (GitHub / files / Jira) contract:source-control Tool capability: branch / commit / diff / push (VCS) contract:tracker Tool capability: issue / board / label backend family:ci .github workflows, prek, validators family:tools tools/* substrate:action-guard Tool substrate: deterministic pre-tool-use command guards substrate:analytics Tool substrate: read-only metrics / dashboards / renderers substrate:framework-dev Tool substrate: build / validate / eval the framework itself substrate:privacy Tool substrate: PII redaction / approved-LLM gating substrate:sandbox Tool substrate: agent isolation, egress control, settings audit labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contract:body-field contract:cve-authority Tool capability: CVE allocation / record management / publication contract:mail-archive Tool capability: mailing-list / forum archive reads contract:mail-create Tool capability: outbound mail composition (editable draft; sending is a separate human step) contract:mail-source Tool capability: inbound-mail ingestion (mbox / IMAP / ...) contract:people contract:security-tracker Tool capability: security-tracker backend for embargoed reports (GitHub / files / Jira) contract:source-control Tool capability: branch / commit / diff / push (VCS) contract:tracker Tool capability: issue / board / label backend family:ci .github workflows, prek, validators family:tools tools/* substrate:action-guard Tool substrate: deterministic pre-tool-use command guards substrate:analytics Tool substrate: read-only metrics / dashboards / renderers substrate:framework-dev Tool substrate: build / validate / eval the framework itself substrate:privacy Tool substrate: PII redaction / approved-LLM gating substrate:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant