repo/lockfile-committed/python
Dependency lockfile is committed
Implements repo/lockfile-committed for python.
| Severity | error |
| Tiers | 1, 2 |
| Stacks | python |
| Scope | each |
| Kind | expr |
| Source | library v0.8.0 |
| Selected by | fleetlint-recommended@v0.8.0 |
Requirement
A Python lockfile is tracked next to the project (or, for a uv workspace member, at the workspace root): uv.lock, poetry.lock, pdm.lock, Pipfile.lock, pylock.toml, or a requirements file that pins hashes (--hash=) or was generated by pip-compile / uv pip compile. A hand-written requirements.txt is not a lockfile. A pyproject.toml without dependencies needs none.
Why
Builds are reproducible only when dependency versions are pinned in git.
Check
tracked().exists(f, f in ["uv.lock", "poetry.lock", "pdm.lock", "Pipfile.lock", "pylock.toml"] || f.matches(r'^pylock\.[^/]+\.toml$')) || ["../", "../../", "../../../"].exists(d, file(d + "uv.lock") && file(d + "pyproject.toml") && text(d + "pyproject.toml").contains("[tool.uv.workspace]")) || tracked().exists(f, f.matches(r'^(requirements/[^/]+|requirements[^/]*)\.(txt|lock)$')
&& text(f).matches(r'--hash=|autogenerated by (pip-compile|uv)'))
|| (file("pyproject.toml") && !file("setup.py") && !exists("requirements*.txt")
&& !text("pyproject.toml").matches(r'(?m)^\s*dependencies\s*=\s*\[\s*($|[\x22\x27#])|\[tool\.poetry\.(group\.[^.\]]+\.)?dependencies\]|\[dependency-groups\]'))Fix
Lock the dependencies (uv lock, poetry lock, or uv pip compile --generate-hashes) and commit the lockfile.
Agent instruction (from repo/lockfile-committed): Run the package manager to produce the lockfile, remove any .gitignore entry for it, and commit it.
A finding that names no file points at uv.lock.
Sources
- https://github.com/ossf/package-manager-best-practices/blob/main/published/npm.md (guidance)
- https://fleetlint.org/baseline/#dependencies (convention)
- https://docs.astral.sh/uv/concepts/projects/layout/ (spec, The lockfile)
- https://fleetlint.org/stacks/#python
Generated by fleetlint docs from catalog v0.8.0.