Skip to content

[Bug] hookify plugin: Python 3.8 incompatibility - TypeError: 'type' object is not subscriptable #14588

@umitkacar

Description

@umitkacar

Bug Description

The hookify plugin's config_loader.py uses Python 3.9+ type hint syntax (tuple[Dict[str, Any], str]) which causes a TypeError on Python 3.8 systems.

Environment

  • OS: Ubuntu 20.04 LTS
  • Python Version: 3.8.10 (Ubuntu 20.04 default)
  • Claude Code Version: Latest (installed via npm)
  • Plugin: hookify (official)
  • Plugin Path: ~/.claude/plugins/cache/claude-plugins-official/hookify/*/core/config_loader.py

Error Message

PreToolUse:TodoWrite says: Plugin hook error: Traceback (most recent call last):
  File "~/.claude/plugins/cache/claude-plugins-official/hookify/.../hooks/pretooluse.py", line 18, in <module>
    from core.config_loader import load_rules
  File "~/.claude/plugins/cache/claude-plugins-official/hookify/.../core/config_loader.py", line 87, in <module>
    def extract_frontmatter(content: str) -> tuple[Dict[str, Any], str]:
TypeError: 'type' object is not subscriptable

Root Cause

Line 87 in config_loader.py:

def extract_frontmatter(content: str) -> tuple[Dict[str, Any], str]:

The tuple[...] syntax for generic type hints is only available in Python 3.9+. In Python 3.8 and earlier, you must use typing.Tuple or add from __future__ import annotations.

Suggested Fix

Add from __future__ import annotations at the top of config_loader.py (after the docstring):

#!/usr/bin/env python3
"""Configuration loader for hookify plugin.

Loads and parses .claude/hookify.*.local.md files.
"""

from __future__ import annotations  # PEP 563: Python 3.7+ type hint compatibility

import os
# ... rest of imports

This is the cleanest fix because:

  1. Only requires adding one line
  2. Works with Python 3.7+ (PEP 563)
  3. Enables all modern type hint syntax
  4. No need to change existing type annotations

Workaround

Users can manually add from __future__ import annotations to the cached file:

# Find and fix the file
sed -i '7i from __future__ import annotations  # PEP 563 fix' \
  ~/.claude/plugins/cache/claude-plugins-official/hookify/*/core/config_loader.py

Note: This workaround is lost when the plugin cache is cleared.

Impact

  • Severity: HIGH - Plugin completely non-functional on Python 3.8
  • Affected Users: Anyone on Ubuntu 20.04 LTS or other systems with Python 3.8 as default
  • Workaround Available: Yes, but temporary (cache clear removes fix)

Additional Context

Ubuntu 20.04 LTS is still widely used and ships with Python 3.8.10 as the default. Many enterprise environments and servers run this version.

Thank you for the amazing Claude Code tool! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:linuxIssue specifically occurs on LinuxstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions