Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tfsingh committed Sep 20, 2024
1 parent 53a54e5 commit ff11408
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,7 @@ pub struct InitArgs {
///
/// By default, the Python version the script depends on is the system version; can be
/// manually specified with the --python argument (takes absolute precedence) or a
/// .python-version file (ignore with --no_pin_python).
/// .python-version file (ignore with --`no_pin_python`).
#[arg(long, alias="script", conflicts_with_all=["app", "lib", "package"])]
pub r#script: bool,

Expand Down
13 changes: 8 additions & 5 deletions crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ pub(crate) async fn init(
script_path.cyan()
)?;
return Ok(ExitStatus::Success);
} else {
anyhow::bail!("Filename not provided for script");
}
anyhow::bail!("Filename not provided for script");
}

// Default to the current directory if a path was not provided.
Expand Down Expand Up @@ -463,7 +462,7 @@ impl InitProjectKind {
.await
}
InitProjectKind::Script => {
dbg!("Script should be initialized directly via init_script");
debug!("Script should be initialized directly via init_script");
anyhow::bail!("Error during script initialization")
}
}
Expand Down Expand Up @@ -610,6 +609,7 @@ impl InitProjectKind {
Ok(())
}

#[allow(clippy::fn_params_excessive_bools)]
async fn init_script(
self,
script_path: &PathBuf,
Expand All @@ -636,8 +636,11 @@ impl InitProjectKind {
}

if let Some(path) = script_path.to_str() {
if !path.ends_with(".py") {
anyhow::bail!("Script name must end in .py extension");
if !std::path::Path::new(path)
.extension()
.map_or(false, |ext| ext.eq_ignore_ascii_case("py"))
{
anyhow::bail!("Script must end in .py extension");
}
}

Expand Down
10 changes: 6 additions & 4 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ uv init [OPTIONS] [PATH]

<h3 class="cli-reference">Arguments</h3>

<dl class="cli-reference"><dt><code>PATH</code></dt><dd><p>The path to use for the project.</p>
<dl class="cli-reference"><dt><code>PATH</code></dt><dd><p>The path to use for the project/script.</p>

<p>Defaults to the current working directory. Accepts relative and absolute paths.</p>
<p>Defaults to the current working directory when initializing an app or library; required when initializing a script. Accepts relative and absolute paths.</p>

<p>If a <code>pyproject.toml</code> is found in any of the parent directories of the target path, the project will be added as a workspace member of the parent, unless <code>--no-workspace</code> is provided.</p>

Expand Down Expand Up @@ -516,9 +516,11 @@ uv init [OPTIONS] [PATH]
</ul>
</dd><dt><code>--quiet</code>, <code>-q</code></dt><dd><p>Do not print any output</p>

</dd><dt><code>--script</code></dt><dd><p>Create a script with inline metadata.</p>
</dd><dt><code>--script</code></dt><dd><p>Create a script.</p>

<p>A Python script is a file intended for standalone execution with or without dependencies.</p>
<p>A script is a standalone file which adheres to the PEP-723 specification.</p>

<p>By default, the Python version the script depends on is the system version; can be manually specified with the --python argument (takes absolute precedence) or a .python-version file (ignore with --<code>no_pin_python</code>).</p>

</dd><dt><code>--verbose</code>, <code>-v</code></dt><dd><p>Use verbose output.</p>

Expand Down

0 comments on commit ff11408

Please sign in to comment.