agentleFS
jscott3201jscott3201/yet-more-skills/skills/python-api-typing/SKILL.md

python-api-typing

Skill4 starsChanged 2 months agoApache-2.0View on GitHub

Design or review Python public APIs, typing, exceptions, and stubs. Use for semantic interface changes and SDK contracts, not formatter churn or native ownership alone.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep exception classes stable and actionable.

    line 17
  2. Distinctive:

    Run a small external consumer against the installed package and its installed type information.

    line 29
  3. Distinctive:

    Read API checks for mixed-language and domain examples.

    line 31

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python APIs and Typing

Begin with callers and the supported Python versions, not a preferred typing style. Follow the existing type checker and its settings; Ruff is not a substitute for type analysis. Avoid installing several checkers or migrating the whole repository for one change.

Design the contract

Make return shape, mutability, optionality, exceptions, sync/async behavior, and lifetime clear. Use Protocol for a useful structural seam, TypedDict for an appropriate mapping shape, and a dataclass or small class for behavior-bearing values. Type annotations do not validate runtime input. Use validation at the actual trust boundary; do not sprinkle casts or Any over a broken interface.

Distinguish missing values from explicit None and domain sentinels. Avoid mutable default arguments and mutable state accidentally shared between instances. A frozen dataclass is not deep immutability. Prefer accepting the narrowest useful behavioral interface without promising operations the implementation does not support. Document generator consumption, lazy errors, and one-shot resources.

Keep exception classes stable and actionable. Preserve causes when translating errors, avoid swallowing cancellation, and do not leak credentials in repr, logs, or diagnostic strings. Use explicit context-managed cleanup rather than relying on destructor timing.

Keep the shipped surface honest

Update Python source, extension signatures, docstrings,.pyi files, exports, examples, and tests together when their contract changes. A native method returning an asyncio Future is an Awaitable, not necessarily a coroutine accepted by create_task or asyncio.run. Represent that distinction in stubs and exercise it as a consumer.

Generated stubs are candidates for review, not authoritative semantics. Check keyword-only and positional parameters, defaults, exception behavior, overloads, nullability, submodule imports, and context-manager methods. inspect.signature is not available for every native symbol; absence is not proof of a broken method. Use actual calls plus the configured checker.

Type syntax must parse on the supported floor, including distributed stubs. Do not adopt newer generic syntax or standard-library helpers merely because the author's interpreter supports them. Review runtime annotation consumers before changing annotation evaluation or moving imports behind TYPE_CHECKING.

Evidence

Run a small external consumer against the installed package and its installed type information. Include at least one rejected invalid use and one accepted intended use. Keep expected-error annotations narrow; never silence the whole module to get a pass. Report runtime and static results separately.

Read API checks for mixed-language and domain examples.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.