Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Aug 11, 2024
1 parent 40cba44 commit be2d747
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/uv-scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ uv-settings = { workspace = true }
uv-workspace = { workspace = true }

fs-err = { workspace = true, features = ["tokio"] }
indoc = { workspace = true }
memchr = { workspace = true }
serde = { workspace = true, features = ["derive"] }
thiserror = { workspace = true }
toml = { workspace = true }
indoc = { workspace = true }
8 changes: 6 additions & 2 deletions crates/uv-workspace/src/pyproject_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ pub enum ArrayEdit {
/// Specifies whether dependencies are added to a script file or a `pyproject.toml` file.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DependencyTarget {
/// A PEP 723 script, with inline metadata.
Script,
/// A project with a `pyproject.toml`.
PyProjectToml,
}

Expand Down Expand Up @@ -92,7 +94,8 @@ impl PyProjectTomlMut {
Ok(())
}

/// Retrieves a mutable reference to the root `Table` of the TOML document, creating the `project` table if necessary.
/// Retrieves a mutable reference to the root [`Table`] of the TOML document, creating the
/// `project` table if necessary.
fn doc(&mut self) -> Result<&mut Table, Error> {
let doc = match self.target {
DependencyTarget::Script => self.doc.as_table_mut(),
Expand All @@ -106,7 +109,8 @@ impl PyProjectTomlMut {
Ok(doc)
}

/// Retrieves an optional mutable reference to the `project` `Table`, returning `None` if it doesn't exist.
/// Retrieves an optional mutable reference to the `project` [`Table`], returning `None` if it
/// doesn't exist.
fn doc_mut(&mut self) -> Result<Option<&mut Table>, Error> {
let doc = match self.target {
DependencyTarget::Script => Some(self.doc.as_table_mut()),
Expand Down
11 changes: 6 additions & 5 deletions crates/uv/src/commands/project/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,18 @@ pub(crate) async fn add(
}
}
};
// If `--frozen`, exit early. There's no reason to lock and sync, and we don't need a `uv.lock`
// to exist at all.
if frozen {
return Ok(ExitStatus::Success);
}

// If `--script`, exit early. There's no reason to lock and sync.
let Target::Project(project, venv) = target else {
return Ok(ExitStatus::Success);
};

// If `--frozen`, exit early. There's no reason to lock and sync, and we don't need a `uv.lock`
// to exist at all.
if frozen {
return Ok(ExitStatus::Success);
}

let existing = project.pyproject_toml();

// Update the `pypackage.toml` in-memory.
Expand Down

0 comments on commit be2d747

Please sign in to comment.