Skip to content
Back to skills

Typehint

ASecurity

- Python 3.10+用内置类型(list[str], dict[str, int], str | None),低版本用typing模块 - Optional[X]等价于X | None,表示可能为None,不表示"可选参数" - 函数签名:所有公开函数标注参数类型和返回类型,内部函数可省略 - 泛型:TypeVar定义类型变量,Generic[T]创建泛型类,bound限制上界 - Protocol:结构化子类型(鸭子类型的静态版),定义接口不需要继承 - TypedDict:字典的精确类型,每个key有独立类型,total=False允许可选key - Literal:限制值为几个字面量之一,如Literal["read", "write"] - Callable[[参数类型], 返回类型]标注回调函数,参数多时用Protocol替代 - overload装饰器:同一函数不同参数组合返回不同类型时使用 - TYPE_CHECKING:避免运行时循环导入,仅在类型检查时导入

  • 687 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 5, 2026
toolspython

Security analysis

A100/100

Scanned June 5, 2026

npx -y skills add val1813/kwcode --skill typehint --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Typehint?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Typehint
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/val1813-typehint/badge)](https://www.skillsdirectory.com/skills/val1813-typehint)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: TypeHintExpert
version: 1.0.0
trigger_keywords: [类型注解, type hint, typing, 类型标注, mypy]
trigger_min_confidence: 0.7
pipeline: [locator, generator]
lifecycle: mature
---

## 领域知识

- Python 3.10+用内置类型(list[str], dict[str, int], str | None),低版本用typing模块
- Optional[X]等价于X | None,表示可能为None,不表示"可选参数"
- 函数签名:所有公开函数标注参数类型和返回类型,内部函数可省略
- 泛型:TypeVar定义类型变量,Generic[T]创建泛型类,bound限制上界
- Protocol:结构化子类型(鸭子类型的静态版),定义接口不需要继承
- TypedDict:字典的精确类型,每个key有独立类型,total=False允许可选key
- Literal:限制值为几个字面量之一,如Literal["read", "write"]
- Callable[[参数类型], 返回类型]标注回调函数,参数多时用Protocol替代
- overload装饰器:同一函数不同参数组合返回不同类型时使用
- TYPE_CHECKING:避免运行时循环导入,仅在类型检查时导入

## 经验规则(自动生成)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…