Skip to content

Commit d2afcb6

Browse files
authored
Update docs as pre-release for 1.17.0 (#2287)
* Update docs as pre-release for 1.17.0 * Add blog post * Update blog post
1 parent 818d284 commit d2afcb6

10 files changed

Lines changed: 292 additions & 34 deletions

File tree

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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!

docs/community/contributing.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,16 @@ hatch test --cover --all
4848

4949
## Lint
5050

51-
Run automated formatting:
51+
Run automated formatting and linting fixes:
5252

5353
```bash
54-
hatch fmt
54+
hatch check --fix
5555
```
5656

57-
Run full linting and type checking:
57+
Run all checks (linting, formatting, type checking):
5858

5959
```bash
60-
hatch fmt --check
61-
hatch run types:check
60+
hatch check
6261
```
6362

6463
## Docs

docs/config/environment/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ version = ["0.1.0", "0.2.0", "1.0.0"]
279279
```toml config-example
280280
[tool.hatch.envs.test.overrides]
281281
matrix.foo.dependencies = [
282-
"httpx",
282+
"httpx2",
283283
{ value = "cryptography" },
284284
]
285285
```

docs/config/internal/static-analysis.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
-----
44

5-
Static analysis performed by the [`fmt`](../../cli/reference.md#hatch-fmt) command is ([by default](#customize-behavior)) backed entirely by [Ruff](https://github.com/astral-sh/ruff).
5+
Static analysis performed by the [`check code`](../../cli/reference.md#hatch-check-code) and [`check fmt`](../../cli/reference.md#hatch-check-fmt) commands is ([by default](#customize-behavior)) backed entirely by [Ruff](https://github.com/astral-sh/ruff).
66

77
Hatch provides [default settings](#default-settings) that user configuration can [extend](#extending-config).
88

9+
!!! note
10+
The [`fmt`](../../cli/reference.md#hatch-fmt) command is being deprecated. Use `hatch check code` for linting and `hatch check fmt` for formatting instead.
11+
912
## Extending config
1013

1114
When defining your configuration, be sure to use options that are prefixed by `extend-` such as [`extend-select`](https://docs.astral.sh/ruff/settings/#extend-select), for example:
@@ -73,10 +76,10 @@ Then instruct Ruff to consider your configuration as an extension of the default
7376
extend = "ruff_defaults.toml"
7477
```
7578

76-
Anytime you wish to update the defaults (such as when upgrading Hatch), you must run the [`fmt`](../../cli/reference.md#hatch-fmt) command once with the `--sync` flag e.g.:
79+
Anytime you wish to update the defaults (such as when upgrading Hatch), you must run the [`check code`](../../cli/reference.md#hatch-check-code) or [`check fmt`](../../cli/reference.md#hatch-check-fmt) command once with the `--sync` flag e.g.:
7780

7881
```
79-
hatch fmt --check --sync
82+
hatch check code --sync
8083
```
8184

8285
!!! tip
@@ -93,30 +96,43 @@ config-path = "none"
9396

9497
## Customize behavior
9598

96-
You can fully alter the behavior of the environment used by the [`fmt`](../../cli/reference.md#hatch-fmt) command. See the [how-to](../../how-to/static-analysis/behavior.md) for a detailed example.
99+
You can fully alter the behavior of the environments used by the [`check code`](../../cli/reference.md#hatch-check-code) and [`check fmt`](../../cli/reference.md#hatch-check-fmt) commands. See the [how-to](../../how-to/static-analysis/behavior.md) for a detailed example.
100+
101+
The `check code` command uses the `hatch-check-code` environment, and the `check fmt` command uses the `hatch-check-fmt` environment. The legacy `fmt` command continues to use the `hatch-static-analysis` environment.
97102

98103
### Dependencies
99104

100105
Pin the particular version of Ruff by explicitly defining the environment [dependencies](../environment/overview.md#dependencies):
101106

102107
```toml config-example
103-
[tool.hatch.envs.hatch-static-analysis]
108+
[tool.hatch.envs.hatch-check-code]
109+
dependencies = ["ruff==X.Y.Z"]
110+
111+
[tool.hatch.envs.hatch-check-fmt]
104112
dependencies = ["ruff==X.Y.Z"]
105113
```
106114

107115
### Scripts
108116

109-
If you want to change the default commands that are executed, you can override the [scripts](../environment/overview.md#scripts). The following four scripts must be defined:
117+
If you want to change the default commands that are executed, you can override the [scripts](../environment/overview.md#scripts).
118+
119+
For the `hatch-check-code` environment:
110120

111121
```toml config-example
112-
[tool.hatch.envs.hatch-static-analysis.scripts]
113-
format-check = "..."
114-
format-fix = "..."
122+
[tool.hatch.envs.hatch-check-code.scripts]
115123
lint-check = "..."
116124
lint-fix = "..."
117125
```
118126

119-
The `format-*` scripts correspond to the `--formatter`/`-f` flag while the `lint-*` scripts correspond to the `--linter`/`-l` flag. The `*-fix` scripts run by default while the `*-check` scripts correspond to the `--check` flag.
127+
For the `hatch-check-fmt` environment:
128+
129+
```toml config-example
130+
[tool.hatch.envs.hatch-check-fmt.scripts]
131+
format-check = "..."
132+
format-fix = "..."
133+
```
134+
135+
The `*-fix` scripts run by default while the `*-check` scripts run when the `--fix` flag is not passed.
120136

121137
!!! note "Reminder"
122138
If you choose to use different tools for static analysis, be sure to update the required [dependencies](#dependencies).
@@ -126,7 +142,10 @@ The `format-*` scripts correspond to the `--formatter`/`-f` flag while the `lint
126142
By default, [UV is enabled](../../how-to/environment/select-installer.md). You may disable that behavior as follows:
127143

128144
```toml config-example
129-
[tool.hatch.envs.hatch-static-analysis]
145+
[tool.hatch.envs.hatch-check-code]
146+
installer = "pip"
147+
148+
[tool.hatch.envs.hatch-check-fmt]
130149
installer = "pip"
131150
```
132151

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Type checking configuration
2+
3+
-----
4+
5+
Type checking performed by the [`check types`](../../cli/reference.md#hatch-check-types) command is ([by default](#customize-behavior)) backed by [Pyrefly](https://github.com/facebook/pyrefly).
6+
7+
## Configuration
8+
9+
When no user configuration is detected, Hatch auto-generates a `pyrefly.toml` config file that:
10+
11+
- Detects source directories (src layout, workspace members, tests)
12+
- Sets appropriate search paths for import resolution
13+
- Uses the `legacy` preset for relaxed type checking suitable for existing codebases
14+
- Ignores platform-conditional dependencies that aren't installed locally
15+
16+
### User configuration
17+
18+
Hatch respects existing Pyrefly configuration. If any of the following exist, the auto-generated config will not be used:
19+
20+
- A `pyrefly.toml` file in the project root
21+
- A `[tool.pyrefly]` section in `pyproject.toml`
22+
23+
### Persistent config
24+
25+
If you want to store the default configuration in the project, set an explicit path:
26+
27+
```toml config-example
28+
[tool.hatch.envs.hatch-check-types]
29+
config-path = "pyrefly.toml"
30+
```
31+
32+
## Customize behavior
33+
34+
You can fully alter the behavior of the environment used by the [`check types`](../../cli/reference.md#hatch-check-types) command by modifying the reserved [environment](../../config/environment/overview.md) named `hatch-check-types`.
35+
36+
### Dependencies
37+
38+
The environment includes Pyrefly and all test dependencies (inherited from the `hatch-test` environment) to ensure type checking has access to all imports. Pin the particular version of Pyrefly by explicitly defining the environment [dependencies](../environment/overview.md#dependencies):
39+
40+
```toml config-example
41+
[tool.hatch.envs.hatch-check-types]
42+
dependencies = ["pyrefly==X.Y.Z"]
43+
```
44+
45+
### Scripts
46+
47+
If you want to change the default commands that are executed, you can override the [scripts](../environment/overview.md#scripts):
48+
49+
```toml config-example
50+
[tool.hatch.envs.hatch-check-types.scripts]
51+
check = "..."
52+
check-summarize = "..."
53+
coverage = "..."
54+
```
55+
56+
The `check` script runs by default. The `check-summarize` script runs when the `--summarize` flag is passed. The `coverage` script runs when the `--cover` flag is passed.
57+
58+
### Installer
59+
60+
By default, [UV is enabled](../../how-to/environment/select-installer.md). You may disable that behavior as follows:
61+
62+
```toml config-example
63+
[tool.hatch.envs.hatch-check-types]
64+
installer = "pip"
65+
```

docs/history/hatch.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
## Unreleased
1010

11+
***Changed:***
12+
13+
- The `hatch fmt` command is now deprecated in favor of the new `hatch check` command group
14+
- Migrate HTTP client from `httpx` to `httpx2`
15+
16+
***Added:***
17+
18+
- Add `hatch check` command group with subcommands for `check code` (linting), `check fmt` (formatting), and `check types` (type checking)
19+
- Add `hatch check types` command for type checking using Pyrefly, with `--summarize` and `--cover` flags
20+
- Add `hatch env lock` command to generate PEP 751 compliant lockfiles (`pylock.toml`) for environments
21+
- Add `hatch dep lock` and `hatch lock` commands as shortcuts for locking the active environment
22+
- Add `hatch dep sync` command for syncing dependencies from a lockfile
23+
- Add pluggable dependency locker interface with built-in UV and pip implementations
24+
- Add `--cover-xml` and `--cover-xml-output` flags to the `hatch test` command for generating XML coverage reports
25+
- Add linehaul telemetry data to User-Agent header for PyPI download statistics
26+
- Auto-create environment when locking if it doesn't exist
27+
28+
***Fixed:***
29+
30+
- Fix help output formatting for the `run` command
31+
1132
## [1.16.5](https://github.com/pypa/hatch/releases/tag/hatch-v1.16.5) - 2026-02-26 ## {: #hatch-v1.16.5 }
1233

1334
***Fixed:***

docs/history/hatchling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212

1313
- Support PEP 794 (core metadata `Import-Name` and `Import-Namespace` fields and version 2.5)
1414

15+
***Fixed:***
16+
17+
- Exclude Git worktree metadata files from sdists
18+
1519
## [1.29.0](https://github.com/pypa/hatch/releases/tag/hatchling-v1.29.0) - 2026-02-21 ## {: #hatchling-v1.29.0 }
1620

1721
***Fixed:***

docs/how-to/run/python-scripts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ The following is an example of Python script with a valid metadata block:
1717
# /// script
1818
# requires-python = ">=3.11"
1919
# dependencies = [
20-
# "httpx",
20+
# "httpx2",
2121
# "rich",
2222
# ]
2323
# ///
2424

25-
import httpx
25+
import httpx2
2626
from rich.pretty import pprint
2727

28-
resp = httpx.get("https://peps.python.org/api/peps.json")
28+
resp = httpx2.get("https://peps.python.org/api/peps.json")
2929
data = resp.json()
3030
pprint([(k, v["title"]) for k, v in data.items()][:10])
3131
```

0 commit comments

Comments
 (0)