Summary
ScriptTag::parse in uv-scripts/src/lib.rs finds the first # /// script block using FINDER.find(contents) (line ~500) and returns its TOML. It never checks whether the file contains a second # /// script block after the first one closes.
PEP 723 says tools MUST error when a script contains multiple embedded metadata blocks. Right now uv silently uses whichever one comes first and ignores any others.
A file like this should be rejected:
# /// script
# dependencies = ["requests"]
# ///
print("hi")
# /// script
# dependencies = ["flask"]
# ///
Instead uv picks requests and quietly drops flask.
Platform
Linux x86_64 (code-level, platform-independent)
Version
latest main (code read from HEAD)
Summary
ScriptTag::parseinuv-scripts/src/lib.rsfinds the first# /// scriptblock usingFINDER.find(contents)(line ~500) and returns its TOML. It never checks whether the file contains a second# /// scriptblock after the first one closes.PEP 723 says tools MUST error when a script contains multiple embedded metadata blocks. Right now uv silently uses whichever one comes first and ignores any others.
A file like this should be rejected:
Instead uv picks
requestsand quietly dropsflask.Platform
Linux x86_64 (code-level, platform-independent)
Version
latest main (code read from HEAD)