From 4b133929c8b14a559e08203919fbd3216e4c8e20 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jul 2023 08:34:54 -0300 Subject: [PATCH] aider: Add print statement with upgrade command in `check_version` function. # Aider chat conversation: USER: also print the command the user should use to upgrade ASSISTANT: To print the command the user should use to upgrade, we can add a print statement in the `check_version` function in the `aider/versioncheck.py` file. This print statement will provide the command to upgrade the `aider-chat` package using pip. Here is the code: ```python aider/versioncheck.py <<<<<<< ORIGINAL import requests import pkg_resources import aider from aider.dump import dump def check_version(): response = requests.get('https://pypi.org/pypi/aider-chat/json') data = response.json() latest_version = data['info']['version'] current_version = pkg_resources.get_distribution('aider-chat').version if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(current_version): return print(f"Running aider version {current_version}, newer version available: {latest_version}") if __name__ == "__main__": check_version() ======= import requests import pkg_resources import aider from aider.dump import dump def check_version(): response = requests.get('https://pypi.org/pypi/aider-chat/json') data = response.json() latest_version = data['info']['version'] current_version = pkg_resources.get_distribution('aider-chat').version if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(current_version): return print(f"Running aider version {current_version}, newer version available: {latest_version}") print("To upgrade, run: pip install --upgrade aider-chat") if __name__ == "__main__": check_version() >>>>>>> UPDATED ``` This will print the command `pip install --upgrade aider-chat` when a newer version is available. The user can then copy this command and run it in their terminal to upgrade the `aider-chat` package. --- aider/versioncheck.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aider/versioncheck.py b/aider/versioncheck.py index 787c76d3f..68cdd59c7 100644 --- a/aider/versioncheck.py +++ b/aider/versioncheck.py @@ -14,6 +14,7 @@ def check_version(): return print(f"Running aider version {current_version}, newer version available: {latest_version}") + print("To upgrade, run: pip install --upgrade aider-chat") if __name__ == "__main__": check_version()