Search beyond workspace root when discovering configuration (#5931)

## Summary

Previously, we wouldn't respect configuration files in directories
_above_ a workspace root. But this is somewhat problematic, because any
`pyproject.toml` will define a workspace root...

Instead, I think we should _start_ the search at the workspace root, but
go above it if necessary.

Closes: #5929.

See: https://github.com/astral-sh/uv/pull/4295.
This commit is contained in:
Charlie Marsh 2024-08-08 17:05:02 -04:00 committed by GitHub
parent cbc3274848
commit 88ece8b791
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 284 additions and 10 deletions

View file

@ -40,9 +40,12 @@ impl FilesystemOptions {
let root = dir.join("uv");
let file = root.join("uv.toml");
debug!("Loading user configuration from: `{}`", file.display());
debug!("Searching for user configuration in: `{}`", file.display());
match read_file(&file) {
Ok(options) => Ok(Some(Self(options))),
Ok(options) => {
debug!("Found user configuration in: `{}`", file.display());
Ok(Some(Self(options)))
}
Err(Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => Ok(None),
Err(_) if !dir.is_dir() => {
// Ex) `XDG_CONFIG_HOME=/dev/null`