Python에서 타입 힌트를 안 써도 되는데, 왜 쓰라고 하나요?
Type Hints를 쓰면 코드 품질이 크게 올라갑니다.
# 타입 힌트 없이def process(data, count): ...# 타입 힌트 있이def process(data: list[dict], count: int) -> dict: ...# 함수 시그니처만 봐도 사용법을 알 수 있음
장점:
실전 사용:
from typing import Optionaldef find_user(user_id: int) -> Optional[dict]: ...def send_email(to: list[str], subject: str, body: str) -> bool: ...
팀 프로젝트에서는 반드시, 개인 프로젝트에서도 습관 들이면 좋습니다.
댓글 1
Type Hints를 쓰면 코드 품질이 크게 올라갑니다.
장점:
실전 사용:
팀 프로젝트에서는 반드시, 개인 프로젝트에서도 습관 들이면 좋습니다.