mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
Fix precommit issues
This commit is contained in:
parent
189490a938
commit
0d40562dcb
4 changed files with 35 additions and 15 deletions
|
|
@ -100,6 +100,7 @@ def _ns(
|
|||
rewrite_command=rewrite_command,
|
||||
files=(),
|
||||
hook=None,
|
||||
tags=(),
|
||||
verbose=False,
|
||||
show_diff_on_failure=False,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import time
|
|||
import unicodedata
|
||||
from typing import Any
|
||||
from typing import Collection
|
||||
from typing import Iterable
|
||||
from typing import MutableMapping
|
||||
from typing import Sequence
|
||||
|
||||
|
|
@ -323,26 +324,29 @@ def _has_unstaged_config(config_file: str) -> bool:
|
|||
# be explicit, other git errors don't mean it has an unstaged config.
|
||||
return retcode == 1
|
||||
|
||||
|
||||
def _hook_should_run(args: argparse.Namespace, hook: Hook) -> bool:
|
||||
if args.hook_stage not in hook.stages:
|
||||
return False
|
||||
|
||||
if args.tags:
|
||||
return len(set(hook.tags) & set(args.tags)) > 0
|
||||
|
||||
|
||||
return (
|
||||
not args.hook
|
||||
or hook.id == args.hook
|
||||
or hook.alias == args.hook
|
||||
not args.hook or
|
||||
hook.id == args.hook or
|
||||
hook.alias == args.hook
|
||||
)
|
||||
|
||||
def _hook_is_skipped(skips: Sequence[str], hook: Hook) -> bool:
|
||||
|
||||
def _hook_is_skipped(skips: Iterable[str], hook: Hook) -> bool:
|
||||
return (
|
||||
hook.id in skips
|
||||
or hook.alias in skips
|
||||
or len(set(hook.tags) & set(skips)) > 0
|
||||
hook.id in skips or
|
||||
hook.alias in skips or
|
||||
len(set(hook.tags) & set(skips)) > 0
|
||||
)
|
||||
|
||||
|
||||
def run(
|
||||
config_file: str,
|
||||
store: Store,
|
||||
|
|
@ -438,7 +442,8 @@ def run(
|
|||
return 1
|
||||
if args.tags and not hooks:
|
||||
output.write_line(
|
||||
f'No hooks with tags matching `{args.tags}` in stage `{args.hook_stage}`'
|
||||
f'No hooks with tags matching `{args.tags}` '
|
||||
f'in stage `{args.hook_stage}`',
|
||||
)
|
||||
return 1
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue