Skip to content

Commit 14b40e6

Browse files
authored
Fix downstream failure in traitlets, due to packaging change. (#1688)
1 parent 9a4d6ee commit 14b40e6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

jupyter_server/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from urllib.request import pathname2url as _pathname2url
2929

3030
from jupyter_core.utils import ensure_async as _ensure_async
31-
from packaging.version import Version
31+
from packaging.version import InvalidVersion, Version
3232
from tornado.httpclient import AsyncHTTPClient, HTTPClient, HTTPRequest, HTTPResponse
3333
from tornado.netutil import Resolver
3434

@@ -178,13 +178,15 @@ def to_api_path(os_path: str, root: str = "") -> ApiPath:
178178
def check_version(v: str, check: str) -> bool:
179179
"""check version string v >= check
180180
181-
If dev/prerelease tags result in TypeError for string-number comparison,
181+
If a version cannot be parsed (dev/prerelease tags, or a non-string),
182182
it is assumed that the dependency is satisfied.
183183
Users on dev branches are responsible for keeping their own packages up to date.
184184
"""
185185
try:
186186
return bool(Version(v) >= Version(check))
187-
except TypeError:
187+
except (TypeError, InvalidVersion):
188+
# packaging >= 26.3 raises InvalidVersion where it used to raise
189+
# TypeError for non-string inputs.
188190
return True
189191

190192

0 commit comments

Comments
 (0)