python-typing

Defines type hint conventions, mypy strict configuration, generics, and Protocol patterns for Python projects.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/chris-prener/dev-kit --skill python-typing-chris-prener
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-typing
Source: https://github.com/chris-prener/dev-kit/tree/main/dev-kit/skills/python-typing
Command: npx skills add https://github.com/chris-prener/dev-kit --skill python-typing-chris-prener

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Python codebases without consistent type annotations accumulate hidden bugs, unclear interfaces, and tooling gaps. This Skill establishes a complete static typing discipline — annotation conventions, mypy strict-mode configuration, generics, Protocols, and library packaging — so type errors are caught at development time instead of in production. ## Core Features & Use Cases - Annotation Conventions: Enforces fully typed public interfaces using modern PEP 604 syntax (str | None, list[int]) instead of legacy typing module forms. - mypy Strict Configuration: Provides a pyproject.toml setup with strict = true, per-module overrides for untyped libraries, and CI commands via uv run mypy src. - Generics and Protocols: Shows how to build typed generic classes (including Python 3.12 native syntax) and use Protocol for structural typing without inheritance. - Library Packaging: Covers the py.typed marker so published packages expose their types to consumers' type checkers. - Use Case: You inherit an untyped Python service. Use this Skill to annotate the public API, enable mypy strict mode in CI, and replace ad-hoc isinstance checks with pydantic validation at trust boundaries. ## Quick Start Add type hints to my Python module and configure mypy strict mode in pyproject.toml.

Frequently Asked Questions about python-typing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure mypy strict mode in pyproject.toml?▼

Add a [tool.mypy] section with python_version, strict = true, files pointing at your source directory, and warn_unused_ignores enabled. Use [[tool.mypy.overrides]] blocks with ignore_missing_imports for third-party libraries that lack type stubs.

Should I use mypy or pyright for Python type checking?▼

Use mypy as the CI gate of record with configuration in pyproject.toml, and pyright (via Pylance) as a faster editor-time supplement. If the two disagree, the mypy configuration is authoritative and both should be kept consistent.

When should I use Protocol instead of an abstract base class in Python?▼

Use Protocol when you want structural typing — accepting any object with the required methods without forcing inheritance. For example, a SupportsToParquet Protocol accepts both polars and pandas DataFrames without either inheriting from a shared base class.

Do Python type hints validate data at runtime?▼

No, type hints are erased at runtime and only checked statically by mypy or pyright. For runtime validation of external input like API payloads or config files, use pydantic or pandera at trust boundaries instead of isinstance checks.

Why do consumers see my typed package as untyped?▼

Type checkers treat installed packages as untyped unless the package ships an empty py.typed marker file in its package directory. Add py.typed to your source package and ensure your build backend includes it in the wheel.