8000 SKIP skips invocation by alias but doesn't skip "Installing environment" · Issue #2478 · pre-commit/pre-commit · GitHub
[go: up one dir, main page]

Skip to content
SKIP skips invocation by alias but doesn't skip "Installing environment" #2478
@kmARC

Description

@kmARC

search tried in the issue tracker

SKIP alias

describe your issue

When I run

SKIP=pylint-alias2 git commit

the hook aliased as pylint-alias2 is properly skipped, however, its environment is still initialized. I would expect that it also skips the lengthy initialization of the environment.

Indeed, running a single hook (run.py#153) checks against hook.id and hook.alias, however install_hook_envs is invoked with only filtering against hook.id (run.py#423

Is this inconsistency deliberate? I couldn't find a use case for it. This quick and dirty patch works for us:

-        to_install = [hook for hook in hooks if hook.id not in skips]
+        to_install = [hook for hook in hooks if hook.id not in skips and hook.alias not in skips]

In our use case Initialization is not needed for everyone (monorepo where some non-python devs also do non-python work) and also very expensive unfortunately (6minutes currently to install already cached pip packages)

(An even better solution would be if initialization wouldn't happen at all if the hook run would we skipped in general (because of SKIP variable or because there is no files changed, however, that would be a but bigger patch I suppose))

pre-commit --version

pre-commit

.pre-commit-config.yaml

repos:
  - repo: https://github.com/PyCQA/pylint
    rev: v2.14.5
    hooks:
      - name: pylint-alias1
        alias: pylint-alias1
        id: pylint
        additional_dependencies:
          - arrow
      - name: pylint-alias2
        alias: pylint-alias2
        id: pylint
        additional_dependencies:
          - hdfs

~/.cache/pre-commit/pre-commit.log (if present)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0