Skip to content

Commit

Permalink
[MNT] differential testing - handle non-package changes in `pyproject…
Browse files Browse the repository at this point in the history
….toml` (#472)

The differential testing utilities would result in exceptions in cases
where `pyproject.toml` was changed with non-package related changes.

This PR modifies the utilities to fix this, bringing them in sync with
sktime.
  • Loading branch information
fkiraly authored Sep 29, 2024
1 parent 8a15961 commit f439012
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions skpro/utils/git_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _get_packages_with_changed_specs():
-------
tuple of str : names of packages with changed or added specs
"""
from packaging.requirements import Requirement
from packaging.requirements import InvalidRequirement, Requirement

changed_lines = get_changed_lines("pyproject.toml")

Expand All @@ -175,8 +175,12 @@ def _get_packages_with_changed_specs():
if ";" in req:
req = req.split(";")[0]

pkg = Requirement(req).name
packages.append(pkg)
try: # deal with lines that are not package requirement strings
pkg = Requirement(req).name
except InvalidRequirement:
continue
else:
packages.append(pkg)

# make unique
packages = tuple(set(packages))
Expand Down

0 comments on commit f439012

Please sign in to comment.