`uv lock` 直到在 `pyproject.toml` 中进行有意义的编辑后,才会将无意义的编辑传播到 `uv.lock`
作者: GideonBear创建于 2026年1月17日更新于 2026年9月26日
标签needs-decision
$ mkdir delme && cd delme $ uv init $ uv sync $ git add . $ git commit -m "Initial commit" $ uv add termcolor $ git diff
diff --git a/pyproject.toml b/pyproject.toml
index 92a83e5..d95598e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,4 +4,6 @@ version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-Python = ">=3.14"
-dependencies = []
+dependencies = [
+ "termcolor>=3.3.0",
+]
diff --git a/uv.lock b/uv.lock
index b1b7a41..5a32051 100644
--- a/uv.lock
+++ b/uv.lock
@@ -6,3 +6,18 @@ requires-Python = ">=3.14"
name = "delme"
version = "0.1.0"
source = { virtual = "." }
+dependencies = [
+ { name = "termcolor" },
+]
+
+[package.metadata]
+requires-dist = [{ name = "termcolor", specifier = ">=3.3.0" }]
+
+[[package]]
+name = "termcolor"
+version = "3.3.0"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/46/79/cf31d7a93a8fdc6aa0fbb665be84426a8c5a557d9240b6239e9e11e35fc5/termcolor-3.3.0.tar.gz", hash = "sha256:348871ca648ec6a9a983a13ab626c0acce02f515b9e1983332b17af7979521c5", size = 14434, upload-time = "2025-12-29T12:55:21.882Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/33/d1/8bb87d21e9aeb323cc03034f5eaf2c8f69841e40e4853c2627edf8111ed3/termcolor-3.3.0-py3-none-any.whl", hash = "sha256:cf642efadaf0a8ebbbf4bc7a31cec2f9b5f21a9f726f4ccbb08192c9c26f43a5", size = 7734, upload-time = "2025-12-29T12:55:20.718Z" },
+]$ git commit -am "Add termcolor"
$ sed -i 's/3.3.0/3.3/' pyproject.toml
# Or:
$ uvx pyproject-fmt pyproject.toml
$ git diff
```diff
diff --git a/pyproject.toml b/pyproject.toml
index d95598e..c2b1a39 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,5 +5,5 @@ description = "Add your description here"
readme = "README.md"
requires-Python = ">=3.14"
dependencies = [
- "termcolor>=3.3.0",
+ "termcolor>=3.3",
]
```console
$ uv lock
# No change in lockfile!
$ git commit -am "Format pyproject.toml"
# Do any operation on pyproject.fmt, like:
$ uv version --bump patch
$ git diff
```diff
diff --git a/pyproject.toml b/pyproject.toml
index c2b1a39..a447926 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "delme"
-version = "0.1.0"
+version = "0.1.1"
description = "Add your description here"
readme = "README.md"
requires-Python = ">=3.14"
diff --git a/uv.lock b/uv.lock
index 5a32051..72af669 100644
--- a/uv.lock
+++ b/uv.lock
@@ -4,14 +4,14 @@
…内容来源: astral-sh/uv