All skills
wdm0006 avatar

/code-quality

@29279e3

Improves Python library code quality through ruff linting, mypy type checking, Pythonic idioms, and refactoring. Use when reviewing code for quality issues, adding type hints, configuring static analysis tools, or refactoring Python library code.

  • 4 files
  • 18.4 KB
  • Updated 2 months ago
  • GitHub

Use this Skill: https://skilld.dev/gh/wdm0006/python-skills/code-quality

This session only. Nothing lands on disk.

MYPY_CONFIG.md

≈357 tokens on demand. Your agent reads this file only when SKILL.md points to it.

MyPy Configuration Reference

Strict Configuration

[tool.mypy]
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true

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

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

Gradual Adoption

Start lenient, tighten over time:

# Phase 1: Basic
[tool.mypy]
python_version = "3.10"
warn_return_any = true

# Phase 2: Require types on new code
disallow_untyped_defs = true
disallow_incomplete_defs = true

# Phase 3: Full strict
strict = true

Common Fixes

# Error: Missing return type
def process(x):  # Add: -> ReturnType
    ...

# Error: Incompatible types
x: str = 123  # Fix: x: int = 123

# Error: Missing type for argument
def func(data):  # Add: data: dict[str, Any]
    ...

# Silence specific line
x = untyped_call()  # type: ignore[no-untyped-call]

Type Stubs

For libraries without type hints:

# Install stubs
uv add --dev types-requests types-PyYAML

# Or ignore in config
[[tool.mypy.overrides]]
module = "untyped_library.*"
ignore_missing_imports = true

Source: SKILL.md on GitHub

No third-party reports yet.

Signed by skilld at 29279e3. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 months ago

README badge

README badge for wdm0006/python-skills/code-quality