Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/nbconvert/utils/version.py: 29%
7 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-03 06:10 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-03 06:10 +0000
1"""
2Utilities for version comparison
4It is a bit ridiculous that we need these.
5"""
7# Copyright (c) Jupyter Development Team.
8# Distributed under the terms of the Modified BSD License.
10from packaging.version import Version
13def check_version(v, min_v, max_v=None):
14 """check version string v >= min_v and v < max_v
16 Parameters
17 ----------
18 v : str
19 version of the package
20 min_v : str
21 minimal version supported
22 max_v : str
23 earliest version not supported
24 Note: If dev/prerelease tags result in TypeError for string-number
25 comparison, it is assumed that the check passes and the version dependency
26 is satisfied. Users on dev branches are responsible for keeping their own
27 packages up to date.
28 """
30 try:
31 below_max = Version(v) < Version(max_v) if max_v is not None else True
32 return Version(v) >= Version(min_v) and below_max
33 except TypeError:
34 return True