docs: expand Python typing guide with real-world protocol examples

Merged
ID
4mo ago
+26-1

Summary

Enrich the Python SDK "Strict Typing in Python" guide. The page already documents the protocols mechanics; this adds the real-world usage and the "keep protocols in sync" framing that were missing.

Key changes

  • Overview: rewrote the opener as a capability lead (removed "This guide explains…").
  • New subsection — "Using protocols in generators and transforms": a multi-kind example (client.filters(kind=NetworkDevice, …) with a list[NetworkDevice] type hint) showing where protocols matter most.
  • New subsection — "Keep protocols in sync with your schema": the generated file is a build artifact; regenerate on schema change; the type checker surfaces drift at development time.

What needs reviewer attention

  • The two new subsections in docs/docs/python-sdk/guides/python-typing.mdx (all other lines unchanged). New prose only; the example uses documented SDK APIs.

What didn't change

  • All existing content preserved; no factual claims altered.
  • The infrahubctl protocols reference page is auto-generated — untouched.

Out of scope (deferred)

  • Voice cleanup of the "Generating Pydantic models from GraphQL queries" section (stacked-benefit bullets + "excellent type safety") — pre-existing prose, not in a section this PR touches. Fix in a follow-up if desired.

Test plan

  • cd docs && npm run build succeeds
  • Vale: 0 errors/warnings on the changed file

Summary by cubic

Expand the Python SDK typing guide with real-world Protocol usage to catch schema mismatches before runtime, add a generator/transform example using client.filters(kind=NetworkDevice, ...) that infers list[NetworkDevice] (no redundant annotation), document regenerating protocols with infrahubctl protocols, and update the overview to lead with capability.