Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

python-quality

БесплатноБез исполняемых скриптовНе проверен

Python static analysis with ruff, mypy, pyright. Type checking and linting best practices. USE WHEN: "type checking", "mypy", "pyright", "ruff", "linting"…

claude-dev-suiteот claude-dev-suite★ 51 звезда на GitHub

Об этом скилле

Python Code Quality

Deep Knowledge: Use mcp__documentation__fetch_docs with technology: python topic: quality for complete documentation.

Tool Stack (2026)

Tool Purpose Speed Recommendation
ruff Linting + Formatting Fastest (10-100x) Primary
mypy Type checking Good CI gate
pyright Type checking Fast IDE (Pylance)
ty Type checking Fastest Emerging

Recommended setup: ruff (lint/format) + pyright (IDE) + mypy (CI)

ruff Configuration

# pyproject.toml
[tool.ruff]
line-length = 88
target-version = "py312"
src = ["src", "tests"]

[tool.ruff.lint]
select = [
    "E",      # pycodestyle errors
    "W",      # pycodestyle warnings
    "F",      # Pyflakes
    "I",      # isort
    "B",      # flake8-bugbear
    "C4",     # flake8-comprehensions
    "UP",     # pyupgrade
    "ARG",    # flake8-unused-arguments
    "SIM",    # flake8-simplify
    "TCH",    # flake8-type-checking
    "S",      # flake8-bandit (security)
    "RUF",    # Ruff-specific rules
]
ignore = [
    "E501",   # line too long (formatter handles)
    "S101",   # assert usage (OK in tests)
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101", "ARG"]
"__init__.py" = ["F401"]

[tool.ruff.lint.isort]
known-first-party = ["my_package"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"

ruff Commands

# Lint
ruff check .
ruff check --fix .          # Auto-fix

# Format
ruff format .
ruff format --check .       # Check only

# Combined (CI)
ruff check . && ruff format --check .

mypy Configuration

# pyproject.toml
[tool.mypy]
python_version = "3.12"
strict = true
warn_return_any = true
warn_unused_ignores = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
no_implicit_optional = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "truthy-bool"]

tool.mypy.overrides
module = "tests.*"
disallow_untyped_defs = false

tool.mypy.overrides
module = ["third_party_lib.*"]
ignore_missing_imports = true

mypy Commands

# Check
mypy src/
mypy src/ --strict

# Daemon mode (faster)
dmypy run -- src/

# Generate stubs
stubgen -p my_package -o stubs/

pyright Configuration

// pyrightconfig.json
{
  "include": ["src"],
  "exclude": ["**/node_modules", "**/__pycache__"],
  "typeCheckingMode": "strict",
  "pythonVersion": "3.12",
  "reportMissingImports": true,
  "reportMissingTypeStubs": false,
  "reportUnusedImport": true,
  "reportUnusedVariable": true
}

Or in pyproject.toml:

[tool.pyright]
include = ["src"]
typeCheckingMode = "strict"
pythonVersion = "3.12"

Common Type Errors & Solutions

Missing return type

# Error: Function is missing a return type annotation
def greet(name: str):  # Bad
    return f"Hello {name}"

def greet(name: str) -> str:  # Good
    return f"Hello {name}"

Optional handling

# Error: "None" is not compatible with "str"
def get_name(user: User | None) -> str:
    return user.name  # Bad - user might be None

def get_name(user: User | None) -> str:
    if user is None:
        return "Unknown"
    return user.name  # Good - narrowed to User

Type narrowing

from typing import TypeGuard

def is_string_list(val: list[object]) -> TypeGuard[list[str]]:
    return all(isinstance(x, str) for x in val)

def process(items: list[object]) -> None:
    if is_string_list(items):
        # items is now list[str]
        print(items[0].upper())

Callable types

from collections.abc import Callable

# Function type
Handler = Callable[[str, int], bool]

def process(handler: Handler) -> None:
    result = handler("test", 42)

Generic variance

from typing import TypeVar

# Invariant (default)
T = TypeVar("T")

# Covariant (read-only)
T_co = TypeVar("T_co", covariant=True)

# Contravariant (write-only)
T_contra = TypeVar("T_contra", contravariant=True)

Strict Mode Migration

Phase 1: Basic types

[tool.mypy]
check_untyped_defs = true

Phase 2: Require annotations

[tool.mypy]
disallow_untyped_defs = true
disallow_incomplete_defs = true

Phase 3: Full strict

[tool.mypy]
strict = true

Per-module migration

tool.mypy.overrides
module = "legacy_module.*"
disallow_untyped_defs = false

CI/CD Integration

# GitHub Actions
name: Quality

on: [push, pull_request]

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v4

      - name: Install dependencies
        run: uv sync

      - name: Lint
        run: uv run ruff check .

      - name: Format check
        run: uv run ruff format --check .

      - name: Type check
        run: uv run mypy src/

Pre-commit Configuration

#
Полный SKILL.md на GitHub

Установить python-quality в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob
Write
Edit
Bash

FAQ

Что делает скилл python-quality?

Python static analysis with ruff, mypy, pyright. Type checking and linting best practices. USE WHEN: "type checking", "mypy", "pyright", "ruff", "linting", "static analysis", "type error", "type hints", "pylint", "flake8", "black", "isort", "code quality" DO NOT USE FOR: Basic type hint syntax - use languages/python skill DO NOT USE FOR: Runtime validation - use Pydantic

Как установить скилл python-quality?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл python-quality запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить python-quality с