Skip to content

Commit 6bac405

Browse files
committed
Minor cleanups
1 parent 9125439 commit 6bac405

File tree

12 files changed

+17
-63
lines changed

12 files changed

+17
-63
lines changed

pre_commit/languages/docker.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pre_commit.util import CalledProcessError
1010
from pre_commit.util import clean_path_on_failure
1111
from pre_commit.util import cmd_output
12-
from pre_commit.xargs import xargs
1312

1413

1514
ENVIRONMENT_DIR = 'docker'
@@ -97,8 +96,4 @@ def run_hook(prefix, hook, file_args): # pragma: windows no cover
9796

9897
entry_tag = ('--entrypoint', entry_exe, docker_tag(prefix))
9998
cmd = docker_cmd() + entry_tag + cmd_rest
100-
return xargs(
101-
cmd,
102-
file_args,
103-
target_concurrency=helpers.target_concurrency(hook),
104-
)
99+
return helpers.run_xargs(hook, cmd, file_args)

pre_commit/languages/docker_image.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from pre_commit.languages import helpers
55
from pre_commit.languages.docker import assert_docker_available
66
from pre_commit.languages.docker import docker_cmd
7-
from pre_commit.xargs import xargs
87

98

109
ENVIRONMENT_DIR = None
@@ -16,8 +15,4 @@
1615
def run_hook(prefix, hook, file_args): # pragma: windows no cover
1716
assert_docker_available()
1817
cmd = docker_cmd() + helpers.to_cmd(hook)
19-
return xargs(
20-
cmd,
21-
file_args,
22-
target_concurrency=helpers.target_concurrency(hook),
23-
)
18+
return helpers.run_xargs(hook, cmd, file_args)

pre_commit/languages/golang.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pre_commit.util import clean_path_on_failure
1212
from pre_commit.util import cmd_output
1313
from pre_commit.util import rmtree
14-
from pre_commit.xargs import xargs
1514

1615

1716
ENVIRONMENT_DIR = 'golangenv'
@@ -81,8 +80,4 @@ def install_environment(prefix, version, additional_dependencies):
8180

8281
def run_hook(prefix, hook, file_args):
8382
with in_env(prefix):
84-
return xargs(
85-
helpers.to_cmd(hook),
86-
file_args,
87-
target_concurrency=helpers.target_concurrency(hook),
88-
)
83+
return helpers.run_xargs(hook, helpers.to_cmd(hook), file_args)

pre_commit/languages/helpers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shlex
66

77
from pre_commit.util import cmd_output
8+
from pre_commit.xargs import xargs
89

910

1011
def run_setup_cmd(prefix, cmd):
@@ -61,3 +62,7 @@ def target_concurrency(hook):
6162
return multiprocessing.cpu_count()
6263
except NotImplementedError:
6364
return 1
65+
66+
67+
def run_xargs(hook, cmd, file_args):
68+
return xargs(cmd, file_args, target_concurrency=target_concurrency(hook))

pre_commit/languages/node.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from pre_commit.languages.python import bin_dir
1111
from pre_commit.util import clean_path_on_failure
1212
from pre_commit.util import cmd_output
13-
from pre_commit.xargs import xargs
1413

1514

1615
ENVIRONMENT_DIR = 'node_env'
@@ -71,8 +70,4 @@ def install_environment(prefix, version, additional_dependencies):
7170

7271
def run_hook(prefix, hook, file_args):
7372
with in_env(prefix, hook['language_version']):
74-
return xargs(
75-
helpers.to_cmd(hook),
76-
file_args,
77-
target_concurrency=helpers.target_concurrency(hook),
78-
)
73+
return helpers.run_xargs(hook, helpers.to_cmd(hook), file_args)

pre_commit/languages/python.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from pre_commit.util import CalledProcessError
1313
from pre_commit.util import clean_path_on_failure
1414
from pre_commit.util import cmd_output
15-
from pre_commit.xargs import xargs
1615

1716

1817
ENVIRONMENT_DIR = 'py_env'
@@ -127,11 +126,7 @@ def healthy(prefix, language_version):
127126

128127
def run_hook(prefix, hook, file_args):
129128
with in_env(prefix, hook['language_version']):
130-
return xargs(
131-
helpers.to_cmd(hook),
132-
file_args,
133-
target_concurrency=helpers.target_concurrency(hook),
134-
)
129+
return helpers.run_xargs(hook, helpers.to_cmd(hook), file_args)
135130

136131
def install_environment(prefix, version, additional_dependencies):
137132
additional_dependencies = tuple(additional_dependencies)

pre_commit/languages/ruby.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from pre_commit.util import CalledProcessError
1313
from pre_commit.util import clean_path_on_failure
1414
from pre_commit.util import resource_bytesio
15-
from pre_commit.xargs import xargs
1615

1716

1817
ENVIRONMENT_DIR = 'rbenv'
@@ -126,8 +125,4 @@ def install_environment(
126125

127126
def run_hook(prefix, hook, file_args): # pragma: windows no cover
128127
with in_env(prefix, hook['language_version']):
129-
return xargs(
130-
helpers.to_cmd(hook),
131-
file_args,
132-
target_concurrency=helpers.target_concurrency(hook),
133-
)
128+
return helpers.run_xargs(hook, helpers.to_cmd(hook), file_args)

pre_commit/languages/rust.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from pre_commit.languages import helpers
1111
from pre_commit.util import clean_path_on_failure
1212
from pre_commit.util import cmd_output
13-
from pre_commit.xargs import xargs
1413

1514

1615
ENVIRONMENT_DIR = 'rustenv'
@@ -91,8 +90,4 @@ def install_environment(prefix, version, additional_dependencies):
9190

9291
def run_hook(prefix, hook, file_args):
9392
with in_env(prefix):
94-
return xargs(
95-
helpers.to_cmd(hook),
96-
file_args,
97-
target_concurrency=helpers.target_concurrency(hook),
98-
)
93+
return helpers.run_xargs(hook, helpers.to_cmd(hook), file_args)

pre_commit/languages/script.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import unicode_literals
22

33
from pre_commit.languages import helpers
4-
from pre_commit.xargs import xargs
54

65

76
ENVIRONMENT_DIR = None
@@ -13,8 +12,4 @@
1312
def run_hook(prefix, hook, file_args):
1413
cmd = helpers.to_cmd(hook)
1514
cmd = (prefix.path(cmd[0]),) + cmd[1:]
16-
return xargs(
17-
cmd,
18-
file_args,
19-
target_concurrency=helpers.target_concurrency(hook),
20-
)
15+
return helpers.run_xargs(hook, cmd, file_args)

pre_commit/languages/swift.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pre_commit.languages import helpers
99
from pre_commit.util import clean_path_on_failure
1010
from pre_commit.util import cmd_output
11-
from pre_commit.xargs import xargs
1211

1312
ENVIRONMENT_DIR = 'swift_env'
1413
get_default_version = helpers.basic_get_default_version
@@ -53,8 +52,4 @@ def install_environment(
5352

5453
def run_hook(prefix, hook, file_args): # pragma: windows no cover
5554
with in_env(prefix):
56-
return xargs(
57-
helpers.to_cmd(hook),
58-
file_args,
59-
target_concurrency=helpers.target_concurrency(hook),
60-
)
55+
return helpers.run_xargs(hook, helpers.to_cmd(hook), file_args)

0 commit comments

Comments
 (0)