Use language: script for cudf-polars-ir-signatures pre-commit hook#22384
Conversation
The hook is a local script (./ci/check_cudf_polars_ir.py) that only uses stdlib modules and has a shebang line. Using language: python was causing pre-commit to unnecessarily create a virtualenv. language: script is the correct setting for local executable scripts.
jameslamb
left a comment
There was a problem hiding this comment.
Sure, seems fine. By definition if precommit is runnable you must have a Python interpreter around, and this seems fine if you're not picky about which one.
The language key is used to determine the installation mechanism, more than the actual language of the hook, and the installation causes problems in some environments because for a local hook it will try to run [INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/nfs/vyasr/.cache/pre-commit/repoh77sil0l/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout: (none)
stderr:
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.I think whether or not it fails is probably dependent on pre-commit version and the behavior has changed. IOW lying about the language of the hook is the lesser of two evils since in some cases the status quo can fail outright. |
|
/merge |
Description
The
cudf-polars-ir-signaturespre-commit hook useslanguage: pythonbut is just a local script (./ci/check_cudf_polars_ir.py) that only depends on stdlib modules (ast,argparse,sys,typing) and has a#!/usr/bin/env python3shebang.With
language: python, pre-commit unnecessarily creates a virtualenv for this hook.language: scriptis the correct setting — it runs the entry point directly as an executable, relying on the shebang for interpreter selection, with no virtualenv overhead.Checklist