From c01a023cd2c487a6ffc9d3b08eef6ce0479d5815 Mon Sep 17 00:00:00 2001 From: Pichot Date: Thu, 17 Oct 2024 11:40:03 +0800 Subject: [PATCH] Add NETRC to the default_pass_env list (#3410) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bernát Gábor --- docs/changelog/3410.feature.rst | 1 + docs/config.rst | 5 +++++ src/tox/tox_env/api.py | 1 + tests/session/cmd/test_show_config.py | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/3410.feature.rst diff --git a/docs/changelog/3410.feature.rst b/docs/changelog/3410.feature.rst new file mode 100644 index 0000000000..e07c6d4c22 --- /dev/null +++ b/docs/changelog/3410.feature.rst @@ -0,0 +1 @@ +Add ``NETRC`` to the list of environment variables always passed through. diff --git a/docs/config.rst b/docs/config.rst index 2393a88493..9df1eae798 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -530,6 +530,11 @@ Base options - ✅ - ✅ - ✅ + * - NETRC + - ✅ + - ✅ + - ✅ + More environment variable-related information diff --git a/src/tox/tox_env/api.py b/src/tox/tox_env/api.py index b98ad3b0aa..bdf4a0b0f3 100644 --- a/src/tox/tox_env/api.py +++ b/src/tox/tox_env/api.py @@ -220,6 +220,7 @@ def _default_pass_env(self) -> list[str]: # noqa: PLR6301 "HOME", # needed for `os.path.expanduser()` on non-Windows systems "FORCE_COLOR", # force color output "NO_COLOR", # disable color output + "NETRC", # used by pip and netrc modules ] if sys.stdout.isatty(): # if we're on a interactive shell pass on the TERM env.append("TERM") diff --git a/tests/session/cmd/test_show_config.py b/tests/session/cmd/test_show_config.py index a5015c260a..370b91f65d 100644 --- a/tests/session/cmd/test_show_config.py +++ b/tests/session/cmd/test_show_config.py @@ -126,7 +126,7 @@ def test_pass_env_config_default(tox_project: ToxProjectCreator, stdout_is_atty: + ["CPPFLAGS", "CURL_CA_BUNDLE", "CXX", "FORCE_COLOR", "HOME", "LANG"] + ["LANGUAGE", "LDFLAGS", "LD_LIBRARY_PATH"] + (["MSYSTEM"] if is_win else []) - + ["NO_COLOR"] + + ["NETRC", "NO_COLOR"] + (["NUMBER_OF_PROCESSORS", "PATHEXT"] if is_win else []) + ["PIP_*", "PKG_CONFIG", "PKG_CONFIG_PATH", "PKG_CONFIG_SYSROOT_DIR"] + (["PROCESSOR_ARCHITECTURE"] if is_win else [])