Skip to content

Commit

Permalink
Consider inline comments when parsing constraints files
Browse files Browse the repository at this point in the history
  • Loading branch information
realshouzy committed Jun 11, 2024
1 parent 2e6bef4 commit 1652fe6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pip_manage/pip_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _set_constraints_of_outdated_pkgs(
for line in file.read_text(encoding="utf-8").splitlines():
if line.lstrip().startswith("#"):
continue
pkg_name, _, constraint_version = line.partition("==")
pkg_name, _, constraint_version = line.partition("#")[0].partition("==")
for pkg in outdated:
if pkg.name == pkg_name.strip():
pkg.constraints.add(constraint_version.strip())
Expand Down
1 change: 1 addition & 0 deletions tests/pip_review_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def test_get_constraints_files_with_named_args_and_dont_ignore_constraints_env_v
("constraints", "expected"),
[
("test2==1.9.9.9", {"1.9.9.9"}),
("test2==1.9.9.9 # test", {"1.9.9.9"}),
("test2==1.9.9.9\n#test", {"1.9.9.9"}),
(" test2 == 1.9.9.9 ", {"1.9.9.9"}),
],
Expand Down

0 comments on commit 1652fe6

Please sign in to comment.