Remove duplicated elements

This commit is contained in:
Vyacheslav Kapitonov 2023-09-27 20:03:55 +03:00 committed by Vyacheslav Kapitonov
parent 516a8a263c
commit 670f16c2f7
2 changed files with 4 additions and 1 deletions

View file

@ -116,7 +116,8 @@ def fix_requirements(f: IO[bytes]) -> int:
for requirement in sorted(requirements):
after.extend(requirement.comments)
assert requirement.value, requirement.value
after.append(requirement.value)
if requirement.value not in after:
after.append(requirement.value)
after.extend(rest)
after_string = b''.join(after)

View file

@ -99,6 +99,8 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
PASS,
b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n',
),
(b'\nfoo\nfoo\n', FAIL, b'\nfoo\n'),
(b'\nbar\nfoo\nbar\n', FAIL, b'\nbar\nfoo\n'),
),
)
def test_integration(input_s, expected_retval, output, tmpdir):