Make missing project table a tracing warning (#5194)

Closes https://github.com/astral-sh/uv/issues/5068.
This commit is contained in:
Charlie Marsh 2024-07-18 14:21:39 -04:00 committed by GitHub
parent 5bcdaedf8b
commit 6a6e3b464f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
use either::Either; use either::Either;
use glob::{glob, GlobError, PatternError}; use glob::{glob, GlobError, PatternError};
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use tracing::{debug, trace}; use tracing::{debug, trace, warn};
use pep508_rs::{RequirementOrigin, VerbatimUrl}; use pep508_rs::{RequirementOrigin, VerbatimUrl};
use pypi_types::{Requirement, RequirementSource}; use pypi_types::{Requirement, RequirementSource};
@ -833,7 +833,7 @@ async fn find_workspace(
Ok(None) Ok(None)
} else { } else {
// We require that a `project.toml` file either declares a workspace or a project. // We require that a `project.toml` file either declares a workspace or a project.
warn_user!( warn!(
"pyproject.toml does not contain `project` table: `{}`", "pyproject.toml does not contain `project` table: `{}`",
pyproject_path.simplified_display() pyproject_path.simplified_display()
); );
@ -863,10 +863,9 @@ fn check_nested_workspaces(inner_workspace_root: &Path, stop_discovery_at: Optio
let contents = match fs_err::read_to_string(&pyproject_toml_path) { let contents = match fs_err::read_to_string(&pyproject_toml_path) {
Ok(contents) => contents, Ok(contents) => contents,
Err(err) => { Err(err) => {
warn_user!( warn!(
"Unreadable pyproject.toml `{}`: {}", "Unreadable pyproject.toml `{}`: {err}",
pyproject_toml_path.user_display(), pyproject_toml_path.simplified_display()
err
); );
return; return;
} }
@ -874,10 +873,9 @@ fn check_nested_workspaces(inner_workspace_root: &Path, stop_discovery_at: Optio
let pyproject_toml: PyProjectToml = match toml::from_str(&contents) { let pyproject_toml: PyProjectToml = match toml::from_str(&contents) {
Ok(contents) => contents, Ok(contents) => contents,
Err(err) => { Err(err) => {
warn_user!( warn!(
"Invalid pyproject.toml `{}`: {}", "Invalid pyproject.toml `{}`: {err}",
pyproject_toml_path.user_display(), pyproject_toml_path.simplified_display()
err
); );
return; return;
} }
@ -896,18 +894,17 @@ fn check_nested_workspaces(inner_workspace_root: &Path, stop_discovery_at: Optio
) { ) {
Ok(contents) => contents, Ok(contents) => contents,
Err(err) => { Err(err) => {
warn_user!( warn!(
"Invalid pyproject.toml `{}`: {}", "Invalid pyproject.toml `{}`: {err}",
pyproject_toml_path.user_display(), pyproject_toml_path.simplified_display()
err
); );
return; return;
} }
}; };
if !is_excluded { if !is_excluded {
warn_user!( warn_user!(
"Outer workspace including existing workspace, nested workspaces are not supported: `{}`", "Nested workspaces are not supported, but outer workspace includes existing workspace: `{}`",
pyproject_toml_path.user_display(), pyproject_toml_path.user_display().cyan(),
); );
} }
} }