From 97ef8250422e0147f6cd2c1d880dd76515861e7d Mon Sep 17 00:00:00 2001 From: shouzy <82171453+realshouzy@users.noreply.github.com> Date: Sun, 25 Feb 2024 18:29:23 +0100 Subject: [PATCH] Improve implementation of `freeze_outdated_packages` --- pip_review.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pip_review.py b/pip_review.py index c9db34d3..a471dabc 100755 --- a/pip_review.py +++ b/pip_review.py @@ -280,8 +280,10 @@ def update_packages( if freeze_outdated_packages: with open("requirements.txt", "w", encoding="utf-8") as f: - for pkg in packages: - f.write(f"{pkg.name}=={pkg.version}\n") + outdated_packages: str = "\n".join( + f"{pkg.name}=={pkg.version}" for pkg in packages + ) + f.write(f"{outdated_packages}\n") if not continue_on_fail: upgrade_cmd.extend(pkg.name for pkg in packages)