Hint at --no-workspace in uv init failures (#6815)

## Summary

We now both (1) include the `pyproject.toml` (which we were doing
sometimes, but inconsistently) and (2) hint at `--no-workspace`).

Closes https://github.com/astral-sh/uv/issues/6393.

## Test Plan

Looks like this now:

![Screenshot 2024-08-29 at 10 44
55 AM](https://github.com/user-attachments/assets/a7c4cbff-704b-4dac-b0e4-e8e12a2b1f5d)
This commit is contained in:
Charlie Marsh 2024-08-29 12:57:09 -04:00 committed by GitHub
parent f046e54c64
commit d62952ec21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 5 deletions

View file

@ -158,7 +158,7 @@ impl Workspace {
workspace
} else if pyproject_toml.project.is_none() {
// Without a project, it can't be an implicit root
return Err(WorkspaceError::MissingProject(project_path));
return Err(WorkspaceError::MissingProject(pyproject_path));
} else if let Some(workspace) = find_workspace(&project_path, options).await? {
// We have found an explicit root above.
workspace
@ -610,7 +610,7 @@ impl Workspace {
};
let pyproject_toml = PyProjectToml::from_string(contents)
.map_err(|err| WorkspaceError::Toml(pyproject_path, Box::new(err)))?;
.map_err(|err| WorkspaceError::Toml(pyproject_path.clone(), Box::new(err)))?;
// Check if the current project is explicitly marked as unmanaged.
if pyproject_toml
@ -629,7 +629,7 @@ impl Workspace {
// Extract the package name.
let Some(project) = pyproject_toml.project.clone() else {
return Err(WorkspaceError::MissingProject(member_root));
return Err(WorkspaceError::MissingProject(pyproject_path));
};
debug!(
@ -825,7 +825,7 @@ impl ProjectWorkspace {
let project = pyproject_toml
.project
.clone()
.ok_or_else(|| WorkspaceError::MissingProject(pyproject_path.clone()))?;
.ok_or_else(|| WorkspaceError::MissingProject(pyproject_path))?;
Self::from_project(project_root, &project, &pyproject_toml, options).await
}