python-type-narrowing
OfficialMaster Python's type narrowing techniques.
Authorflext-sh
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill addresses the complexity of writing precise conditional logic in Python, ensuring type safety and clarity when dealing with union types, optional values, and discriminated unions.
Core Features & Use Cases
- Conditional Type Logic: Safely handle variables that can be one of several types using
isinstance,TypeIs, andTypeGuard. - Exhaustiveness Checking: Guarantee that all possible cases of a union type are handled in
matchstatements orif-elsechains usingassert_never. - Use Case: When processing a
FlextResultobject that could be either a success or a failure, use type narrowing to apply specific operations only to the success payload, preventing runtime errors.
Quick Start
Use the python-type-narrowing skill to demonstrate how to use TypeIs for discriminated union narrowing.
Dependency Matrix
Required Modules
None requiredComponents
referencesrules
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: python-type-narrowing Download link: https://github.com/flext-sh/flext/archive/main.zip#python-type-narrowing Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.