From d51b429837ff1fb3423389ae51f0c7fb435acdaf Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 25 Jul 2024 19:58:36 -0400 Subject: [PATCH] Add `--no-config` to replace `--isolated` (#5463) ## Summary I'll deprecate `--isolated` separately, since it _is_ still used for some other behaviors. Closes #5428. --- README.md | 3 +++ crates/uv-cli/src/lib.rs | 5 +++++ crates/uv/src/lib.rs | 2 +- crates/uv/tests/help.rs | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b7e1d085e..37e3eefa7 100644 --- a/README.md +++ b/README.md @@ -587,6 +587,9 @@ uv accepts the following command-line arguments as environment variables: will use this value as the keyring provider. - `UV_CONFIG_FILE`: Equivalent to the `--config-file` command-line argument. Expects a path to a local `uv.toml` file to use as the configuration file. +- `UV_NO_CONFIG`: Equivalent to the `--no-config` command-line argument. If set, uv will not read + any configuration files from the current directory, parent directories, or user configuration + directories. - `UV_CONCURRENT_DOWNLOADS`: Sets the maximum number of in-flight concurrent downloads that `uv` will perform at any given time. - `UV_CONCURRENT_BUILDS`: Sets the maximum number of source distributions that `uv` will build diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 4926a980a..d8e938886 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -75,6 +75,11 @@ pub struct Cli { #[arg(global = true, long, env = "UV_CONFIG_FILE")] pub config_file: Option, + /// Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current directory, + /// parent directories, or user configuration directories. + #[arg(global = true, long, env = "UV_NO_CONFIG", value_parser = clap::builder::BoolishValueParser::new())] + pub no_config: bool, + /// Print help. #[arg(global = true, short, long, action = clap::ArgAction::HelpShort)] help: Option, diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index d5a6cbe2a..0e4334938 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -71,7 +71,7 @@ async fn run(cli: Cli) -> Result { // search for `pyproject.toml` files, since we're not in a workspace. let filesystem = if let Some(config_file) = cli.config_file.as_ref() { Some(FilesystemOptions::from_file(config_file)?) - } else if cli.global_args.isolated { + } else if cli.global_args.isolated || cli.no_config { None } else if let Ok(project) = Workspace::discover(&std::env::current_dir()?, &DiscoveryOptions::default()).await diff --git a/crates/uv/tests/help.rs b/crates/uv/tests/help.rs index f447f824f..ae95fa583 100644 --- a/crates/uv/tests/help.rs +++ b/crates/uv/tests/help.rs @@ -55,6 +55,9 @@ fn help() { Path to the cache directory [env: UV_CACHE_DIR=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=] -h, --help Print help -V, --version @@ -118,6 +121,9 @@ fn help_flag() { Path to the cache directory [env: UV_CACHE_DIR=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=] -h, --help Print help -V, --version @@ -180,6 +186,9 @@ fn help_short_flag() { Path to the cache directory [env: UV_CACHE_DIR=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=] -h, --help Print help -V, --version @@ -297,6 +306,12 @@ fn help_subcommand() { [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories + + [env: UV_NO_CONFIG=] + -h, --help Print help @@ -419,6 +434,12 @@ fn help_subsubcommand() { [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories + + [env: UV_NO_CONFIG=] + -h, --help Print help @@ -481,6 +502,9 @@ fn help_flag_subcommand() { Path to the cache directory [env: UV_CACHE_DIR=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=] -h, --help Print help -V, --version @@ -540,6 +564,9 @@ fn help_flag_subsubcommand() { Path to the cache directory [env: UV_CACHE_DIR=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=] -h, --help Print help -V, --version @@ -656,6 +683,9 @@ fn help_with_global_option() { Path to the cache directory [env: UV_CACHE_DIR=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=] -h, --help Print help -V, --version @@ -752,6 +782,9 @@ fn test_with_no_pager() { Path to the cache directory [env: UV_CACHE_DIR=] --config-file The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=] + --no-config + Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current + directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=] -h, --help Print help -V, --version