mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
Automatically fix package=version in requirements.txt
This commit is contained in:
parent
86bfe8c475
commit
f8b8997c07
2 changed files with 4 additions and 0 deletions
|
|
@ -61,6 +61,9 @@ def fix_requirements(f):
|
|||
elif line.startswith(b'#') or line.strip() == b'':
|
||||
requirement.comments.append(line)
|
||||
else:
|
||||
# Automatically fix 'package=version' to 'package==version'
|
||||
if b'=' in line and b'==' not in line and b'egg=' not in line:
|
||||
line = line.replace(b'=', b'==')
|
||||
requirement.value = line
|
||||
|
||||
# if a file ends in a comment, preserve it at the end
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
|
|||
),
|
||||
(b'bar\npkg-resources==0.0.0\nfoo\n', FAIL, b'bar\nfoo\n'),
|
||||
(b'foo\npkg-resources==0.0.0\nbar\n', FAIL, b'bar\nfoo\n'),
|
||||
(b'foo=1\n', FAIL, b'foo==1\n'),
|
||||
),
|
||||
)
|
||||
def test_integration(input_s, expected_retval, output, tmpdir):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue