Created
September 5, 2022 16:47
-
-
Save tony/05c66199c003aaf712a39b5dbc103eba to your computer and use it in GitHub Desktop.
sphinx.ext.doctest issue with is_allowed_version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from packaging.specifiers import InvalidSpecifier, SpecifierSet | |
from packaging.version import Version | |
def is_allowed_version(spec: str, version: str) -> bool: | |
"""Check `spec` satisfies `version` or not. | |
This obeys PEP-440 specifiers: | |
https://peps.python.org/pep-0440/#version-specifiers | |
Some examples: | |
>>> is_allowed_version('3.3', '<=3.5') | |
True | |
>>> is_allowed_version('3.3', '<=3.2') | |
False | |
>>> is_allowed_version('3.3', '>3.2, <4.0') | |
True | |
""" | |
return Version(version) in SpecifierSet(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run `python -m doctest example.py` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment