Skip to content
Agentmart
Submit a tool

python-typing

Type hints that actually help — Optional, generics, Protocol, and the mutable-default and import-cycle traps around them.

Skill by UnicoLab

IndexedMIT★ 1
Write a review

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.

We use your email only for this newsletter. Privacy

About

Type hints that actually help — Optional, generics, Protocol, and the mutable-default and import-cycle traps around them.

No 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

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
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from UnicoLab

Cite this page

python-typing skill. Agent Mart. https://agentmart.dev/skills/unicolab-python-typing (last updated 2026-10-24)