|
| 1 | +--- |
| 2 | +date: 2026-05-30 |
| 3 | +authors: [cjames23] |
| 4 | +description: >- |
| 5 | + Hatch v1.17.0 brings lockfile support and a new unified check command. |
| 6 | +categories: |
| 7 | + - Release |
| 8 | +--- |
| 9 | + |
| 10 | +# Hatch v1.17.0 |
| 11 | + |
| 12 | +Hatch [v1.17.0](https://github.com/pypa/hatch/releases/tag/hatch-v1.17.0) brings first-class lockfile support and a new `hatch check` command that unifies code quality checks under a single, extensible interface. |
| 13 | + |
| 14 | +<!-- more --> |
| 15 | + |
| 16 | +## Lockfile support |
| 17 | + |
| 18 | + Hatch now generates [PEP 751](https://peps.python.org/pep-0751/) lockfiles (`pylock.toml`) for your environments, capturing exact resolved versions and cryptographic hashes of every dependency. |
| 19 | + |
| 20 | +### Getting started |
| 21 | + |
| 22 | +Enable locking on any environment: |
| 23 | + |
| 24 | +```toml config-example |
| 25 | +[tool.hatch.envs.test] |
| 26 | +locked = true |
| 27 | +dependencies = [ |
| 28 | + "pytest", |
| 29 | +] |
| 30 | +``` |
| 31 | + |
| 32 | +Or flip it on globally: |
| 33 | + |
| 34 | +```toml config-example |
| 35 | +[tool.hatch] |
| 36 | +lock-envs = true |
| 37 | +``` |
| 38 | + |
| 39 | +Then generate lockfiles: |
| 40 | + |
| 41 | +```console |
| 42 | +$ hatch env lock |
| 43 | +Locking environment: default |
| 44 | +Wrote lockfile: pylock.toml |
| 45 | +Locking environment: test |
| 46 | +Wrote lockfile: pylock.test.toml |
| 47 | +``` |
| 48 | + |
| 49 | +The `default` environment produces `pylock.toml`, while others follow the `pylock.<name>.toml` convention from PEP 751. |
| 50 | + |
| 51 | +### Automatic locking |
| 52 | + |
| 53 | +Environments configured with `locked = true` will have their lockfiles generated automatically during `hatch env create` or `hatch run` whenever the lockfile is missing or dependencies have changed. No extra steps required. |
| 54 | + |
| 55 | +### CI verification |
| 56 | + |
| 57 | +Use `--check` to verify lockfiles are up to date in CI pipelines: |
| 58 | + |
| 59 | +```console |
| 60 | +$ hatch env lock --check |
| 61 | +Lockfile is up to date: pylock.toml |
| 62 | +``` |
| 63 | + |
| 64 | +This re-resolves dependencies and compares the result against the committed lockfile, failing if they diverge. |
| 65 | + |
| 66 | +### Upgrading dependencies |
| 67 | + |
| 68 | +Upgrade everything: |
| 69 | + |
| 70 | +```console |
| 71 | +$ hatch env lock --upgrade |
| 72 | +``` |
| 73 | + |
| 74 | +Or target specific packages: |
| 75 | + |
| 76 | +```console |
| 77 | +$ hatch env lock --upgrade-package requests --upgrade-package urllib3 |
| 78 | +``` |
| 79 | + |
| 80 | +### Pluggable lockers |
| 81 | + |
| 82 | +The lockfile system is built on a plugin interface. Hatch ships two built-in lockers: |
| 83 | + |
| 84 | +- **UV** — uses `uv pip compile` with hash generation and `uv pip sync` for installation |
| 85 | +- **pip** — uses `pip lock` (requires pip 25.1+) |
| 86 | + |
| 87 | +The locker is selected automatically based on your environment's installer, or you can set it explicitly: |
| 88 | + |
| 89 | +```toml config-example |
| 90 | +[tool.hatch] |
| 91 | +locker = "uv" |
| 92 | +``` |
| 93 | + |
| 94 | +Third-party locker plugins can be registered via the `hatch_register_locker` hook, implementing the `LockerInterface` to provide custom resolution strategies. |
| 95 | + |
| 96 | +### Additional commands |
| 97 | + |
| 98 | +- `hatch lock` — shorthand for locking the active environment |
| 99 | +- `hatch dep lock` — same workflow, scoped to the `-e` / `HATCH_ENV` selection |
| 100 | +- `hatch dep sync` — install from an existing lockfile (e.g. `uv pip sync`) |
| 101 | +- `--export` / `--export-all` — write lockfiles to custom paths or export all environments to a directory |
| 102 | + |
| 103 | +## The `hatch check` command |
| 104 | + |
| 105 | +The new [`check`](../../cli/reference.md#hatch-check) command brings linting, formatting verification, and type checking together under one roof: |
| 106 | + |
| 107 | +```console |
| 108 | +$ hatch check |
| 109 | +``` |
| 110 | + |
| 111 | +That single invocation runs all three checks in sequence. You can also target individual checks: |
| 112 | + |
| 113 | +```console |
| 114 | +$ hatch check code # static analysis (Ruff linter) |
| 115 | +$ hatch check fmt # formatting verification (Ruff formatter) |
| 116 | +$ hatch check types # type checking (Pyrefly) |
| 117 | +``` |
| 118 | + |
| 119 | +Add `--fix` to automatically apply fixes for code and formatting issues: |
| 120 | + |
| 121 | +```console |
| 122 | +$ hatch check --fix |
| 123 | +``` |
| 124 | + |
| 125 | +### Type checking with Pyrefly |
| 126 | + |
| 127 | +The `types` subcommand uses [Pyrefly](https://github.com/facebook/pyrefly) by default, bringing fast, incremental type checking to your workflow. It also supports `--cover` for type coverage reports and `--summarize` for error statistics. |
| 128 | + |
| 129 | +### Designed for extensibility |
| 130 | + |
| 131 | +The architecture behind `hatch check` is deliberately modular. Each subcommand (`code`, `fmt`, `types`) runs in its own dedicated managed environment (`hatch-check-code`, `hatch-check-fmt`, `hatch-check-types`), with its own scripts and configuration. |
| 132 | + |
| 133 | +This design sets the stage for extreme extensibility in future releases. The same pattern that lets Hatch manage Ruff and Pyrefly today will allow users to plug in their own checkers — security scanners, documentation linters, custom style enforcers, license auditors — as first-class `hatch check` subcommands. Each checker will be able to define its own environment, dependencies, and scripts, all orchestrated through the same unified interface. |
| 134 | + |
| 135 | +We are building toward a world where `hatch check` becomes the single entry point for every quality gate your project needs, with the plugin system handling the rest. |
| 136 | + |
| 137 | + |
| 138 | +### Support |
| 139 | + |
| 140 | +If you or your organization finds value in what Hatch provides, consider sponsoring our maintainers [Ofek](https://github.com/sponsors/ofek)[Cary](https://github.com/sponsors/cjames23) to assist with maintenance and more rapid development! |
0 commit comments