Skip to content

Commit 581d30e

Browse files
committed
docs: drop redundant type annotation in filters() protocol example
1 parent 13b589c commit 581d30e

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

docs/docs/python-sdk/guides/python-typing.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ Protocols make the most difference in generators, transforms, and checks, where
109109
```python
110110
from .protocols import NetworkDevice
111111

112-
# `kind` is the generated class, not a string, so attributes are type-checked
113-
leaf_switches: list[NetworkDevice] = await client.filters(
114-
kind=NetworkDevice, role__value="leaf", include=["interfaces"]
115-
)
112+
# Passing the generated class as `kind` makes `filters()` return `list[NetworkDevice]`,
113+
# so `switch` is fully typed without annotating the variable yourself
114+
leaf_switches = await client.filters(kind=NetworkDevice, role__value="leaf", include=["interfaces"])
116115

117116
for switch in leaf_switches:
118117
switch.name.value # autocompleted, and checked against the schema

0 commit comments

Comments
 (0)