mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-11 13:44:17 +00:00
fix(requirements-txt-fixer): handle -i and --index-url= forms
This commit is contained in:
parent
918dc64fe7
commit
36a1c0e621
2 changed files with 22 additions and 0 deletions
|
|
@ -34,6 +34,10 @@ class Requirement:
|
||||||
assert m is not None
|
assert m is not None
|
||||||
|
|
||||||
name = m.group()
|
name = m.group()
|
||||||
|
if name == b'-i' or name.startswith(b'--index-url='):
|
||||||
|
return b'--index-url'
|
||||||
|
elif name.startswith(b'--extra-index-url='):
|
||||||
|
return b'--extra-index-url'
|
||||||
m = self.UNTIL_COMPARISON.search(name)
|
m = self.UNTIL_COMPARISON.search(name)
|
||||||
if not m:
|
if not m:
|
||||||
return name
|
return name
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,24 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
|
||||||
b'--extra-index-url https://example.com/simple\n'
|
b'--extra-index-url https://example.com/simple\n'
|
||||||
b'requests\n',
|
b'requests\n',
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
b'--extra-index-url https://example.com/simple\n'
|
||||||
|
b'-i https://pypi.org/simple\n'
|
||||||
|
b'requests\n',
|
||||||
|
FAIL,
|
||||||
|
b'-i https://pypi.org/simple\n'
|
||||||
|
b'--extra-index-url https://example.com/simple\n'
|
||||||
|
b'requests\n',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
b'--extra-index-url=https://example.com/simple\n'
|
||||||
|
b'--index-url=https://pypi.org/simple\n'
|
||||||
|
b'requests\n',
|
||||||
|
FAIL,
|
||||||
|
b'--index-url=https://pypi.org/simple\n'
|
||||||
|
b'--extra-index-url=https://example.com/simple\n'
|
||||||
|
b'requests\n',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_integration(input_s, expected_retval, output, tmpdir):
|
def test_integration(input_s, expected_retval, output, tmpdir):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue