Skip to content

Commit 0a8ba31

Browse files
authored
Merge pull request #1349 from pre-commit/covdefaults
Use covdefaults to handle coveragerc
2 parents 4a3b10f + 67c1beb commit 0a8ba31

19 files changed

+42
-81
lines changed

.coveragerc

Lines changed: 0 additions & 37 deletions
This file was deleted.

azure-pipelines.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ jobs:
1818
parameters:
1919
toxenvs: [py37]
2020
os: windows
21-
additional_variables:
22-
COVERAGE_IGNORE_WINDOWS: '# pragma: windows no cover'
23-
TOX_TESTENV_PASSENV: COVERAGE_IGNORE_WINDOWS
2421
pre_test:
2522
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
2623
displayName: Add conda to PATH

pre_commit/color.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def bool_errcheck(result, func, args):
5050
terminal_supports_color = False
5151
else:
5252
terminal_supports_color = True
53-
else: # pragma: windows no cover
53+
else: # pragma: win32 no cover
5454
terminal_supports_color = True
5555

5656
RED = '\033[41m'

pre_commit/commands/install_uninstall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _hook_paths(
4646

4747

4848
def is_our_script(filename: str) -> bool:
49-
if not os.path.exists(filename): # pragma: windows no cover (symlink)
49+
if not os.path.exists(filename): # pragma: win32 no cover (symlink)
5050
return False
5151
with open(filename) as f:
5252
contents = f.read()

pre_commit/file_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _locked(
4747
# before closing a file or exiting the program."
4848
# TODO: https://github.com/python/typeshed/pull/3607
4949
msvcrt.locking(fileno, msvcrt.LK_UNLCK, _region) # type: ignore
50-
else: # pragma: windows no cover
50+
else: # pragma: win32 no cover
5151
import fcntl
5252

5353
@contextlib.contextmanager

pre_commit/languages/docker.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
healthy = helpers.basic_healthy
1818

1919

20-
def md5(s: str) -> str: # pragma: windows no cover
20+
def md5(s: str) -> str: # pragma: win32 no cover
2121
return hashlib.md5(s.encode()).hexdigest()
2222

2323

24-
def docker_tag(prefix: Prefix) -> str: # pragma: windows no cover
24+
def docker_tag(prefix: Prefix) -> str: # pragma: win32 no cover
2525
md5sum = md5(os.path.basename(prefix.prefix_dir)).lower()
2626
return f'pre-commit-{md5sum}'
2727

2828

29-
def docker_is_running() -> bool: # pragma: windows no cover
29+
def docker_is_running() -> bool: # pragma: win32 no cover
3030
try:
3131
cmd_output_b('docker', 'ps')
3232
except CalledProcessError:
@@ -35,7 +35,7 @@ def docker_is_running() -> bool: # pragma: windows no cover
3535
return True
3636

3737

38-
def assert_docker_available() -> None: # pragma: windows no cover
38+
def assert_docker_available() -> None: # pragma: win32 no cover
3939
assert docker_is_running(), (
4040
'Docker is either not running or not configured in this environment'
4141
)
@@ -45,7 +45,7 @@ def build_docker_image(
4545
prefix: Prefix,
4646
*,
4747
pull: bool,
48-
) -> None: # pragma: windows no cover
48+
) -> None: # pragma: win32 no cover
4949
cmd: Tuple[str, ...] = (
5050
'docker', 'build',
5151
'--tag', docker_tag(prefix),
@@ -60,7 +60,7 @@ def build_docker_image(
6060

6161
def install_environment(
6262
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
63-
) -> None: # pragma: windows no cover
63+
) -> None: # pragma: win32 no cover
6464
helpers.assert_version_default('docker', version)
6565
helpers.assert_no_additional_deps('docker', additional_dependencies)
6666
assert_docker_available()
@@ -76,14 +76,14 @@ def install_environment(
7676
os.mkdir(directory)
7777

7878

79-
def get_docker_user() -> str: # pragma: windows no cover
79+
def get_docker_user() -> str: # pragma: win32 no cover
8080
try:
8181
return f'{os.getuid()}:{os.getgid()}'
8282
except AttributeError:
8383
return '1000:1000'
8484

8585

86-
def docker_cmd() -> Tuple[str, ...]: # pragma: windows no cover
86+
def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
8787
return (
8888
'docker', 'run',
8989
'--rm',
@@ -100,7 +100,7 @@ def run_hook(
100100
hook: Hook,
101101
file_args: Sequence[str],
102102
color: bool,
103-
) -> Tuple[int, bytes]: # pragma: windows no cover
103+
) -> Tuple[int, bytes]: # pragma: win32 no cover
104104
assert_docker_available()
105105
# Rebuild the docker image in case it has gone missing, as many people do
106106
# automated cleanup of docker images.

pre_commit/languages/docker_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run_hook(
1616
hook: Hook,
1717
file_args: Sequence[str],
1818
color: bool,
19-
) -> Tuple[int, bytes]: # pragma: windows no cover
19+
) -> Tuple[int, bytes]: # pragma: win32 no cover
2020
assert_docker_available()
2121
cmd = docker_cmd() + hook.cmd
2222
return helpers.run_xargs(hook, cmd, file_args, color=color)

pre_commit/languages/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_env_patch(venv: str) -> PatchesT:
3535
elif sys.platform == 'win32': # pragma: no cover
3636
install_prefix = bin_dir(venv)
3737
lib_dir = 'Scripts'
38-
else: # pragma: windows no cover
38+
else: # pragma: win32 no cover
3939
install_prefix = venv
4040
lib_dir = 'lib'
4141
return (

pre_commit/languages/ruby.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
def get_env_patch(
2626
venv: str,
2727
language_version: str,
28-
) -> PatchesT: # pragma: windows no cover
28+
) -> PatchesT: # pragma: win32 no cover
2929
patches: PatchesT = (
3030
('GEM_HOME', os.path.join(venv, 'gems')),
3131
('RBENV_ROOT', venv),
@@ -43,7 +43,7 @@ def get_env_patch(
4343
return patches
4444

4545

46-
@contextlib.contextmanager # pragma: windows no cover
46+
@contextlib.contextmanager # pragma: win32 no cover
4747
def in_env(
4848
prefix: Prefix,
4949
language_version: str,
@@ -64,7 +64,7 @@ def _extract_resource(filename: str, dest: str) -> None:
6464
def _install_rbenv(
6565
prefix: Prefix,
6666
version: str = C.DEFAULT,
67-
) -> None: # pragma: windows no cover
67+
) -> None: # pragma: win32 no cover
6868
directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
6969

7070
_extract_resource('rbenv.tar.gz', prefix.path('.'))
@@ -80,7 +80,7 @@ def _install_rbenv(
8080
def _install_ruby(
8181
prefix: Prefix,
8282
version: str,
83-
) -> None: # pragma: windows no cover
83+
) -> None: # pragma: win32 no cover
8484
try:
8585
helpers.run_setup_cmd(prefix, ('rbenv', 'download', version))
8686
except CalledProcessError: # pragma: no cover (usually find with download)
@@ -90,7 +90,7 @@ def _install_ruby(
9090

9191
def install_environment(
9292
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
93-
) -> None: # pragma: windows no cover
93+
) -> None: # pragma: win32 no cover
9494
additional_dependencies = tuple(additional_dependencies)
9595
directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
9696
with clean_path_on_failure(prefix.path(directory)):
@@ -121,6 +121,6 @@ def run_hook(
121121
hook: Hook,
122122
file_args: Sequence[str],
123123
color: bool,
124-
) -> Tuple[int, bytes]: # pragma: windows no cover
124+
) -> Tuple[int, bytes]: # pragma: win32 no cover
125125
with in_env(hook.prefix, hook.language_version):
126126
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)

pre_commit/languages/swift.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
BUILD_CONFIG = 'release'
2222

2323

24-
def get_env_patch(venv: str) -> PatchesT: # pragma: windows no cover
24+
def get_env_patch(venv: str) -> PatchesT: # pragma: win32 no cover
2525
bin_path = os.path.join(venv, BUILD_DIR, BUILD_CONFIG)
2626
return (('PATH', (bin_path, os.pathsep, Var('PATH'))),)
2727

2828

29-
@contextlib.contextmanager # pragma: windows no cover
29+
@contextlib.contextmanager # pragma: win32 no cover
3030
def in_env(prefix: Prefix) -> Generator[None, None, None]:
3131
envdir = prefix.path(
3232
helpers.environment_dir(ENVIRONMENT_DIR, C.DEFAULT),
@@ -37,7 +37,7 @@ def in_env(prefix: Prefix) -> Generator[None, None, None]:
3737

3838
def install_environment(
3939
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
40-
) -> None: # pragma: windows no cover
40+
) -> None: # pragma: win32 no cover
4141
helpers.assert_version_default('swift', version)
4242
helpers.assert_no_additional_deps('swift', additional_dependencies)
4343
directory = prefix.path(
@@ -59,6 +59,6 @@ def run_hook(
5959
hook: Hook,
6060
file_args: Sequence[str],
6161
color: bool,
62-
) -> Tuple[int, bytes]: # pragma: windows no cover
62+
) -> Tuple[int, bytes]: # pragma: win32 no cover
6363
with in_env(hook.prefix):
6464
return helpers.run_xargs(hook, hook.cmd, file_args, color=color)

0 commit comments

Comments
 (0)