---
name: block-any-type
enabled: true
event: file
action: block
conditions:
  - field: file_path
    operator: regex_match
    pattern: \.(py|pyi)$
  - field: new_text
    operator: regex_match
    pattern: (from\s+typing\s+import\s+[^#\n]*\bAny\b|:\s*Any\b|:\s*"Any"|:\s*'Any'|->\s*Any\b|->\s*"Any"|->\s*'Any'|\[\s*Any\s*\]|\[\s*Any\s*,|,\s*Any\s*\]|,\s*Any\s*,|Union\[.*\bAny\b.*\]|Optional\[Any\])
---

🚫 **BLOCKED: Insecure `Any` Type Usage Detected**

You are attempting to use `Any` as a type annotation, which is **strictly forbidden** in this codebase.

## Why `Any` is Forbidden

- `Any` bypasses all type checking, defeating the purpose of static analysis
- It creates type safety holes that propagate through the codebase
- It hides bugs that would otherwise be caught at compile time
- It makes refactoring dangerous and error-prone

## What to Do Instead

1. **Use specific types**: `str`, `int`, `dict[str, int]`, `list[MyClass]`
2. **Use `object`**: When you truly need the base type
3. **Use `Protocol`**: For structural typing / duck typing
4. **Use `TypeVar`**: For generic type parameters
5. **Use union types**: `str | int | None` instead of `Any`

## Need Help?

Run the **`/type-strictness`** skill to get guidance on proper type annotations for your specific use case.

```
/type-strictness
```

This skill will help you find the correct specific type to use instead of `Any`.
