fix(hygiene): detect unpinned dependencies with environment markers - #107
fix(hygiene): detect unpinned dependencies with environment markers#107rioyu123 wants to merge 3 commits into
Conversation
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
rng1995
left a comment
There was a problem hiding this comment.
One blocking marker-parsing case remains.
| # Marker comparisons do not constrain the package version. Leave | ||
| # direct references intact because their URLs may contain ";"; | ||
| # markers on direct references therefore keep existing behavior. | ||
| constraint_part = line if "@" in line else line.partition(";")[0] |
There was a problem hiding this comment.
Checking for @ anywhere in the full line misclassifies a marker value as a direct reference. For example, requests; implementation_name == "cpython@corp" produces no unpinned warning. Detect a direct-reference @ only in the requirement portion before ; (or parse the PEP 508 requirement), and add this regression.
There was a problem hiding this comment.
Fixed in 5afe819. The direct-reference check now only considers @ before the environment marker, so requests; implementation_name == "cpython@corp" is still reported as unpinned. I added that regression, merged the latest upstream main without rewriting history, and resolved the CHANGELOG conflict. The focused hygiene tests pass (37 passed, 1 skipped), Ruff is clean, and the package build succeeds. The updated GitHub CI is now running.
There was a problem hiding this comment.
Thanks for handling the at-sign inside marker values. The direct-reference branch does not actually treat the at-sign as a constraint; it only scans the full URL for comparison characters. As a result, an ordinary requests direct reference to https://example.invalid/requests.whl is still reported as unpinned. The new direct-reference tests pass only because their URL or marker contains a comparison character. Please make the at-sign in requirement_part sufficient while keeping marker text excluded, and add a plain-URL regression.
There was a problem hiding this comment.
Thanks — fixed in 29877b2. An @ in the pre-marker requirement now directly identifies a direct reference, while non-direct requirements only check comparison operators before the marker. I also added a plain-URL regression. The hygiene tests pass (38 passed, 1 skipped), and the full Ruff lint and build pass.
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
Signed-off-by: Rio Yu <52408936+rioyu123@users.noreply.github.com>
Summary
requests; python_version < "3.13".==.Before this change, the validator searched the entire physical line for
[=<>!], so marker operators could hide an unversioned package:requests; python_version < "3.13"requests; sys_platform == "win32"requests>=2; python_version < "3.13"requests @ https://example.invalid/a;v=1/requests.whlKnown adjacent behavior remains out of scope: direct references keep their existing constraint policy, inline comments are not parsed, and backslash continuations are still evaluated as physical lines.
Verification
make lintmake test? ran the complete affected validator domain insteadmake buildResults:
uv run pytest -q tests/validators/test_hygiene.py? 26 passed, 1 skippeduv run pytest -q tests/validatorson Linux ? 847 passedmake PYTHON=.venv/bin/python lint? passedmake PYTHON=.venv/bin/python build? passedRelease Impact
CHANGELOG.md