Skip to content

Commit

Permalink
pre-commit: fix pygrep hooks
Browse files Browse the repository at this point in the history
Fixes #173707
  • Loading branch information
NilsIrl authored and pull[bot] committed Feb 12, 2024
1 parent 2591d82 commit 27b6d45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkgs/tools/misc/pre-commit/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ buildPythonApplication rec {
patches = [
./languages-use-the-hardcoded-path-to-python-binaries.patch
./hook-tmpl.patch
./pygrep-pythonpath.patch
];

propagatedBuildInputs = [
Expand Down
13 changes: 13 additions & 0 deletions pkgs/tools/misc/pre-commit/pygrep-pythonpath.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/pre_commit/languages/pygrep.py b/pre_commit/languages/pygrep.py
index ec55560..44e08a1 100644
--- a/pre_commit/languages/pygrep.py
+++ b/pre_commit/languages/pygrep.py
@@ -98,7 +98,7 @@ def run_hook(
color: bool,
) -> tuple[int, bytes]:
cmd = (sys.executable, '-m', __name__, *args, entry)
- return xargs(cmd, file_args, color=color)
+ return xargs(cmd, file_args, color=color, env={ "PYTHONPATH": ':'.join(sys.path) })


def main(argv: Sequence[str] | None = None) -> int:

0 comments on commit 27b6d45

Please sign in to comment.