mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-18 01:20:01 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
fb0f6fac81
commit
df46f71980
3 changed files with 142 additions and 140 deletions
|
|
@ -151,7 +151,7 @@ def fix_requirements(f: IO[bytes], fail_without_version: bool) -> int:
|
|||
if before_string == after_string:
|
||||
return PASS
|
||||
else:
|
||||
print("Sorting requirements")
|
||||
print('Sorting requirements')
|
||||
f.seek(0)
|
||||
f.write(after_string)
|
||||
f.truncate()
|
||||
|
|
@ -161,8 +161,10 @@ def fix_requirements(f: IO[bytes], fail_without_version: bool) -> int:
|
|||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
|
||||
parser.add_argument("--fail-without-version", action="store_true",
|
||||
help="Fail if a requirement is missing a version")
|
||||
parser.add_argument(
|
||||
'--fail-without-version', action='store_true',
|
||||
help='Fail if a requirement is missing a version',
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
retv = PASS
|
||||
|
|
|
|||
|
|
@ -119,10 +119,10 @@ 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'bar\nfoo\n', ["--fail-without-version"], FAIL, b'bar\nfoo\n'),
|
||||
(b'bar==1.0\nfoo==1.1a\n', ["--fail-without-version"], PASS, b'bar==1.0\nfoo==1.1a\n'),
|
||||
(b'#test\nbar==1.0\nfoo==1.1a\n', ["--fail-without-version"], PASS, b'#test\nbar==1.0\nfoo==1.1a\n'),
|
||||
(b'bar==1.0\n#test\nfoo==1.1a\n', ["--fail-without-version"], PASS, b'bar==1.0\n#test\nfoo==1.1a\n'),
|
||||
(b'bar\nfoo\n', ['--fail-without-version'], FAIL, b'bar\nfoo\n'),
|
||||
(b'bar==1.0\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'bar==1.0\nfoo==1.1a\n'),
|
||||
(b'#test\nbar==1.0\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'#test\nbar==1.0\nfoo==1.1a\n'),
|
||||
(b'bar==1.0\n#test\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'bar==1.0\n#test\nfoo==1.1a\n'),
|
||||
),
|
||||
)
|
||||
def test_integration(input_s, argv, expected_retval, output, tmpdir):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue