code-quality_skill

This skill helps you improve Python library code quality by applying ruff linting, mypy typing, and clean refactoring across projects.
  • Python

6

GitHub Stars

4

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill wdm0006/python-skills --skill code-quality

  • MYPY_CONFIG.md1.4 KB
  • RUFF_CONFIG.md1.6 KB
  • SKILL.md3.0 KB
  • TYPE_PATTERNS.md2.3 KB

Overview

This skill improves Python library code quality by applying ruff linting, mypy type checking, Pythonic idioms, and targeted refactors. It focuses on making public APIs typed and documented, removing common anti-patterns, and configuring static analysis for consistent results. Use it when reviewing or hardening library code for distribution and long-term maintenance.

How this skill works

The skill runs ruff to enforce linting and formatting rules and runs mypy for static type checking. It identifies mutable-defaults, bare excepts, untyped public functions, and other common anti-patterns, then suggests idiomatic rewrites and refactors. It also recommends minimal pyproject.toml configurations and module layout changes to support a clean, typed public API.

When to use it

  • During code review of a Python library before a release
  • When adding or enforcing type hints across a public API
  • When configuring or standardizing ruff and mypy for a repo
  • When refactoring legacy modules to remove anti-patterns
  • When preparing a library for packaging with proper type markers

Best practices

  • Run ruff (check + format) and mypy in CI with the repo’s pyproject.toml settings
  • Use explicit type hints on public functions and classes; keep internal types in types.py
  • Avoid mutable default arguments; prefer None with a local fallback
  • Catch specific exceptions and log or rewrap them instead of using bare except
  • Include a py.typed marker and docstrings for all public API elements

Example use cases

  • Add type annotations and mypy config for a previously untyped library module
  • Refactor functions that use mutable defaults or bare except blocks
  • Standardize ruff rules (line length, target Python version, selected codes) across projects
  • Audit a package to ensure public API functions are typed and documented before release
  • Create a minimal pyproject.toml with ruff and mypy settings to enable CI checks

FAQ

No. The goal is to preserve behavior while improving style, types, and safety. Any behavioral changes are flagged and reviewed before applying.

What minimal configs are recommended for ruff and mypy?

Use a pyproject.toml with ruff line-length and target-version plus a select lint list. For mypy, set python_version and enable disallow_untyped_defs and warn_return_any for stricter checks.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational