Skip to content

Commit c8620f3

Browse files
authored
Merge pull request pre-commit#1170 from pre-commit/fail_fix
Fix fail type signature
2 parents 2048fed + 3876681 commit c8620f3

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

pre_commit/languages/fail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
def run_hook(hook, file_args):
1313
out = hook.entry.encode('UTF-8') + b'\n\n'
1414
out += b'\n'.join(f.encode('UTF-8') for f in file_args) + b'\n'
15-
return 1, out, b''
15+
return 1, out

tests/repository_test.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def _test_hook_repo(
7373
):
7474
path = make_repo(tempdir_factory, repo_path)
7575
config = make_config_from_repo(path, **(config_kwargs or {}))
76-
ret = _get_hook(config, store, hook_id).run(args)
77-
assert ret[0] == expected_return_code
78-
assert _norm_out(ret[1]) == expected
76+
ret, out = _get_hook(config, store, hook_id).run(args)
77+
assert ret == expected_return_code
78+
assert _norm_out(out) == expected
7979

8080

8181
def test_python_hook(tempdir_factory, store):
@@ -137,9 +137,9 @@ def test_switch_language_versions_doesnt_clobber(tempdir_factory, store):
137137
def run_on_version(version, expected_output):
138138
config = make_config_from_repo(path)
139139
config['hooks'][0]['language_version'] = version
140-
ret = _get_hook(config, store, 'python3-hook').run([])
141-
assert ret[0] == 0
142-
assert _norm_out(ret[1]) == expected_output
140+
ret, out = _get_hook(config, store, 'python3-hook').run([])
141+
assert ret == 0
142+
assert _norm_out(out) == expected_output
143143

144144
run_on_version('python2', b'2\n[]\nHello World\n')
145145
run_on_version('python3', b'3\n[]\nHello World\n')
@@ -543,9 +543,9 @@ def test_local_golang_additional_dependencies(store):
543543
'additional_dependencies': ['github.com/golang/example/hello'],
544544
}],
545545
}
546-
ret = _get_hook(config, store, 'hello').run(())
547-
assert ret[0] == 0
548-
assert _norm_out(ret[1]) == b'Hello, Go examples!\n'
546+
ret, out = _get_hook(config, store, 'hello').run(())
547+
assert ret == 0
548+
assert _norm_out(out) == b'Hello, Go examples!\n'
549549

550550

551551
def test_local_rust_additional_dependencies(store):
@@ -559,9 +559,9 @@ def test_local_rust_additional_dependencies(store):
559559
'additional_dependencies': ['cli:hello-cli:0.2.2'],
560560
}],
561561
}
562-
ret = _get_hook(config, store, 'hello').run(())
563-
assert ret[0] == 0
564-
assert _norm_out(ret[1]) == b'Hello World!\n'
562+
ret, out = _get_hook(config, store, 'hello').run(())
563+
assert ret == 0
564+
assert _norm_out(out) == b'Hello World!\n'
565565

566566

567567
def test_fail_hooks(store):
@@ -576,9 +576,9 @@ def test_fail_hooks(store):
576576
}],
577577
}
578578
hook = _get_hook(config, store, 'fail')
579-
ret = hook.run(('changelog/1234.bugfix', 'changelog/wat'))
580-
assert ret[0] == 1
581-
assert ret[1] == (
579+
ret, out = hook.run(('changelog/1234.bugfix', 'changelog/wat'))
580+
assert ret == 1
581+
assert out == (
582582
b'make sure to name changelogs as .rst!\n'
583583
b'\n'
584584
b'changelog/1234.bugfix\n'
@@ -645,8 +645,8 @@ class MyKeyboardInterrupt(KeyboardInterrupt):
645645
# However, it should be perfectly runnable (reinstall after botched
646646
# install)
647647
install_hook_envs(hooks, store)
648-
retv, stdout = hook.run(())
649-
assert retv == 0
648+
ret, out = hook.run(())
649+
assert ret == 0
650650

651651

652652
def test_invalidated_virtualenv(tempdir_factory, store):
@@ -667,8 +667,8 @@ def test_invalidated_virtualenv(tempdir_factory, store):
667667
cmd_output_b('rm', '-rf', *paths)
668668

669669
# pre-commit should rebuild the virtualenv and it should be runnable
670-
retv, stdout = _get_hook(config, store, 'foo').run(())
671-
assert retv == 0
670+
ret, out = _get_hook(config, store, 'foo').run(())
671+
assert ret == 0
672672

673673

674674
def test_really_long_file_paths(tempdir_factory, store):
@@ -707,14 +707,14 @@ def test_tags_on_repositories(in_tmpdir, tempdir_factory, store):
707707
git2 = _create_repo_with_tags(tempdir_factory, 'script_hooks_repo', tag)
708708

709709
config1 = make_config_from_repo(git1, rev=tag)
710-
ret1 = _get_hook(config1, store, 'prints_cwd').run(('-L',))
711-
assert ret1[0] == 0
712-
assert ret1[1].strip() == _norm_pwd(in_tmpdir)
710+
ret1, out1 = _get_hook(config1, store, 'prints_cwd').run(('-L',))
711+
assert ret1 == 0
712+
assert out1.strip() == _norm_pwd(in_tmpdir)
713713

714714
config2 = make_config_from_repo(git2, rev=tag)
715-
ret2 = _get_hook(config2, store, 'bash_hook').run(('bar',))
716-
assert ret2[0] == 0
717-
assert ret2[1] == b'bar\nHello World\n'
715+
ret2, out2 = _get_hook(config2, store, 'bash_hook').run(('bar',))
716+
assert ret2 == 0
717+
assert out2 == b'bar\nHello World\n'
718718

719719

720720
@pytest.fixture
@@ -736,9 +736,9 @@ def test_local_python_repo(store, local_python_config):
736736
hook = _get_hook(local_python_config, store, 'foo')
737737
# language_version should have been adjusted to the interpreter version
738738
assert hook.language_version != C.DEFAULT
739-
ret = hook.run(('filename',))
740-
assert ret[0] == 0
741-
assert _norm_out(ret[1]) == b"['filename']\nHello World\n"
739+
ret, out = hook.run(('filename',))
740+
assert ret == 0
741+
assert _norm_out(out) == b"['filename']\nHello World\n"
742742

743743

744744
def test_default_language_version(store, local_python_config):

0 commit comments

Comments
 (0)