Title: SKIP skips invocation by alias but doesn't skip "Installing environment" · Issue #2478 · pre-commit/pre-commit · GitHub
Open Graph Title: SKIP skips invocation by alias but doesn't skip "Installing environment" · Issue #2478 · pre-commit/pre-commit
X Title: SKIP skips invocation by alias but doesn't skip "Installing environment" · Issue #2478 · pre-commit/pre-commit
Description: 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 s...
Open Graph Description: 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 in...
X Description: 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 in...
Opengraph URL: https://github.com/pre-commit/pre-commit/issues/2478
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SKIP skips invocation by alias but doesn't skip \"Installing environment\"","articleBody":"### search tried in the issue tracker\r\n\r\nSKIP alias\r\n\r\n### describe your issue\r\n\r\nWhen I run \r\n\r\n```sh\r\nSKIP=pylint-alias2 git commit\r\n```\r\n\r\nthe 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.\r\n\r\nIndeed, running a single hook ([run.py#153](https://github.com/pre-commit/pre-commit/blob/49f95b9ef391639d09136666be375d99a3dccd04/pre_commit/commands/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](https://github.com/pre-commit/pre-commit/blob/49f95b9ef391639d09136666be375d99a3dccd04/pre_commit/commands/run.py)\r\n\r\nIs this inconsistency deliberate? I couldn't find a use case for it. This quick and dirty patch works for us:\r\n\r\n```diff\r\n- to_install = [hook for hook in hooks if hook.id not in skips]\r\n+ to_install = [hook for hook in hooks if hook.id not in skips and hook.alias not in skips]\r\n```\r\n\r\nIn 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)\r\n\r\n(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))\r\n\r\n### pre-commit --version\r\n\r\npre-commit \r\n\r\n### .pre-commit-config.yaml\r\n\r\n```yaml\r\nrepos:\r\n - repo: https://github.com/PyCQA/pylint\r\n rev: v2.14.5\r\n hooks:\r\n - name: pylint-alias1\r\n alias: pylint-alias1\r\n id: pylint\r\n additional_dependencies:\r\n - arrow\r\n - name: pylint-alias2\r\n alias: pylint-alias2\r\n id: pylint\r\n additional_dependencies:\r\n - hdfs\r\n```\r\n\r\n\r\n### ~/.cache/pre-commit/pre-commit.log (if present)\r\n\r\n_No response_","author":{"url":"https://github.com/kmARC","@type":"Person","name":"kmARC"},"datePublished":"2022-08-10T13:49:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/2478/pre-commit/issues/2478"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5de1ba15-30ff-1ec3-5c96-3d65a763a5d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E53A:19CFB6:C1F216:1028813:6A52C300 |
| html-safe-nonce | a6ca7699837c752f7fdb0bf20ba154e532fa59966c3dccaafdce3c6a03538838 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTNBOjE5Q0ZCNjpDMUYyMTY6MTAyODgxMzo2QTUyQzMwMCIsInZpc2l0b3JfaWQiOiIxNjQ0OTI3NTIzODk4NDk4NTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c793bfb05002d3873c2f278462e9d473d0fa6a2dc117dfa20a68c5c1eb409b1b |
| hovercard-subject-tag | issue:1334660855 |
| github-keyboard-shortcuts | repository,issues,commits,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pre-commit/pre-commit/2478/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5391453a096e4010d723bb09bfaf5735d5bc7136118d77654b52b8bfc31bb9be/pre-commit/pre-commit/issues/2478 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5391453a096e4010d723bb09bfaf5735d5bc7136118d77654b52b8bfc31bb9be/pre-commit/pre-commit/issues/2478 |
| og:image:alt | 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 in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kmARC |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/pre-commit/pre-commit git https://github.com/pre-commit/pre-commit.git |
| octolytics-dimension-user_id | 6943086 |
| octolytics-dimension-user_login | pre-commit |
| octolytics-dimension-repository_id | 17689377 |
| octolytics-dimension-repository_nwo | pre-commit/pre-commit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17689377 |
| octolytics-dimension-repository_network_root_nwo | pre-commit/pre-commit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width