Skip to content

Commit 2b7de69

Browse files
committed
add semi-automatic ways to upgrade pyproject.toml
1 parent 1957361 commit 2b7de69

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

docs/posts/2025/2025-08-26-python-uv-cheat-sheet.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ categories:
1010
comments: true
1111
date:
1212
created: 2025-08-26
13-
updated: 2025-09-07
13+
updated: 2025-10-04
1414
---
1515

1616
# Python uv cheat sheet
@@ -391,9 +391,20 @@ Skipping bytecode compilation can be undesirable in workflows; for example, we r
391391

392392
## Upgrade packages and uv.lock
393393

394-
The only way to change the package version constraints is to edit manually the `pyproject.toml` file directly. After making changes to `pyproject.toml`, you should run `uv sync` to update the venv dependencies and the `uv.lock` file accordingly. Or `uv lock` to update only the `uv.lock` file without changing the venv dependencies.
394+
### Upgrade pyproject.toml
395395

396-
[`uv.lock` file](https://docs.astral.sh/uv/concepts/projects/layout/#the-lockfile) can be updated by `uv lock`, `uv sync`, `uv run`, `uv add`, `uv remove`.
396+
The only way to change the package version constraints is to edit manually the `pyproject.toml` file directly.
397+
After making changes to `pyproject.toml`, you should run `uv sync` to upgrade the venv dependencies and the `uv.lock` file accordingly.
398+
Or `uv lock` to upgrade only the `uv.lock` file without changing the venv dependencies.
399+
400+
!!! note "other semi-automatic ways to upgrade pyproject.toml"
401+
Beside above mentioned manual edit of `pyproject.toml` with `uv tree --outdated | grep latest`, we do have some semi-automatic ways to upgrade`pyproject.toml`, like [Github dependabot](https://docs.github.com/en/code-security/getting-started/dependabot-quickstart-guide), or [Renovate](https://docs.renovatebot.com/), they will create PRs to upgrade`pyproject.toml` automatically.
402+
403+
Or locally in VSCode, the [Dependi extension](https://marketplace.visualstudio.com/items?itemName=fill-labs.dependi) is pretty good, it shows in-line the latest version in the editor, and can upgrade the whole `pyproject.toml`with a click.
404+
405+
### Upgrade uv.lock
406+
407+
[`uv.lock` file](https://docs.astral.sh/uv/concepts/projects/layout/#the-lockfile) can be updated by `uv lock`,`uv sync`,`uv run`,`uv add`,`uv remove`.
397408

398409
| Command | Description |
399410
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

0 commit comments

Comments
 (0)