Skip to content

Commit

Permalink
Merge pull request #975 from atugushev/unpin-commented-out-unsafe-pkgs
Browse files Browse the repository at this point in the history
Unpin commented out unsafe packages
  • Loading branch information
atugushev authored Nov 17, 2019
2 parents 5efb2de + 841bffb commit ef52977
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
19 changes: 10 additions & 9 deletions piptools/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,18 @@ def _iter_lines(
yield MESSAGE_UNSAFE_PACKAGES

for ireq in unsafe_requirements:
req = self._format_requirement(
ireq,
reverse_dependencies,
primary_packages,
marker=markers.get(key_from_ireq(ireq)),
hashes=hashes,
)
ireq_key = key_from_ireq(ireq)
if not self.allow_unsafe:
yield comment("# {}".format(req))
yield comment("# {}".format(ireq_key))
else:
yield req
line = self._format_requirement(
ireq,
reverse_dependencies,
primary_packages,
marker=markers.get(ireq_key),
hashes=hashes,
)
yield line

# Yield even when there's no real content, so that blank files are written
if not yielded:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,7 @@ def test_annotate_option(pip_conf, runner, option, expected):


@pytest.mark.parametrize(
"option, expected",
[("--allow-unsafe", "\nsetuptools=="), (None, "\n# setuptools==")],
"option, expected", [("--allow-unsafe", "\nsetuptools=="), (None, "\n# setuptools")]
)
@pytest.mark.network
def test_allow_unsafe_option(runner, option, expected):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_iter_lines__unsafe_dependencies(writer, from_line, allow_unsafe):
"test==1.2",
"",
MESSAGE_UNSAFE_PACKAGES,
"setuptools==1.10.0" if allow_unsafe else comment("# setuptools==1.10.0"),
"setuptools==1.10.0" if allow_unsafe else comment("# setuptools"),
)
assert tuple(lines) == expected_lines

Expand All @@ -147,7 +147,7 @@ def test_iter_lines__unsafe_with_hashes(writer, from_line):
"test==1.2 \\\n --hash=FAKEHASH",
"",
MESSAGE_UNSAFE_PACKAGES_UNPINNED,
comment("# setuptools==1.10.0"),
comment("# setuptools"),
)
assert tuple(lines) == expected_lines

Expand Down

0 comments on commit ef52977

Please sign in to comment.