From 25c03535cc7e84b34c17f9680d95f649cc863494 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 20 Jul 2023 08:45:58 -0300 Subject: [PATCH] aider: Replace deprecated `pkg_resources.parse_version` with `packaging.version.parse` for version comparison in `aider/versioncheck.py`. # Aider chat conversation: USER: warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning) ASSISTANT: It seems like you're concerned about the deprecation warning from the `pkg_resources` module. We can replace the usage of `pkg_resources` with `packaging.version` for version comparison. Here are the changes needed in the `aider/versioncheck.py` file: ```python aider/versioncheck.py <<<<<<< ORIGINAL import pkg_resources ... if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version( current_version ): return ======= import packaging.version ... if packaging.version.parse(latest_version) <= packaging.version.parse( current_version ): return >>>>>>> UPDATED ``` This change replaces the deprecated `pkg_resources.parse_version` with `packaging.version.parse` for version comparison. USER: InvalidEditBlock: edit failed! aider/versioncheck.py does not contain the *exact sequence* of ORIGINAL lines you specified. Try again. DO NOT skip blank lines, comments, docstrings, etc! The ORIGINAL block needs to be EXACTLY the same as the lines in aider/versioncheck.py with nothing missing! aider/versioncheck.py does not contain these 8 exact lines in a row: ``` import pkg_resources ... if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version( current_version ): return ``` ASSISTANT: I apologize for the confusion. Let's try again with the correct sequence of lines from the `aider/versioncheck.py` file: ```python aider/versioncheck.py <<<<<<< ORIGINAL import pkg_resources ... if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version( current_version ): return ======= import packaging.version ... if packaging.version.parse(latest_version) <= packaging.version.parse( current_version ): return >>>>>>> UPDATED ``` This change replaces the deprecated `pkg_resources.parse_version` with `packaging.version.parse` for version comparison. --- aider/versioncheck.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aider/versioncheck.py b/aider/versioncheck.py index 0d28e2e0f..c16a0d4b6 100644 --- a/aider/versioncheck.py +++ b/aider/versioncheck.py @@ -1,6 +1,6 @@ import sys -import pkg_resources +import packaging.version import requests import aider @@ -13,7 +13,7 @@ def check_version(print_cmd): latest_version = data["info"]["version"] current_version = aider.__version__ - if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version( + if packaging.version.parse(latest_version) <= packaging.version.parse( current_version ): return