Replace hatch env layer with native uv commands#8510
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
manzt
commented
Feb 27, 2026
Comment on lines
-285
to
-297
| [tool.hatch.envs.test.scripts] | ||
| test = "pytest{env:HATCH_TEST_ARGS:} {args:tests}" | ||
| default = "pytest{env:HATCH_TEST_ARGS:} {args:tests}" | ||
| # This is used externally from the narwhals repo to run our tests from their repo. | ||
| # This should include any tests that may use narwhals. | ||
| # It is ok if we test more than narwhals here, but we should not test less. | ||
| test-narwhals = """ | ||
| pytest{env:HATCH_TEST_ARGS:} \ | ||
| tests/_data/ \ | ||
| tests/_plugins/ui/_impl/ \ | ||
| tests/_utils/test_narwhals_utils.py | ||
| """ | ||
|
|
Contributor
There was a problem hiding this comment.
this will break narwhals, so you will need to make a PR to their repo: https://github.com/narwhals-dev/narwhals/blob/ef7e90ba1f51f0d88dc2c1a34513cfbc2dac6eb0/.github/workflows/downstream_tests.yml#L125
Collaborator
Author
There was a problem hiding this comment.
mscolnick
reviewed
Feb 27, 2026
manzt
commented
Feb 27, 2026
93eb605 to
337929b
Compare
akshayka
previously approved these changes
Feb 28, 2026
manzt
added a commit
to manzt/narwhals
that referenced
this pull request
Feb 28, 2026
Pending on marimo-team/marimo#8510, which replaces hatch with native uv commands in marimo. Uses `uv add ../ --editable` and a new `scripts/test-narwhals.sh` in marimo instead of the old hatch-based test invocation.
Many of the APIs are similar and I'm curious what this would look like in CI. Converts hatch environments to PEP 735 dependency groups and replaces `hatch run` with `uv run --group` across Makefile, scripts, workflows, and docs. Keeps `hatch publish` for releases.
The narwhals repo used to invoke `hatch run test:test-narwhals` externally to run marimo's narwhals-related tests. That hatch script entry point was removed in the hatch-to-uv migration, so this preserves the capability as a Makefile target.
The `~=10.4.0` constraint forced pillow 10.4.x which lacks prebuilt wheels for some platform/Python combos, causing compilation failures when jpeg headers aren't available. Using `>=10.4.0` lets uv pick a newer version with wheels.
Under hatch, `UV_RESOLUTION: lowest` was scoped to an isolated test environment. With `uv run`, resolution covers the entire project including all dependency groups, so transitive deps like `lz4` were getting pinned to unbuildable ancient versions. `lowest-direct` still validates that marimo works with its minimum declared dependency versions without forcing the lowest possible transitive deps.
The repo now has a `.python-version` file that uv respects by default, so hardcoding `--python 3.12` (or 3.13) in the Makefile and CI is redundant and creates a maintenance burden when the target version changes. Removing it from dev commands (codegen, snapshots, narwhals tests) and the non-matrix CI coverage job lets `.python-version` be the single source of truth. Documentation examples in AGENTS.md files are updated to show the three-command pattern: default run, optional deps, and explicit `--python` override for when you need a specific version.
Running changed-file tests across Python versions locally previously meant manually invoking uv/pytest for each version. This script wraps the pytest-changed plugin with a version matrix loop, defaulting to 3.10–3.13 with `test-optional` deps and diffing against `main`. A user can narrow to a single version with `--python` or switch to core-only deps with `--group test`. Extra pytest flags pass through after `--`.
`uv run` sets `UV` to the absolute path of its binary, which leaked into tests causing `infer_package_manager()` to always return `"uv"` and `find_uv_bin()` to return a full path instead of bare `"uv"`. This broke mock assertions, snapshot tests, and config inference tests. Clearing it at the top of conftest before any marimo imports fixes all of these.
The CLI test job installs marimo from a wheel (which includes `_static/index.html`), but pytest runs from the repo checkout where the local `marimo/` source directory shadows the installed package. Since the checkout has no built frontend assets, the export HTML tests fail with a missing `index.html`. Changing the working directory to `runner.temp` before running pytest ensures Python imports the wheel-installed package. Also drops the redundant `--group=test` since `test-optional` already includes it via `include-group`.
`black` was removed as a dev dependency since it is only used as an optional runtime dependency behind lazy imports with try/except guards. This adds `type: ignore[import-not-found]` to the two import sites so mypy doesn't fail when `black` isn't installed in the typecheck environment, consistent with how all other optional imports are handled in the codebase.
The CLI tests `cd` to a temp directory before running pytest via `uv run --no-project` to ensure tests run against the installed wheel rather than the source checkout. After the hatch-to-uv migration, uv can no longer discover the venv created in the workspace directory once the working directory changes. Setting `VIRTUAL_ENV` explicitly points uv back to the right venv.
After migrating from hatch to uv, the shared `.venv` includes packages like `ibis-framework` from test-optional, causing mypy to raise `import-untyped` errors. Using `--only-group typecheck` restores the isolated environment hatch provided.
for more information, see https://pre-commit.ci
On Windows, `${{ runner.temp }}` expands to `D:\a\_temp` which bash
interprets as escape sequences (`\a`, `\_`), producing `D:a_temp`.
Single quotes prevent bash from processing the backslashes.
The `# type: ignore[import-not-found]` on the black import causes mypy to treat the module as `Any` when black isn't installed, which cascades into a `no-any-return` error on the return value of `format_str`.
The `cd ${{ runner.temp }}` broke tests like `test_openapi_up_to_date`
that use paths relative to the repo root. `--no-project` is sufficient
to prevent uv from discovering and rebuilding the project from source.
The setup section previously led with pixi as the primary tool, which caused confusion for contributors who don't use it. This restructures the guide to lead with the prerequisites we actually use on the team (uv, Node 20+, pnpm 9+) and a minimal getting started flow. Pixi and Gitpod are mentioned as unsupported alternatives in a tip callout.
1318787 to
1c0422a
Compare
mscolnick
approved these changes
Mar 11, 2026
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.20.5-dev42 |
dmadisetti
pushed a commit
that referenced
this pull request
Mar 11, 2026
Many of the APIs are similar and I'm curious what this would look like in CI. Converts hatch environments to PEP 735 dependency groups and replaces `hatch run` with `uv run --group` across Makefile, scripts, workflows, and docs. Keeps `hatch publish` for releases. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Many of the APIs are similar and I'm curious what this would look like in CI. Converts hatch environments to PEP 735 dependency groups and replaces
hatch runwithuv run --groupacross Makefile, scripts, workflows, and docs. Keepshatch publishfor releases.