python-type-hints

Guide Python type hint adoption with generics, Protocols, TypedDict, and TypeGuard.

Updated Aug 29, 2025
One-click install
npx skills add https://github.com/DDTully/dotfiles --skill python-type-hints-ddtully
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-type-hints
Source: https://github.com/DDTully/dotfiles/tree/main/skills/.agent_skills/python-type-hints
Command: npx skills add https://github.com/DDTully/dotfiles --skill python-type-hints-ddtully

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Python type hints enable static checking but many projects struggle to adopt advanced typing patterns safely. This skill provides a comprehensive guide and ready-to-use patterns for built-in generics, unions, protocols, TypedDict, and more to improve code reliability and maintainability.

Core Features & Use Cases

  • Advanced typing techniques: built-in generics, Union, Protocols, TypedDict, Literal, Final, TypeGuard, TypeIs, ParamSpec, Self, and recursive types.
  • Configurable type checking: guidance for Mypy and Pyright, with example configurations and workflows.
  • Practical patterns: repository patterns, discriminated unions, builder patterns, and type-safe decorators for real-world Python apps.

Quick Start

Analyze a Python module by adding type hints and run your chosen type checker to see improvements.

Frequently Asked Questions about python-type-hints

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

FAQPage Schema
How do I use Protocols and TypedDict for structural typing in Python?

Python type hints enable structural typing by using Protocols to define implicit interfaces and TypedDict to type dictionaries with specific key-value schemas. This skill provides ready-to-use patterns for both to improve code reliability and maintainability.

What is the best way to configure mypy and pyright for static type checking?

Static type checking with mypy and pyright is best configured using the example workflows and settings provided by this skill. It offers guidance to safely adopt advanced typing patterns and run checks across Python projects of varying sizes.

How do I create type-safe decorators using ParamSpec and TypeGuard?

Type-safe decorators in Python utilize ParamSpec to preserve function signatures and TypeGuard to narrow types dynamically. This skill supplies practical patterns for implementing these advanced typing features in real-world applications.

Can I use Python type hints for discriminated unions and recursive types?

Python type hints support discriminated unions to distinguish complex object variants and recursive types for self-referencing data structures. This skill delivers comprehensive guidance on applying these advanced techniques safely across your codebase.

Does this typing guidance work for large Python codebases?

Typing guidance in this skill is explicitly designed for Python codebases of varying sizes. It supports scalable static type checking through practical repository patterns, builder patterns, and configurable mypy or pyright integration.