현대적인 Python 타입 힌트, Protocol을 활용한 구조적 타이핑, 그리고 견고한 코드를 위한 타입 안전성 패턴을 구현합니다.
- GitHub 스타
- 81
- 파일
- 9
- 마지막 커밋
- 2026년 11월 7일
- 라이선스
- MIT
- 허용된 도구
- 2
python-typing-ops skill은 무엇을 하나요?
python-typing-ops은(는) agent skill입니다. 현대적인 Python 타입 힌트, Protocol을 활용한 구조적 타이핑, 그리고 견고한 코드를 위한 타입 안전성 패턴을 구현합니다.
skill의 SKILL.md에서 생성된 요약입니다.
python-typing-ops skill 정보
이 SKILL은 안전하고 문서화가 잘 된 코드베이스를 구축하는 개발자가 현대적인 Python 타입 힌트와 구조적 타이핑 패턴을 구현할 수 있도록 지원합니다. 타입 어노테이션, 제네릭, 그리고 Protocol을 통한 구조적 타이핑을 적용하여 코드 신뢰성을 확보할 수 있는 포괄적인 도구 세트를 제공합니다. 에이전트가 이 SKILL을 로드하면 TypeVar, TypedDict, Literal 타입과 같은 고급 기능을 사용하여 코드를 생성하거나 리팩터링할 수 있습니다.
이 SKILL은 유니온 타입을 포함한 Python 3.10+ 문법을 지원하며, Self 및 TypeVarTuple과 같은 Python 3.11+ 전용 패턴도 지원합니다. 또한 mypy 및 pyright와 같은 타입 체커를 설정하고 실행하여 코드 무결성을 검증하는 데 도움을 줍니다. 이러한 패턴을 활용하면 개발자는 기본적인 어노테이션을 넘어 타입 좁히기를 위한 TypeGuards나 유연한 인터페이스 정의를 위한 구조적 타이핑과 같은 복잡한 로직을 구현할 수 있습니다. 이는 정적 분석을 통해 런타임 에러를 줄이고자 하는 모든 이에게 필수적인 도구입니다.
agent가 수행할 수 있는 작업
- 1구조적 타이핑 구현Protocol을 정의하여 특정 메서드를 가진 모든 객체가 함수에 전달될 수 있도록 합니다.
- 2고정 키 딕셔너리 정의TypedDict를 생성하여 딕셔너리 접근 시 특정 타입 안전 키를 사용하도록 보장합니다.
- 3타입 체커를 통한 코드 검증mypy 또는 pyright 명령을 실행하여 소스 디렉토리의 타입 에러를 확인합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
python-typing-ops skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.플러그인에 python-typing-ops skill 설치
/plugin marketplace add 0xDarkMatter/claude-mods /plugin install claude-mods@claude-mods
Claude Code에 python-typing-ops skill 설치
~/.claude/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.claude/skills/python-typing-opsClaude Code (project)에 python-typing-ops skill 설치
.claude/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops .claude/skills/python-typing-opsCodex에 python-typing-ops skill 설치
~/.agents/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.agents/skills/python-typing-opsGemini CLI에 python-typing-ops skill 설치
~/.gemini/skills/python-typing-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.gemini/skills/python-typing-opsClaude.ai에 python-typing-ops skill 설치
npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops python-typing-ops && zip -r python-typing-ops.zip python-typing-ops # claude.ai → Customize → Skills → + → Create skill → Upload a skill → python-typing-ops.zip
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →자동 검사를 통과했습니다. 보안 감사는 아닙니다. 에이전트가 실행하기 전에 스크립트를 읽어 보세요. 검사 방식
- 소스 저장소 연결 및 접근 가능0xdarkmatter/claude-mods/skills/python-typing-ops is public and reachablegithub.com/0xdarkmatter/claude-mods/tree/HEAD/skills/python- ↗통과
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit 2026-11-07github.com/0xdarkmatter/claude-mods/commits ↗통과
- 스크립트에 다운로드 후 실행이나 자격 증명 탈취가 없음1 script read; no download-and-run, remote eval, base64 execution or credential upload통과
- SKILL.md에 숨겨진 지침 없음No override phrases, safeguard switches, credential requests or hidden charactersgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗통과
- 사전 허용 도구가 제한됨Pre-approved: Read, Writegithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗통과
SKILL.md
GitHub에서 보기Python Typing Patterns
Modern type hints for safe, documented Python code.
Basic Annotations
# Variables
name: str = "Alice"
count: int = 42
items: list[str] = ["a", "b"]
mapping: dict[str, int] = {"key": 1}
# Function signatures
def greet(name: str, times: int = 1) -> str:
return f"Hello, {name}!" * times
# None handling
def find(id: int) -> str | None:
return db.get(id) # May return None
Collections
from collections.abc import Sequence, Mapping, Iterable
# Use collection ABCs for flexibility
def process(items: Sequence[str]) -> list[str]:
"""Accepts list, tuple, or any sequence."""
return [item.upper() for item in items]
def lookup(data: Mapping[str, int], key: str) -> int:
"""Accepts dict or any mapping."""
return data.get(key, 0)
# Nested types
Matrix = list[list[float]]
Config = dict[str, str | int | bool]
Optional and Union
# Modern syntax (3.10+)
def find(id: int) -> User | None:
pass
def parse(value: str | int | float) -> str:
pass
# With default None
def fetch(url: str, timeout: float | None = None) -> bytes:
pass
TypedDict
from typing import TypedDict, Required, NotRequired
class UserDict(TypedDict):
id: int
name: str
email: str | None
class ConfigDict(TypedDict, total=False): # All optional
debug: bool
log_level: str
class APIResponse(TypedDict):
data: Required[list[dict]]
error: NotRequired[str]
def process_user(user: UserDict) -> str:
return user["name"] # Type-safe key access
Callable
from collections.abc import Callable
# Function type
Handler = Callable[[str, int], bool]
def register(callback: Callable[[str], None]) -> None:
pass
# With keyword args (use Protocol instead)
from typing import Protocol
class Processor(Protocol):
def __call__(self, data: str, *, verbose: bool = False) -> int:
...
Generics
from typing import TypeVar
T = TypeVar("T")
def first(items: list[T]) -> T | None:
return items[0] if items else None
# Bounded TypeVar
from typing import SupportsFloat
N = TypeVar("N", bound=SupportsFloat)
def average(values: list[N]) -> float:
return sum(float(v) for v in values) / len(values)
Protocol (Structural Typing)
from typing import Protocol
class Readable(Protocol):
def read(self, n: int = -1) -> bytes:
...
def load(source: Readable) -> dict:
"""Accepts any object with read() method."""
data = source.read()
return json.loads(data)
# Works with file, BytesIO, custom classes
load(open("data.json", "rb"))
load(io.BytesIO(b"{}"))
Type Guards
from typing import TypeGuard
def is_string_list(val: list[object]) -> TypeGuard[list[str]]:
return all(isinstance(x, str) for x in val)
def process(items: list[object]) -> None:
if is_string_list(items):
# items is now list[str]
print(", ".join(items))
Literal and Final
from typing import Literal, Final
Mode = Literal["read", "write", "append"]
def open_file(path: str, mode: Mode) -> None:
pass
# Constants
MAX_SIZE: Final = 1024
API_VERSION: Final[str] = "v2"
Quick Reference
| Type | Use Case |
|---|---|
X | None |
Optional value |
list[T] |
Homogeneous list |
dict[K, V] |
Dictionary |
Callable[[Args], Ret] |
Function type |
TypeVar("T") |
Generic parameter |
Protocol |
Structural typing |
TypedDict |
Dict with fixed keys |
Literal["a", "b"] |
Specific values only |
Final |
Cannot be reassigned |
Type Checker Commands
# mypy (run inside the project env)
uv run mypy src/ --strict
# pyright
uv run pyright src/
# In pyproject.toml
[tool.mypy]
strict = true
python_version = "3.11"
Emerging: ty — Astral's Rust-based type checker (same toolchain as uv +
ruff), dramatically faster than mypy. Still in preview (pre-1.0), so mypy or
pyright remain the production default — but worth watching, and easy to try:
uvx ty check. Adopt for new projects once it stabilizes.
Additional Resources
./references/generics-advanced.md- TypeVar, ParamSpec, TypeVarTuple./references/protocols-patterns.md- Structural typing, runtime protocols./references/type-narrowing.md- Guards, isinstance, assert./references/mypy-config.md- mypy/pyright configuration./references/runtime-validation.md- Pydantic v2, typeguard, beartype./references/overloads.md- @overload decorator patterns
Scripts
./scripts/check-types.sh- Run type checkers with common options
Assets
./assets/pyproject-typing.toml- Recommended mypy/pyright config
See Also
This is a foundation skill with no prerequisites.
Related Skills:
python-pytest-ops- Type-safe fixtures and mocking
Build on this skill:
python-async-ops- Async type annotationspython-fastapi-ops- Pydantic models and validationpython-database-ops- SQLAlchemy type annotations
이 스킬의 파일
9python-typing-ops skill 질문
Claude Code에 python-typing-ops skill을 어떻게 설치하나요?
npx degit 0xDarkMatter/claude-mods/skills/python-typing-ops ~/.claude/skills/python-typing-ops를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
python-typing-ops skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
이 패턴들을 사용하려면 어떤 Python 버전이 필요한가요?
이 패턴들은 Python 3.10+ 문법(X | Y 유니온 문법 등)을 사용하며, Self 또는 TypeVarTuple과 같은 특정 패턴은 Python 3.11+ 버전이 필요합니다.
프로젝트에서 타입 체커를 어떻게 실행할 수 있나요?
uv를 통해 mypy 또는 pyright를 사용할 수 있습니다. 예: 'uv run mypy src/ --strict' 또는 'uv run pyright src/'.
함수 타입에 사용하는 Callable과 Protocol의 차이점은 무엇인가요?
Callable은 단순한 함수 타입에 사용하며, 키워드 인자를 지정해야 하는 경우에는 Protocol을 사용합니다.