Update PEP 723 lockfile in uv add --script (#10145)

## Summary

`uv add --script main.py anyio` will now update the lockfile, _if_ it
already exists. (If no such lockfile exists, the behavior is unchanged.)
This commit is contained in:
Charlie Marsh 2025-01-08 16:19:12 -05:00 committed by GitHub
parent e22b728e3f
commit 31b2d3f988
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 585 additions and 121 deletions

View file

@ -230,7 +230,7 @@ impl Pep723Script {
}
/// Replace the existing metadata in the file with new metadata and write the updated content.
pub async fn write(&self, metadata: &str) -> Result<(), Pep723Error> {
pub fn write(&self, metadata: &str) -> Result<(), io::Error> {
let content = format!(
"{}{}{}",
self.prelude,
@ -238,7 +238,7 @@ impl Pep723Script {
self.postlude
);
fs_err::tokio::write(&self.path, content).await?;
fs_err::write(&self.path, content)?;
Ok(())
}
@ -307,7 +307,7 @@ impl Pep723Metadata {
}
impl FromStr for Pep723Metadata {
type Err = Pep723Error;
type Err = toml::de::Error;
/// Parse `Pep723Metadata` from a raw TOML string.
fn from_str(raw: &str) -> Result<Self, Self::Err> {