Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions utils/VersionSuggester.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from datetime import datetime
from utils.SGTUtils import SGTFormatter
from utils.VulnChecker import fetch_osv
from utils.GenerateReport_Archive import suggest_upgrade_version
# from utils.GenerateReport_Archive import suggest_upgrade_version
# Custom formatter (assumes SGTFormatter is defined elsewhere or should be implemented here)
try:
from zoneinfo import ZoneInfo # Python 3.9+
Expand Down Expand Up @@ -120,7 +120,7 @@ def main():
"""
Parses command-line arguments and suggests upgrade versions for a specified Python package.

Runs as a script entry point to fetch all available versions of a package from PyPI, suggest a basic upgrade, and optionally suggest a safe minor upgrade that is not affected by known vulnerabilities.
Fetches all available versions of the given package from PyPI and, if requested, suggests a minor upgrade that is not affected by known vulnerabilities. Intended to be used as the script's entry point.
"""
parser = argparse.ArgumentParser(description="Suggest upgrade versions")
parser.add_argument("package", help="Package name on PyPI")
Expand All @@ -133,8 +133,8 @@ def main():
pkg_name = args.package # used in suggest_safe_minor_upgrade

versions = get_all_versions(pkg_name)
basic = suggest_upgrade_version(versions, args.current)
print(f"Suggested upgrade: {basic}")
# basic = suggest_upgrade_version(versions, args.current)
# print(f"Suggested upgrade: {basic}")
Comment on lines +136 to +137
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 24, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Commenting-out the call silently drops a feature and leaves an unused function.

The helper suggest_upgrade_version is still defined in this file (lines 45-75) but is now unreachable code. Decide one of two paths and make it explicit:

  1. Keep basic-upgrade suggestion → call the in-file helper instead of the removed external one.
  2. Drop the feature altogether → delete the function and update CLI help text accordingly.

Path ① (minimal diff):

-    # basic = suggest_upgrade_version(versions, args.current)
-    # print(f"Suggested upgrade: {basic}")
+    basic = suggest_upgrade_version(versions, args.current)
+    print(f"Suggested upgrade: {basic}")

Path ② (clean removal): delete lines 45-75 plus the two commented lines above and adjust the docstring/argparse description.

Leaving the code commented causes:
• dead code → lower maintainability
• missing output without warning → confusing UX
Pick one direction and implement it decisively.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# basic = suggest_upgrade_version(versions, args.current)
# print(f"Suggested upgrade: {basic}")
basic = suggest_upgrade_version(versions, args.current)
print(f"Suggested upgrade: {basic}")
🤖 Prompt for AI Agents
In utils/VersionSuggester.py around lines 45 to 75 and 136 to 137, the function
suggest_upgrade_version is defined but not used because the call is commented
out, causing dead code and missing output. Choose to either keep the feature by
uncommenting the call at line 136 and using the in-file helper function, or
remove the feature entirely by deleting the function definition (lines 45-75),
the commented call lines (136-137), and updating the CLI help text and docstring
to reflect the removal. Implement one of these options clearly to avoid
confusion and improve maintainability.

Copy link
Owner Author

Choose a reason for hiding this comment

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

The intension is to disable the suggest_upgrade_version which is an outdated function. We use suggest_safe_minor_upgrade function instead

Copy link
Contributor

Choose a reason for hiding this comment

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

@TongWu Thanks for the clarification! Since you've intentionally disabled the outdated suggest_upgrade_version in favor of suggest_safe_minor_upgrade, I recommend completing the cleanup by removing the dead code.

The local suggest_upgrade_version function (lines 45-75) is now unused and should be deleted to improve code maintainability. You can also remove the commented lines and update the docstring to reflect that only safe minor upgrades are suggested.

This will make your intention clear and keep the codebase clean.


✏️ Learnings added
Learnt from: TongWu
PR: TongWu/PythonPackageManager#14
File: utils/VersionSuggester.py:136-137
Timestamp: 2025-06-24T03:17:27.141Z
Learning: In utils/VersionSuggester.py, the suggest_upgrade_version function has been intentionally disabled as it's outdated. The preferred approach is to use suggest_safe_minor_upgrade function instead for version suggestions.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


if args.safe_minor:
safe = asyncio.run(
Expand Down