python-deprecation-fixer
БесплатноЗапускает вложенные скриптыНе проверенAutomatically detect and fix Python deprecation warnings in codebases, including datetime.utcnow(), and other common deprecated patterns. Supports extensible…
Об этом скилле
Python Deprecation Fixer
Overview
This skill automatically detects and fixes Python deprecation warnings across your codebase. It uses intelligent pattern matching to identify deprecated code patterns and applies the recommended modern alternatives. The skill is designed to be extensible, allowing easy addition of new deprecation patterns as Python evolves.
When to Use This Skill
Use this skill when:
- You encounter Python deprecation warnings in your code
- Upgrading to a newer Python version (e.g., 3.12+)
- Modernizing a legacy Python codebase
- Running linters that flag deprecated APIs
- You see warnings like "DeprecationWarning: datetime.utcnow() is deprecated"
Common deprecation scenarios:
datetime.utcnow()→datetime.now(UTC)datetime.utcfromtimestamp()→datetime.fromtimestamp(UTC)asyncio.coroutinedecorator →async defcollections.Mapping→collections.abc.Mapping- Other deprecated stdlib patterns
Quick Start
Scan for Deprecations
Scan your codebase to find all deprecation issues:
python3 scripts/fix_deprecations.py /path/to/project --scan-only
This will report all deprecated patterns found without making changes.
Fix All Deprecations
Automatically fix all detected deprecations:
python3 scripts/fix_deprecations.py /path/to/project --fix
Preview Changes
See what would be changed before applying fixes:
python3 scripts/fix_deprecations.py /path/to/project --dry-run
Usage Options
Basic Commands
Scan only (no changes):
python3 scripts/fix_deprecations.py /path/to/project --scan-only
Fix with automatic backup:
python3 scripts/fix_deprecations.py /path/to/project --fix
Dry run (show changes without applying):
python3 scripts/fix_deprecations.py /path/to/project --dry-run
Advanced Options
Target specific files:
python3 scripts/fix_deprecations.py /path/to/project --fix --files "*.py" --exclude "tests/*"
Fix specific deprecation types:
# Only fix datetime deprecations
python3 scripts/fix_deprecations.py /path/to/project --fix --pattern datetime
# Only fix asyncio deprecations
python3 scripts/fix_deprecations.py /path/to/project --fix --pattern asyncio
Control output verbosity:
# Verbose output with detailed changes
python3 scripts/fix_deprecations.py /path/to/project --fix --verbose
# JSON output for programmatic use
python3 scripts/fix_deprecations.py /path/to/project --scan-only --json
Skip imports check:
# Fix patterns without verifying imports exist
python3 scripts/fix_deprecations.py /path/to/project --fix --no-import-check
Supported Deprecation Patterns
datetime Module (Python 3.12+)
Pattern: datetime.utcnow()
Replacement: datetime.now(UTC)
Import required: from datetime import UTC
Example:
# Before
from datetime import datetime
timestamp = datetime.utcnow()
# After
from datetime import datetime, UTC
timestamp = datetime.now(UTC)
Pattern: datetime.utcfromtimestamp(ts)
Replacement: datetime.fromtimestamp(ts, UTC)
Example:
# Before
dt = datetime.utcfromtimestamp(1234567890)
# After
from datetime import UTC
dt = datetime.fromtimestamp(1234567890, UTC)
asyncio Module
Pattern: @asyncio.coroutine
Replacement: async def
Example:
# Before
@asyncio.coroutine
def my_func():
yield from something()
# After
async def my_func():
await something()
collections Module
Pattern: collections.Mapping, collections.Sequence, etc.
Replacement: collections.abc.Mapping, collections.abc.Sequence
Example:
# Before
from collections import Mapping
# After
from collections.abc import Mapping
How It Works
The fixer uses a multi-step approach:
- Pattern Detection: Searches Python files using AST (Abstract Syntax Tree) parsing
- Context Analysis: Verifies the deprecation applies in context (e.g., checks imports)
- Smart Replacement: Applies the recommended fix while preserving formatting
- Import Management: Automatically adds required imports (e.g.,
UTC) - Validation: Optionally runs syntax checks after modifications
Output Format
Scan Results
🔍 Scanning for Python deprecations in: /path/to/project
Found 3 deprecation issues:
📄 src/models.py
Line 42: datetime.utcnow() → datetime.now(UTC)
Line 127: datetime.utcfromtimestamp(ts) → datetime.fromtimestamp(ts, UTC)
📄 src/utils.py
Line 15: datetime.utcnow() → datetime.now(UTC)
Summary:
- datetime deprecations: 3
- Files affected: 2
Fix Results
🔧 Fixing Python deprecations in: /path/to/project
✅ src/models.py
✓ Line 42: Fixed datetime.utcnow() → datetime.now(UTC)
✓ Line 127: Fixed datetime.utcfromtimestamp() → datetime.fromtimestamp(UTC)
✓ Added import: from datetime import UTC
✅ src/utils.py
✓ Line 15: Fixed datetime.utcn
Установить python-deprecation-fixer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл python-deprecation-fixer?
Automatically detect and fix Python deprecation warnings in codebases, including datetime.utcnow(), and other common deprecated patterns. Supports extensible pattern matching for future deprecations.
Как установить скилл python-deprecation-fixer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл python-deprecation-fixer запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
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