Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 5.0.0 (unreleased)

- Fix: `process_line()` now correctly comments out packages in `override_keys` and `ignore_keys` for both requirements and constraints files. Previously, these settings only applied to constraints files (variety="c"). Now they work for requirements files (variety="r") as well, with the message "-> mxdev disabled (version override)" for override_keys in requirements.
[jensens]
- **Breaking**: support for Python 3.8 and 3.9. Minimum required version is now Python 3.10.
[jensens]
- **Breaking**: Modernize type hints to use Python 3.10+ syntax (PEP 604: `X | Y` instead of `Union[X, Y]`)
Expand Down
9 changes: 6 additions & 3 deletions src/mxdev/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ def process_line(
parsed_name_lower = parsed.name.lower()
if parsed_name_lower in [k.lower() for k in package_keys]:
line = f"# {line.strip()} -> mxdev disabled (source)\n"
if variety == "c" and parsed_name_lower in [k.lower() for k in override_keys]:
line = f"# {line.strip()} -> mxdev disabled (override)\n"
if variety == "c" and parsed_name_lower in [k.lower() for k in ignore_keys]:
if parsed_name_lower in [k.lower() for k in override_keys]:
if variety == "c":
line = f"# {line.strip()} -> mxdev disabled (override)\n"
else:
line = f"# {line.strip()} -> mxdev disabled (version override)\n"
if parsed_name_lower in [k.lower() for k in ignore_keys]:
line = f"# {line.strip()} -> mxdev disabled (ignore)\n"
if variety == "c":
return [], [line]
Expand Down
30 changes: 30 additions & 0 deletions tests/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@ def test_process_line_constraint_in_ignore_keys():
assert "# ignored.package==1.0.0 -> mxdev disabled (ignore)" in constraints[0]


def test_process_line_package_in_override_keys():
"""Test process_line comments out packages in override_keys."""
from mxdev.processing import process_line

requirements, constraints = process_line(
"my.package==1.0.0",
package_keys=[],
override_keys=["my.package"],
ignore_keys=[],
variety="r",
)
assert requirements == ["# my.package==1.0.0 -> mxdev disabled (version override)\n"]
assert constraints == []


def test_process_line_package_in_ignore_keys():
"""Test process_line comments out packages in ignore_keys."""
from mxdev.processing import process_line

requirements, constraints = process_line(
"my.package==1.0.0",
package_keys=[],
override_keys=[],
ignore_keys=["my.package"],
variety="r",
)
assert requirements == ["# my.package==1.0.0 -> mxdev disabled (ignore)\n"]
assert constraints == []


def test_process_line_constraint():
"""Test process_line with constraint variety."""
from mxdev.processing import process_line
Expand Down