fix: hookify Python 3.8 compat and cwd-independent rule loading#23972
Open
clowerweb wants to merge 1 commit intoanthropics:mainfrom
Open
fix: hookify Python 3.8 compat and cwd-independent rule loading#23972clowerweb wants to merge 1 commit intoanthropics:mainfrom
clowerweb wants to merge 1 commit intoanthropics:mainfrom
Conversation
Two fixes for the hookify plugin:
1. Add `from __future__ import annotations` to config_loader.py.
The `tuple[Dict, str]` return type annotation on line 87 uses
Python 3.9+ syntax, causing TypeError on Python 3.8 (e.g.
Ubuntu 20.04 default). The future import enables modern type
hint syntax on Python 3.7+.
2. Use CLAUDE_PROJECT_DIR env var for rule file discovery instead
of a relative path. The previous `os.path.join('.claude', ...)`
only found rules when cwd happened to be the project root.
Now uses the CLAUDE_PROJECT_DIR environment variable set by
Claude Code, falling back to cwd if unset.
Fixes anthropics#14588
Fixes anthropics#20749
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes for the hookify plugin in
config_loader.py:from __future__ import annotationsto fixTypeError: 'type' object is not subscriptableon Python 3.8 (Ubuntu 20.04 default). Thetuple[Dict, str]return type syntax requires Python 3.9+; the future import enables it on 3.7+.CLAUDE_PROJECT_DIRenv var instead of relative path for.claude/hookify.*.local.mddiscovery. Previously, rules were only found when the cwd happened to be the project root; now they're found from any working directory.Test plan
TypeErrorCLAUDE_PROJECT_DIRis set (standard Claude Code behavior)os.getcwd()whenCLAUDE_PROJECT_DIRis unsetFixes #14588
Fixes #20749
🤖 Generated with Claude Code