mypy-setup
БесплатноБез исполняемых скриптовНе проверенSet up Mypy type checking configuration for a Python project
от jpoutrin★ 16 звёзд на GitHubОб этом скилле
mypy-setup
Category: Python Development
Usage
/mypy-setup [--strict] [--django] [--format=<ini|toml>] [--install]
Arguments
| Argument | Required | Description |
|---|---|---|
--strict |
No | Use strict type checking configuration |
--django |
No | Add Django-specific configuration and plugin |
--format=<ini|toml> |
No | Config format (default: ini) |
--install |
No | Install Mypy and required plugins |
Purpose
Set up Mypy static type checking in a Python project:
- Create Configuration: Generate mypy.ini or pyproject.toml config
- Install Dependencies: Install Mypy and type stub packages
- Configure IDE: Add Mypy settings for VS Code/PyCharm
- Setup CI/CD: Generate GitHub Actions workflow
- Add Pre-commit: Configure pre-commit hook for Mypy
Execution Instructions for Claude Code
When this command is run, Claude Code should:
1. Parse Arguments
STRICT_MODE = true if --strict specified
DJANGO_MODE = true if --django specified
FORMAT = value after --format= (default: "ini")
INSTALL = true if --install specified
2. Detect Project Type
Scan the project to determine:
# Check for Django
HAS_DJANGO=false
if [ -f "manage.py" ] || grep -q "django" requirements.txt 2>/dev/null; then
HAS_DJANGO=true
echo "✓ Django project detected"
fi
# Check for existing config
HAS_CONFIG=false
if [ -f "mypy.ini" ] || [ -f ".mypy.ini" ] || grep -q "\[tool.mypy\]" pyproject.toml 2>/dev/null; then
HAS_CONFIG=true
echo "⚠ Existing Mypy configuration found"
fi
# Check Python version
PYTHON_VERSION=$(python --version | cut -d' ' -f2 | cut -d'.' -f1,2)
echo "Python version: $PYTHON_VERSION"
3. Install Mypy (if --install)
if [ "$INSTALL" = true ]; then
echo "Installing Mypy..."
# Use uv if available, otherwise pip
if command -v uv &> /dev/null; then
PKG_MANAGER="uv pip install"
else
PKG_MANAGER="pip install"
fi
# Install Mypy
$PKG_MANAGER mypy
# Install Django plugin if needed
if [ "$DJANGO_MODE" = true ] || [ "$HAS_DJANGO" = true ]; then
$PKG_MANAGER django-stubs mypy-django-plugin
fi
# Install common type stubs
$PKG_MANAGER types-requests types-PyYAML types-redis
echo "✓ Mypy installed successfully"
fi
4. Generate Configuration File
Option A: mypy.ini (default)
if [ "$FORMAT" = "ini" ]; then
cat > mypy.ini << 'EOF'
[mypy]
# Python version
python_version = 3.11
# Import discovery
namespace_packages = True
explicit_package_bases = True
ignore_missing_imports = False
# Platform configuration
platform = linux
# Disallow dynamic typing
disallow_any_generics = True
disallow_subclassing_any = True
# Disallow untyped code
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
# None and Optional handling
no_implicit_optional = True
strict_optional = True
# Warnings
warn_redundant_casts = True
warn_unused_ignores = True
warn_no_return = True
warn_return_any = True
warn_unreachable = True
# Strictness flags
strict_equality = True
strict_concatenate = True
# Error messages
show_error_codes = True
show_column_numbers = True
show_error_context = True
pretty = True
# Miscellaneous
warn_unused_configs = True
# Per-module options for gradual typing
[mypy-tests.*]
disallow_untyped_defs = False
[mypy-migrations.*]
ignore_errors = True
EOF
if [ "$STRICT_MODE" = true ]; then
# Already strict by default
echo "✓ Created strict mypy.ini"
else
# Relax some settings for gradual adoption
cat >> mypy.ini << 'EOF'
# Relaxed settings for gradual adoption
# Remove these overrides as you add type hints
[mypy]
disallow_untyped_calls = False
disallow_untyped_defs = False
disallow_incomplete_defs = False
EOF
echo "✓ Created mypy.ini (gradual mode)"
echo " Gradually enable stricter checks as you add type hints"
fi
# Add Django configuration
if [ "$DJANGO_MODE" = true ] || [ "$HAS_DJANGO" = true ]; then
cat >> mypy.ini << 'EOF'
# Django configuration
[mypy]
plugins = mypy_django_plugin.main
[mypy.plugins.django-stubs]
django_settings_module = "config.settings" # Update with your settings module
EOF
echo "✓ Added Django plugin configuration"
echo " Update django_settings_module in mypy.ini"
fi
fi
Option B: pyproject.toml
if [ "$FORMAT" = "toml" ]; then
# Check if pyproject.toml exists
if [ ! -f "pyproject.toml" ]; then
cat > pyproject.toml << 'EOF'
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
EOF
fi
# Add Mypy configuration
cat >> pyproject.toml << 'EOF'
[tool.mypy]
python_version = "3.11"
namespace_packages = true
explicit_package_bases = true
ignore_missing_imports = false
# Strictness
disallow_an
Установить mypy-setup в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл mypy-setup?
Set up Mypy type checking configuration for a Python project
Как установить скилл mypy-setup?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mypy-setup запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic