Prompts-MCP 686 skills · ai / design / design-pattern / framework / fundamentals / habit / lang / tech-selection /mcp/sse
lang lang/python/typing/index.md medium

lang-python-typing-index

Python 类型注解规范

子项索引

子项 一句话
strict-annotations skill 函数签名 100% 类型注解 — 含返回类型
pydantic-v2-field skill Pydantic Field 必带 description + 约束(ge/le/max_length)
no-any skill 禁 Any — 必要时用 Union / TypeVar / 类型守卫
pep695-generics skill PEP 695 新泛型语法 def f[T] / class C[T] / type Alias,取代 TypeVar/Generic 样板
protocol-structural skill Protocol 结构化子类型 + runtime_checkable,按行为而非继承约定接口
typeddict-literal skill TypedDict/NotRequired/Required、Literal、Final、NewType、overload 精确建模字典与常量
type-narrowing skill TypeGuard/TypeIs 自定义窄化、Self 返回自身、assert_never 穷尽、Never/NoReturn
deferred-annotations skill PEP 649/749 注解延迟求值(3.14 默认),影响 pydantic/FastAPI/dataclasses 运行时反射