|
4 | 4 |
|
5 | 5 | import json |
6 | 6 | import sys |
7 | | -from distutils.version import ( # pylint: disable=deprecated-module |
8 | | - LooseVersion, |
9 | | - StrictVersion, |
10 | | -) |
11 | 7 | from sys import version_info |
12 | 8 | from typing import Optional |
13 | 9 |
|
14 | 10 | import requests |
| 11 | +from packaging import version |
15 | 12 |
|
16 | 13 |
|
17 | 14 | def do_request( |
@@ -160,26 +157,24 @@ def _attempt_warn_old_version(ctx, result): |
160 | 157 |
|
161 | 158 | try: |
162 | 159 | # Parse the spec versions from the API and local CLI. |
163 | | - StrictVersion(spec_version) |
164 | | - StrictVersion(ctx.spec_version) |
| 160 | + spec_version_parsed = version.parse(spec_version) |
| 161 | + current_version_parsed = version.parse(ctx.spec_version) |
165 | 162 |
|
166 | 163 | # Get only the Major/Minor version of the API Spec and CLI Spec, |
167 | 164 | # ignore patch version differences |
168 | 165 | spec_major_minor_version = ( |
169 | | - spec_version.split(".")[0] + "." + spec_version.split(".")[1] |
| 166 | + f"{spec_version_parsed.major}.{spec_version_parsed.minor}" |
170 | 167 | ) |
171 | 168 | current_major_minor_version = ( |
172 | | - ctx.spec_version.split(".")[0] |
173 | | - + "." |
174 | | - + ctx.spec_version.split(".")[1] |
| 169 | + f"{current_version_parsed.major}.{current_version_parsed.minor}" |
175 | 170 | ) |
176 | 171 | except ValueError: |
177 | 172 | # If versions are non-standard like, "DEVELOPMENT" use them and don't complain. |
178 | 173 | spec_major_minor_version = spec_version |
179 | 174 | current_major_minor_version = ctx.spec_version |
180 | 175 |
|
181 | 176 | try: |
182 | | - if LooseVersion(spec_major_minor_version) > LooseVersion( |
| 177 | + if version.parse(spec_major_minor_version) > version.parse( |
183 | 178 | current_major_minor_version |
184 | 179 | ): |
185 | 180 | api_version_higher = True |
@@ -209,7 +204,7 @@ def _attempt_warn_old_version(ctx, result): |
209 | 204 | pypi_version = pypi_response.json()["info"]["version"] |
210 | 205 |
|
211 | 206 | # no need to be fancy; these should always be valid versions |
212 | | - if LooseVersion(pypi_version) > LooseVersion(ctx.version): |
| 207 | + if version.parse(pypi_version) > version.parse(ctx.version): |
213 | 208 | new_version_exists = True |
214 | 209 | except: |
215 | 210 | # I know, but if anything happens here the end user should still |
|
0 commit comments