Skip to content
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

Fix #2527: Add ability to suppress nested venv courtesy notice #2581

Closed
wants to merge 5 commits into from

Conversation

Haplo-Dragon
Copy link
Contributor

This will add an environment variable, PIPENV_SUPPRESS_NESTED_WARNING, to be used to suppress the courtesy notice from warn_in_virtualenv (produced when pipenv finds itself running inside another virtual environment).
It will also add a sentence to the end of the courtesy notice to tell users how to suppress the notice.

I ended up putting the test in its own file - if there's a more logical place to put it, let me know!

Fixes #2527.

Added an environment variable, PIPENV_SUPPRESS_NESTED_WARNING, to be
used to suppress the courtesy notice from warn_in_virtualenv.
Changed wording of the courtesy notice to mention suppression variable.
Fixes pypa#2527.
@Haplo-Dragon
Copy link
Contributor Author

Hmmm, the tests were all passing when I ran them. I wonder what I've done wrong.

with redirect_stderr(f):
warn_in_virtualenv()
output = f.getvalue()
assert 'Courtesy Notice' not in output
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d recommend using capsys to redirect stdout/stderr here. I didn’t test myself, and cannot access Buildkite logs either, but suspect this caused the build failure on Python 2.

@techalchemy
Copy link
Member

Can we just change the name of this to be a more generic ‘be less verbose’ variable? Maybe it should eventually toggle off all of the informational things we write to stderr

@Haplo-Dragon
Copy link
Contributor Author

Thanks for the prompt feedback! I'll switch to capsys - I feel kinda silly for not noticing it earlier. @techalchemy, how do we feel about PIPENV_CONCISE? Or maybe PIPENV_TERSE? I figure PIPENV_SHUT_UP is out of the question?

@uranusjr
Copy link
Member

Could we make this more generic, like, combining it with the --verbose flag in other commands? Something like PIPENV_VERBOSITY as an integer value?

@Haplo-Dragon
Copy link
Contributor Author

PIPENV_VERBOSITY as an integer value sounds good to me! I'm assuming 0 will be the default (most verbose) setting, and we can assess higher values as needed later?
I don't feel qualified to integrate it throughout the rest of the codebase, but I can certainly set it and integrate it with my small changes.

Changed PIPENV_SUPPRESS_NESTED_WARNING to PIPENV_VERBOSITY, an integer
value that defaults to 0 (verbose).
Changed test in test_core.py to use capsys to capture standard
output/error in order to improve compatibility with Python 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants