python
БесплатноБез исполняемых скриптовНе проверенPython language (3.10-3.14). Covers typing, async, and modern patterns. Use when writing Python applications. USE WHEN: user mentions "python", "type hints"…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Python Core Knowledge
Full Reference: See advanced.md for production patterns: Result types, custom exceptions, structured logging, Pydantic validation, testing patterns, performance optimization, and dependency injection.
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:pythonfor comprehensive documentation.
Python Version Support
| Version | Status | Key Features |
|---|---|---|
| 3.14 | Current | Type defaults, JIT improvements |
| 3.13 | Stable | Free-threading (experimental), JIT |
| 3.12 | Stable | PEP 695 type syntax, f-string improvements |
| 3.11 | Stable | Exception groups, 10-60% faster |
| 3.10 | Security | Pattern matching, | union |
Type Hints (Modern Syntax)
# Python 3.10+ - Use | instead of Union
def greet(name: str | None = None) -> str:
return f"Hello, {name or 'World'}"
# Python 3.9+ - Use built-in generics
def process(items: list[str]) -> dict[str, int]:
return {item: len(item) for item in items}
# Python 3.12+ - PEP 695 Type Parameter Syntax
def first[T](items: list[T]) -> T | None:
return items[0] if items else None
class Stack[T]:
def __init__(self) -> None:
self._items: list[T] = []
def push(self, item: T) -> None:
self._items.append(item)
def pop(self) -> T:
return self._items.pop()
# Type aliases (Python 3.12+)
type Point = tuple[float, float]
type Vector[T] = list[T]
type Handler[T] = Callable[[T], None]
# Callable
def apply(fn: Callable[[int], int], value: int) -> int:
return fn(value)
Dataclasses
from dataclasses import dataclass, field
from datetime import datetime
@dataclass
class User:
id: int
name: str
email: str
created_at: datetime = field(default_factory=datetime.now)
is_active: bool = True
def __post_init__(self):
self.email = self.email.lower()
# Frozen (immutable)
@dataclass(frozen=True)
class Point:
x: float
y: float
# Slots for memory efficiency (Python 3.10+)
@dataclass(slots=True)
class Optimized:
value: int
Async/Await
import asyncio
import aiohttp
async def fetch_user(id: int) -> dict:
async with aiohttp.ClientSession() as session:
async with session.get(f'/api/users/{id}') as response:
return await response.json()
async def fetch_all_users(ids: List[int]) -> List[dict]:
tasks = [fetch_user(id) for id in ids]
return await asyncio.gather(*tasks)
# Run
asyncio.run(fetch_all_users([1, 2, 3]))
Context Managers
from contextlib import contextmanager, asynccontextmanager
@contextmanager
def timer():
start = time.time()
yield
print(f"Elapsed: {time.time() - start:.2f}s")
with timer():
process_data()
@asynccontextmanager
async def get_db():
db = await create_connection()
try:
yield db
finally:
await db.close()
Modern Patterns
# Match (3.10+)
match status:
case "active":
handle_active()
case "inactive" | "pending":
handle_pending()
case {"type": "user", "name": name}: # Dict pattern
handle_user(name)
case [first, *rest]: # Sequence pattern
handle_sequence(first, rest)
case _:
handle_default()
# Walrus operator
if (n := len(items)) > 10:
print(f"Too many: {n}")
# Exception groups (3.11+)
try:
async with asyncio.TaskGroup() as tg:
tg.create_task(task1())
tg.create_task(task2())
except* ValueError as eg:
for exc in eg.exceptions:
print(f"ValueError: {exc}")
except* TypeError as eg:
for exc in eg.exceptions:
print(f"TypeError: {exc}")
Static Analysis & Linting
Official Rules References
| Tool | Rules Count | Documentation |
|---|---|---|
| Ruff | 800+ | https://docs.astral.sh/ruff/rules/ |
| SonarPython | 300+ | https://rules.sonarsource.com/python/ |
| Pylint | 200+ | https://pylint.readthedocs.io/en/latest/user_guide/messages/messages_overview.html |
| Mypy | Type checker | https://mypy.readthedocs.io/en/stable/error_codes.html |
Style Guides
| Guide | Link |
|---|---|
| PEP 8 | https://peps.python.org/pep-0008/ |
| PEP 20 (Zen) | https://peps.python.org/pep-0020/ |
| Google Python Style | https://google.github.io/styleguide/pyguide.html |
Ruff Configuration
# pyproject.toml
[tool.ruff]
line-length = 88
target-version = "py312"
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"S", # flake8-bandit (security)
]
ignore = ["E501"] # line too long (handled by formatter)
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"] # allow assert in tests
Full configuration guide: See [python-quality skill](../../best-practice
Установить python в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditВложенные файлы
FAQ
Что делает скилл python?
Python language (3.10-3.14). Covers typing, async, and modern patterns. Use when writing Python applications. USE WHEN: user mentions "python", "type hints", "dataclasses", "async/await", asks about "asyncio", "context managers", "match statement", "walrus operator", "PEP 695", "type parameter", "generic" DO NOT USE FOR: reviewing existing Python code - use `review/python`, which covers the defects ruff and mypy do not report DO NOT USE FOR: FastAPI framework - use `backend-fastapi` skill instead DO NOT USE FOR: Django framework - use Django-specific skill DO NOT USE FOR: Package management - use `python-packaging` skill DO NOT USE FOR: Linting/type checking config - use `python-quality` skill
Как установить скилл python?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл python запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic