-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add --no-proxy Option #13051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add --no-proxy Option #13051
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add ``--no-proxy-env`` option to bypass http proxy. Using this option will ignore any configured http proxies, including any environmental variables | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -274,6 +274,15 @@ class PipOption(Option): | |||||||||||||||||||||||||||||||||
help="Specify a proxy in the form scheme://[user:passwd@]proxy.server:port.", | ||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
no_proxy: Callable[..., Option] = partial( | ||||||||||||||||||||||||||||||||||
Option, | ||||||||||||||||||||||||||||||||||
"--no-proxy-env", | ||||||||||||||||||||||||||||||||||
dest="no_proxy", | ||||||||||||||||||||||||||||||||||
action="store_true", | ||||||||||||||||||||||||||||||||||
default=False, | ||||||||||||||||||||||||||||||||||
help="Ignore all configured proxy settings, including environmental variables.", | ||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||
Comment on lines
+277
to
+284
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
retries: Callable[..., Option] = partial( | ||||||||||||||||||||||||||||||||||
Option, | ||||||||||||||||||||||||||||||||||
"--retries", | ||||||||||||||||||||||||||||||||||
|
@@ -1048,6 +1057,7 @@ def check_list_path_option(options: Values) -> None: | |||||||||||||||||||||||||||||||||
no_input, | ||||||||||||||||||||||||||||||||||
keyring_provider, | ||||||||||||||||||||||||||||||||||
proxy, | ||||||||||||||||||||||||||||||||||
no_proxy, | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
retries, | ||||||||||||||||||||||||||||||||||
timeout, | ||||||||||||||||||||||||||||||||||
exists_action, | ||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,19 @@ def _build_session( | |
} | ||
session.trust_env = False | ||
|
||
# Handle no proxy option | ||
if options.no_proxy: | ||
# Handle case of both --no-proxy-env being set along with --proxy=<proxy>. | ||
# In this case, the proxies from the environmental variables will be | ||
# ignored, but the command line proxy will be used. | ||
http_proxy = options.proxy if options.proxy else None | ||
https_proxy = options.proxy if options.proxy else None | ||
session.proxies = { | ||
"http": http_proxy, | ||
"https": https_proxy, | ||
} | ||
session.trust_env = False | ||
|
||
Comment on lines
+127
to
+139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be merged into the pre-existing proxy logic in the following way, but would be this too magical? # Handle configured proxies, including --no-proxy-env
if options.proxy or options.no_proxy_env:
session.proxies = {
"http": options.proxy or None,
"https": options.proxy or None,
}
session.trust_env = False |
||
# Determine if we can prompt the user for authentication or not | ||
session.auth.prompting = not options.no_input | ||
session.auth.keyring_provider = options.keyring_provider | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.