Skip to content

Commit

Permalink
Merge pull request #79 from wronaq/fix-pdm-req-with-slash
Browse files Browse the repository at this point in the history
Fix checking requirements.txt with hashes
  • Loading branch information
FredHappyface authored Apr 5, 2024
2 parents da11701 + 3f75010 commit 979ded3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion licensecheck/get_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def resolveExtraReq(extraReq: str) -> ucstr | None:
raise RuntimeError(msg)

for _line in reqPath.read_text(encoding="utf-8").splitlines():
line = _line.strip()
line = _line.rstrip("\\").strip()
if not line or line[0] in {"#", "-"}:
continue
reqs.add(resolveReq(line))
Expand Down
12 changes: 12 additions & 0 deletions tests/data/test_requirements_hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# This file is autogenerated by poetry with Python 3.11
# by the following command:
#
# poetry export -f requirements.txt --output requirements/tmp.txt
#

packaging==24.0 ; python_version >= "3.8" and python_version < "4.0" \
--hash=sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5 \
--hash=sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9
toskip==0.0.1 ; python_version >= "3.8" and python_version < "3.10" \
--hash=sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5
15 changes: 15 additions & 0 deletions tests/test_get_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,18 @@ def test_doGetReqs_requirements() -> None:
"XARRAY" not in deps
) # xarray is an optional dependency of pandas associated with 'computation' key that is not
# tracked in test_requirements.txt

def test_doGetReqs_requirements_with_hashes() -> None:
using = "requirements"
extras = []
pyproject = {}
requirementsPaths = [Path(f"{THISDIR}/data/test_requirements_hash.txt")]
skipDependencies = [types.ucstr("TOSKIP")]

deps = get_deps.do_get_reqs(using, skipDependencies, extras, pyproject, requirementsPaths)
assert deps == {
"PACKAGING"
}
assert (
"TOSKIP" not in deps
)

0 comments on commit 979ded3

Please sign in to comment.