Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated elements #968

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pre_commit_hooks/requirements_txt_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/requirements_txt_fixer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
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):
Expand Down