python-typing
Type hints that actually help — Optional, generics, Protocol, and the mutable-default and import-cycle traps around them.
Skill by UnicoLab
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/unicolab-python-typing
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/python-typing
What's inside
- Skill name
python-typing- Description
- Type hints that actually help — Optional, generics, Protocol, and the mutable-default and import-cycle traps around them.
- License
- MIT
- Instructions
- 47 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Python typing that pays for itself
```python
from __future__ import annotations # `list[int]` etc. on any 3.x
from dataclasses import dataclass, field
from typing import Protocol, Sequence
@dataclass(frozen=True, slots=True)
class Order:
id: int
items: list[str] = field(default_factory=list) # NOT `= []`
class Repo(Protocol): # structural: no base class needed
def get(self, order_id: int) -> Order | None: ...
def total(orders: Sequence[Order]) -> float: ... # accept, do not require list
```
## The traps
- **Mutable default arguments.** `def f(x=[])` / `={}` / `=set()` creates ONE
object shared by every call. Use `=None` and build the default in the body.
In a dataclass the equivalent is `field(default_factory=list)`.
- **`Optional` is not optional.** A function that can return `None` is
`-> Foo | None`. Annotating it `-> Foo` makes the type checker bless a
`NoneType has no attribute` crash.
- **Narrow before use.** `if x is None: return` at the top beats `x.y` guarded by
nothing; the checker follows the early return.
- **Accept the widest type you can use, return the narrowest you have.**
Parameters: `Sequence`, `Iterable`, `Mapping`. Returns: the concrete `list`.
- **`Any` disables checking** for everything it touches. `object` plus an
`isinstance` narrow is almost always what was meant.
- **Import cycles.** Types needed only for annotations go under
`if TYPE_CHECKING:` with `from __future__ import annotations` — that breaks the
cycle without a function-local import. If you must import inside a function,
leave a comment saying which cycle it breaks.
- **`==` vs `is`.** `is` for `None`, `True`, `False` and sentinels only.
- **Logging.** `logging.info("saved %s", oid)` — never an f-string; the f-string
formats even when the level is off and destroys structured logging.
## Verify
`mypy .` or `pyright`, then `ruff check .`. A type annotation the checker never
ran over is a comment.From UnicoLab/smlcode, MIT.
More from UnicoLab/smlcode
- 0.584score
hve-security-rai
UnicoLab
STRIDE threat modeling, OWASP/MCSB security planning, OpenSSF/SLSA supply chain hygiene, and NIST AI RMF Responsible AI.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
api-versioning
UnicoLab
HTTP API design and evolution — resource shapes, status codes, pagination, and how to change an API without breaking its clients.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
openshift-manifests
UnicoLab
OpenShift deployment specs that pass the restricted SCC on the first apply — kustomize base/overlays, probes, limits, secrets done safely, and how to explain…
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
pytest-fixtures
UnicoLab
pytest fixtures, parametrize, tmp_path and monkeypatch — the idioms that replace setUp boilerplate and shared mutable state.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
go-table-tests
UnicoLab
Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
dockerfile-hygiene
UnicoLab
Dockerfiles that build fast, stay small and do not run as root — layer ordering, multi-stage builds and the cache rules behind them.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
conventional-commits
UnicoLab
Commit and PR messages that survive a `git log` six months later — Conventional Commits, imperative subjects, and what belongs in the body.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-rpi
UnicoLab
Hypervelocity Engineering RPI loop (Research, Challenge, Plan, Implement, Review) with FAR rubric and uncertainty tracking.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
hve-ux-design
UnicoLab
Design Thinking (DFV) and UX architecture for user flows, component hierarchy, and interactive state matrices.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
go-concurrency
UnicoLab
Goroutine lifetime, context cancellation, channel direction and the mistakes that make Go concurrency leak or race.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
honest-verification
UnicoLab
Prove the objective was met, not merely that nothing is red — a suite that was already green is not evidence.
SkillAFreshness: A★ 1Claude Code +9 - 0.581score
hve-requirements
UnicoLab
BRD 3-phase discovery, PRD 7-phase specification, Epic/Story/Task decomposition, and Socratic ADR coaching.
SkillAFreshness: A★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 23, 2026 (2 months ago)
- Last release
- Oct 20, 2026 (9 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/UnicoLab/smlcode
- Website
- unicolab.github.io/smlcode/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from UnicoLab
- 0.584score
api-versioning
UnicoLab
HTTP API design and evolution — resource shapes, status codes, pagination, and how to change an API without breaking its clients.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-rpi
UnicoLab
Hypervelocity Engineering RPI loop (Research, Challenge, Plan, Implement, Review) with FAR rubric and uncertainty tracking.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
conventional-commits
UnicoLab
Commit and PR messages that survive a `git log` six months later — Conventional Commits, imperative subjects, and what belongs in the body.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
go-table-tests
UnicoLab
Write Go tests the standard way — table-driven subtests, t.Helper, t.Cleanup, and what to assert instead of reflect.DeepEqual.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
dockerfile-hygiene
UnicoLab
Dockerfiles that build fast, stay small and do not run as root — layer ordering, multi-stage builds and the cache rules behind them.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
hve-security-rai
UnicoLab
STRIDE threat modeling, OWASP/MCSB security planning, OpenSSF/SLSA supply chain hygiene, and NIST AI RMF Responsible AI.
SkillAFreshness: A★ 1Claude Code +9
Cite this page
python-typing skill. Agent Mart. https://agentmart.dev/skills/unicolab-python-typing (last updated 2026-10-24)