Skip to content

Commit

Permalink
MNT: compatibility with newer packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLLentz committed Apr 18, 2023
1 parent f2500fa commit cd744dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_version(filename):
requirements = [
'click >= 6.7',
'jinja2',
'packaging < 22.0',
'packaging',
'pyparsing >= 2.0.2',
'setuptools',
'sphinx',
Expand Down
12 changes: 6 additions & 6 deletions src/docs_versions_menu/groups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Classification of folders into groups according to :pep:`440`."""
from packaging.version import LegacyVersion
from packaging.version import parse as parse_version
from packaging.version import InvalidVersion, Version


def get_groups(folders, default_branches=None):
Expand Down Expand Up @@ -48,10 +47,11 @@ def get_groups(folders, default_branches=None):
'default-branch': set(),
}
for folder in folders:
version = parse_version(folder)
if folder in default_branches:
groups['default-branch'].add(folder)
if isinstance(version, LegacyVersion):
try:
version = Version(folder)
except InvalidVersion:
if folder in default_branches:
groups['default-branch'].add(folder)
groups['branches'].add(folder)
else:
groups['releases'].add(folder)
Expand Down

0 comments on commit cd744dc

Please sign in to comment.