summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages
diff options
context:
space:
mode:
Diffstat (limited to 'pre_commit/languages')
-rw-r--r--pre_commit/languages/docker.py19
-rw-r--r--pre_commit/languages/docker_image.py2
-rw-r--r--pre_commit/languages/python.py3
3 files changed, 2 insertions, 22 deletions
diff --git a/pre_commit/languages/docker.py b/pre_commit/languages/docker.py
index 4091492..9c13119 100644
--- a/pre_commit/languages/docker.py
+++ b/pre_commit/languages/docker.py
@@ -7,9 +7,7 @@ import pre_commit.constants as C
from pre_commit.hook import Hook
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
-from pre_commit.util import CalledProcessError
from pre_commit.util import clean_path_on_failure
-from pre_commit.util import cmd_output_b
ENVIRONMENT_DIR = 'docker'
PRE_COMMIT_LABEL = 'PRE_COMMIT'
@@ -26,21 +24,6 @@ def docker_tag(prefix: Prefix) -> str: # pragma: win32 no cover
return f'pre-commit-{md5sum}'
-def docker_is_running() -> bool: # pragma: win32 no cover
- try:
- cmd_output_b('docker', 'ps')
- except CalledProcessError:
- return False
- else:
- return True
-
-
-def assert_docker_available() -> None: # pragma: win32 no cover
- assert docker_is_running(), (
- 'Docker is either not running or not configured in this environment'
- )
-
-
def build_docker_image(
prefix: Prefix,
*,
@@ -63,7 +46,6 @@ def install_environment(
) -> None: # pragma: win32 no cover
helpers.assert_version_default('docker', version)
helpers.assert_no_additional_deps('docker', additional_dependencies)
- assert_docker_available()
directory = prefix.path(
helpers.environment_dir(ENVIRONMENT_DIR, C.DEFAULT),
@@ -101,7 +83,6 @@ def run_hook(
file_args: Sequence[str],
color: bool,
) -> Tuple[int, bytes]: # pragma: win32 no cover
- assert_docker_available()
# Rebuild the docker image in case it has gone missing, as many people do
# automated cleanup of docker images.
build_docker_image(hook.prefix, pull=False)
diff --git a/pre_commit/languages/docker_image.py b/pre_commit/languages/docker_image.py
index 0c51df6..311d127 100644
--- a/pre_commit/languages/docker_image.py
+++ b/pre_commit/languages/docker_image.py
@@ -3,7 +3,6 @@ from typing import Tuple
from pre_commit.hook import Hook
from pre_commit.languages import helpers
-from pre_commit.languages.docker import assert_docker_available
from pre_commit.languages.docker import docker_cmd
ENVIRONMENT_DIR = None
@@ -17,6 +16,5 @@ def run_hook(
file_args: Sequence[str],
color: bool,
) -> Tuple[int, bytes]: # pragma: win32 no cover
- assert_docker_available()
cmd = docker_cmd() + hook.cmd
return helpers.run_xargs(hook, cmd, file_args, color=color)
diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
index 6f7c900..7a68580 100644
--- a/pre_commit/languages/python.py
+++ b/pre_commit/languages/python.py
@@ -191,7 +191,8 @@ def healthy(prefix: Prefix, language_version: str) -> bool:
return (
'version_info' in cfg and
- _version_info(py_exe) == cfg['version_info'] and (
+ # always use uncached lookup here in case we replaced an unhealthy env
+ _version_info.__wrapped__(py_exe) == cfg['version_info'] and (
'base-executable' not in cfg or
_version_info(cfg['base-executable']) == cfg['version_info']
)