Skip to content

Replace hatch environments with direct uv/pip commands - #442

Draft
Carreau wants to merge 7 commits into
mainfrom
claude/hatch-venv-duplication-om4uit
Draft

Replace hatch environments with direct uv/pip commands#442
Carreau wants to merge 7 commits into
mainfrom
claude/hatch-venv-duplication-om4uit

Conversation

@Carreau

@Carreau Carreau commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

This PR removes the hatch environment configurations and replaces all hatch-based task execution with direct uv pip and python commands in the CI workflows. This simplifies the development and CI setup by eliminating the intermediate hatch layer.

Key Changes

  • pyproject.toml: Removed all [tool.hatch.envs.*] configuration sections (default, docs, test, cov, lint, typing)
  • CI Workflows (.github/workflows/tests.yml):
    • Replaced hatch run cov:test with direct pytest invocation with coverage flags
    • Replaced hatch run docs:build with direct make -C docs html command
    • Replaced hatch run typing:test with direct python -m mypy command
    • Replaced hatch run lint:build with direct linting commands
    • Replaced hatch run test:nowarn with direct pytest invocation
    • Replaced pipx run with uv tool run for interrogate and doc8
    • Added explicit uv pip install --system -e ".[test]" and uv pip install --system -e ".[docs]" steps to install dependencies before running tasks
    • Consolidated Windows and non-Windows test steps into a single test step with unified coverage requirements

Notable Details

  • All test commands now explicitly set PYTHONWARNDEFAULTENCODING=1 where needed
  • Coverage threshold (--cov-fail-under 75) is now enforced in all test runs
  • Dependencies are installed directly using uv pip with extras (test, docs) rather than through hatch environment definitions
  • The version check step now uses uv tool run hatch instead of hatch directly

https://claude.ai/code/session_01GNegkQJzxWvFd2sekqB13q

@Carreau

Carreau commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

In all the project I used I find hatch + precommit and all the indirections more of a problems than anything else.

I'm usually already in a env and hatch create and env, to install pre-commit that install things in a env... it's madness. Plus mypy in pre-commit forget some types errors if we don't pay attention to install the curent dev version and install all deps.

Carreau commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Good call — you called it exactly. Moving mypy out of pre-commit's isolated env and running it directly (with the project actually installed via -e .) surfaced real gaps that had been hidden:

  • fastjsonschema has no stubs upstream at all (added a mypy override to ignore-missing-imports for it).
  • jsonschema's stubs (types-jsonschema) weren't installed anywhere, so several errors were silently swallowed as "missing stubs" instead of being checked.
  • With types-jsonschema actually present, two more real typing issues showed up: sign.py's pysqlite2 fallback import had the wrong type: ignore code, and json_compat.py's _validator attribute was narrowing to Draft4Validator from the base class instead of allowing the fastjsonschema-compiled callable — needed an explicit Any annotation. Also dropped a now-stale unused ignore on NotebookValidationError.

All fixed and pushed (74eb873). Ran the full test suite + mypy locally against the exact deps CI now installs — clean. This lines up with the broader hatch/pre-commit cleanup on this PR: fewer indirections, and now you can just run python -m mypy directly in your own env and get the real result.


Generated by Claude Code

claude added 5 commits July 31, 2026 12:37
Replace tool.hatch.envs.* and `hatch run` CI calls with plain uv pip
install + direct pytest/pre-commit/sphinx invocations. hatchling and
hatch-nodejs-version remain as the build backend/version source.
All test jobs (including Windows) now use pytest's default filterwarnings
config (error) instead of overriding with -W default.
uv is already the package manager used throughout this workflow, so
route the one-off tool invocations (hatch, interrogate, doc8) through
uv tool run instead of pulling in pipx.
ruff-check/ruff-format already run on every PR via pre-commit.ci (default
stage), so re-running them through pre-commit in test_lint was redundant.
mypy is pinned to stages: [manual] specifically because pre-commit.ci
skips manual-stage hooks, so it still needs to run in CI, but directly
via `python -m mypy` rather than through pre-commit.
…commit

Running mypy outside pre-commit's isolated additional_dependencies env
exposed real gaps: fastjsonschema has no stubs (add an override), jsonschema
needed types-jsonschema installed, sign.py's pysqlite2 fallback import used
the wrong ignore code, json_compat.py's _validator attribute needed an
explicit Any annotation (its type narrowed to Draft4Validator from the base
class otherwise), and NotebookValidationError had a now-stale unused ignore.
@Carreau
Carreau force-pushed the claude/hatch-venv-duplication-om4uit branch from 74eb873 to 5972cc5 Compare July 31, 2026 12:38
pre-commit-ci Bot and others added 2 commits July 31, 2026 12:38
PY007 (task runner) and PP006 (dev dependency group) no longer apply now
that hatch's env runner is gone and there's no tox/nox in its place, per
the ongoing hatch/pre-commit indirection cleanup on this PR. PP304 (pytest
log_level) and PC902 (custom pre-commit.ci autofix message) are stylistic
preferences we don't need.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants