Various cleanup. · precommit/pre-commit@01b557c · GitHub
Skip to content

Commit 01b557c

Browse files
committed
Various cleanup.
1 parent bf912cf commit 01b557c

12 files changed

Lines changed: 85 additions & 37 deletions

.pre-commit-config.yaml

Lines changed: 0 additions & 10 deletions

pre_commit/commands.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030
def install(runner):
3131
"""Install the pre-commit hooks."""
32-
pre_commit_file = pkg_resources.resource_filename('pre_commit', 'resources/pre-commit.sh')
32+
pre_commit_file = pkg_resources.resource_filename(
33+
'pre_commit', 'resources/pre-commit.sh',
34+
)
3335
with open(runner.pre_commit_path, 'w') as pre_commit_file_obj:
3436
pre_commit_file_obj.write(open(pre_commit_file).read())
3537

pre_commit/git.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def is_in_merge_conflict():
2929
def parse_merge_msg_for_conflicts(merge_msg):
3030
# Conflicted files start with tabs
3131
return [
32-
line.strip() for line in merge_msg.splitlines() if line.startswith('\t')
32+
line.strip()
33+
for line in merge_msg.splitlines()
34+
if line.startswith('\t')
3335
]
3436

3537

pre_commit/languages/all.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
# # Use None for no environment
1010
# ENVIRONMENT_DIR = 'foo_env'
1111
#
12-
# def install_environment(repo_cmd_runner):
12+
# def install_environment(repo_cmd_runner, version='default'):
1313
# """Installs a repository in the given repository. Note that the current
1414
# working directory will already be inside the repository.
1515
#
1616
# Args:
1717
# repo_cmd_runner - `PrefixedCommandRunner` bound to the repository.
18+
# version - A version specified in the hook configuration or
19+
# 'default'.
1820
# """
1921
#
2022
# def run_hook(repo_cmd_runner, hook, file_args):
21-
# """Runs a hook and returns the returncode and output of running that hook.
23+
# """Runs a hook and returns the returncode and output of running that
24+
# hook.
2225
#
2326
# Args:
2427
# repo_cmd_runner - `PrefixedCommandRunner` bound to the repository.

pre_commit/output.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def get_hook_message(
2626
>>> print_hook_message('start', end_len=6)
2727
start...............................................................
2828
29-
# Print `start` followed by dots with the end message colored if coloring is
30-
# specified and a newline afterwards
29+
# Print `start` followed by dots with the end message colored if coloring
30+
# is specified and a newline afterwards
3131
>>> print_hook_message(
3232
'start',
3333
end_msg='end',

pre_commit/prefixed_command_runner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ class PrefixedCommandRunner(object):
4242
4343
will run ['/tmp/foo/foo.sh', 'bar', 'baz']
4444
"""
45-
def __init__(self, prefix_dir, popen=subprocess.Popen, makedirs=os.makedirs):
45+
def __init__(
46+
self,
47+
prefix_dir,
48+
popen=subprocess.Popen,
49+
makedirs=os.makedirs
50+
):
4651
self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep
4752
self.__popen = popen
4853
self.__makedirs = makedirs

pre_commit/run.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ def run(argv):
3535
'--no-stash', default=False, action='store_true',
3636
help='Use this option to prevent auto stashing of unstaged files.',
3737
)
38-
run_parser.add_argument('--verbose', '-v', action='store_true', default=False)
38+
run_parser.add_argument(
39+
'--verbose', '-v', action='store_true', default=False,
40+
)
3941

40-
help = subparsers.add_parser('help', help='Show help for a specific command.')
42+
help = subparsers.add_parser(
43+
'help', help='Show help for a specific command.'
44+
)
4145
help.add_argument('help_cmd', nargs='?', help='Command to show help for.')
4246

4347
# Argparse doesn't really provide a way to use a `default` subparser

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
setup(
66
name='pre_commit',
7-
description='A framework for managing and maintaining multi-language pre-commit hooks.',
7+
description=(
8+
'A framework for managing and maintaining multi-language pre-commit '
9+
'hooks.'
10+
),
811
url='https://github.com/pre-commit/pre-commit',
912
version='0.0.0',
1013

tests/clientlib/validate_base_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def test_raises_for_invalid_yaml_file(noop_validator):
4444

4545
def test_raises_for_failing_schema(array_validator):
4646
with pytest.raises(ValueError):
47-
array_validator(get_resource_path('valid_yaml_but_invalid_manifest.yaml'))
47+
array_validator(
48+
get_resource_path('valid_yaml_but_invalid_manifest.yaml')
49+
)
4850

4951

5052
def test_passes_array_schema(array_validator):

tests/commands_test.py

Lines changed: 47 additions & 11 deletions

0 commit comments

Comments
 (0)