From 737de39381d9c9931295e9841e9a165da76bd426 Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Sat, 28 Jan 2023 16:24:35 +0100 Subject: [PATCH 1/4] Fix over-writing of verbose output Fix #5530 --- pipenv/core.py | 26 +++++++++----------------- pipenv/utils/resolver.py | 14 ++++++++------ 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index a7c437bd..36f4c6d5 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -259,7 +259,9 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False except Exception: err.print(environments.PIPENV_SPINNER_FAIL_TEXT.format("Failed...")) else: - st.update(environments.PIPENV_SPINNER_OK_TEXT.format("Success!")) + st.console.print( + environments.PIPENV_SPINNER_OK_TEXT.format("Success!") + ) # Warn the user of side-effects. click.echo( "{0}: Your {1} now contains pinned versions, if your {2} did. \n" @@ -2305,7 +2307,7 @@ def do_install( os.environ["PIP_USER"] = "0" if "PYTHONHOME" in os.environ: del os.environ["PYTHONHOME"] - st.update(f"Resolving {pkg_line}...") + st.console.print(f"Resolving {pkg_line}...") try: pkg_requirement = Requirement.from_line(pkg_line) except ValueError as e: @@ -2316,11 +2318,11 @@ def do_install( ) ) sys.exit(1) - st.update("Installing...") + st.console.print("Installing...") try: st.update(f"Installing {pkg_requirement.name}...") if project.s.is_verbose(): - st.update( + st.console.print( f"Installing package: {pkg_requirement.as_line(include_hashes=False)}" ) c = pip_install( @@ -2393,18 +2395,8 @@ def do_install( pipfile_sections = "[dev-packages]" else: pipfile_sections = "[packages]" - st.update( - "{} {} {} {}{}".format( - click.style("Adding", bold=True), - click.style(f"{pkg_requirement.name}", fg="green", bold=True), - click.style("to Pipfile's", bold=True), - click.style( - pipfile_sections, - fg="yellow", - bold=True, - ), - click.style(fix_utf8("..."), bold=True), - ) + st.console.print( + f"[bold]Adding [green]{pkg_requirement.name}[/green][/bold] to Pipfile's [yellow]\\{pipfile_sections}[/yellow] ..." ) # Add the package to the Pipfile. if index_url: @@ -2433,7 +2425,7 @@ def do_install( ) ) # ok has a nice v in front, should do something similir with rich - st.update( + st.console.print( environments.PIPENV_SPINNER_OK_TEXT.format("Installation Succeeded") ) # Update project settings with pre preference. diff --git a/pipenv/utils/resolver.py b/pipenv/utils/resolver.py index 1e3b7472..b48f3209 100644 --- a/pipenv/utils/resolver.py +++ b/pipenv/utils/resolver.py @@ -925,13 +925,13 @@ def resolve(cmd, st, project): continue err += line if is_verbose: - st.update(line.rstrip()) + st.console.print(line.rstrip()) c.wait() returncode = c.poll() out = c.stdout.read() if returncode != 0: - st.update(environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!")) + st.console.print(environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!")) echo(out.strip(), err=True) if not is_verbose: echo(err, err=True) @@ -1031,7 +1031,7 @@ def venv_resolve_deps( # we now download those requirements / make temporary folders to perform # dependency resolution on them, so we are including this step inside the # spinner context manager for the UX improvement - st.update("Building requirements...") + st.console.print("Building requirements...") deps = convert_deps_to_pip(deps, project, include_index=True) constraints = set(deps) with tempfile.NamedTemporaryFile( @@ -1040,14 +1040,16 @@ def venv_resolve_deps( constraints_file.write(str("\n".join(constraints))) cmd.append("--constraints-file") cmd.append(constraints_file.name) - st.update("Resolving dependencies...") + st.console.print("Resolving dependencies...") c = resolve(cmd, st, project=project) if c.returncode == 0: - st.update(environments.PIPENV_SPINNER_OK_TEXT.format("Success!")) + st.console.print(environments.PIPENV_SPINNER_OK_TEXT.format("Success!")) if not project.s.is_verbose() and c.stderr.strip(): click.echo(click.style(f"Warning: {c.stderr.strip()}"), err=True) else: - st.update(environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!")) + st.console.print( + environments.PIPENV_SPINNER_FAIL_TEXT.format("Locking Failed!") + ) click.echo(f"Output: {c.stdout.strip()}", err=True) click.echo(f"Error: {c.stderr.strip()}", err=True) try: From 040b4649e9068dc035d84970d92a1f17536ebdb9 Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Sat, 28 Jan 2023 16:25:47 +0100 Subject: [PATCH 2/4] Fix failing test This is due to slightly modified output format --- tests/integration/test_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_update.py b/tests/integration/test_update.py index e9db40b9..ba927b9a 100644 --- a/tests/integration/test_update.py +++ b/tests/integration/test_update.py @@ -9,4 +9,4 @@ def test_update_outdated_with_outdated_package(pipenv_instance_private_pypi, cmd p.pipenv(f"install {cmd_option} {package_name}==1.11") c = p.pipenv("update --outdated") assert isinstance(c.exception, SystemExit) - assert c.stdout_bytes.decode("utf-8").startswith(f"Package '{package_name}' out-of-date:") + assert f"Package '{package_name}' out-of-date:" in c.stdout_bytes.decode("utf-8") From 8a2c5dfb4a95ccdb4f9e4d1766f37899a5727e53 Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Sat, 28 Jan 2023 16:27:01 +0100 Subject: [PATCH 3/4] Add news snippet for 5530 --- news/5530.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/5530.bugfix.rst diff --git a/news/5530.bugfix.rst b/news/5530.bugfix.rst new file mode 100644 index 00000000..271251a0 --- /dev/null +++ b/news/5530.bugfix.rst @@ -0,0 +1 @@ +Fix overwriting of output in verbose mode From b4c000a03308ec3136cd9f8a7a03aad6c25956a6 Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Sun, 29 Jan 2023 22:05:47 +0100 Subject: [PATCH 4/4] Bump isort version to 5.12.0 This version now works again. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3515fc9f..181f3139 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: exclude: tests/data - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort files: \.py$