Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ meets the schema**. Feel the difference yourself.

**First, experience editor autocomplete.** Open
[`examples/explore_platform.py`](examples/explore_platform.py) in VS Code (the Codespace
ships Pylance). Find the `# platform.` line, delete the `#`, put your cursor right after the
dot, and type: VS Code pops up the object's *declared* attributes (`radiated_noise`,
`sensors`, …) — statically, before the code has even run. Keep drilling
ships Pylance). Find the `# platform.radiated_noise.` line, delete the `#`, put your cursor
right after the dot, and type: VS Code pops up the object's *declared* attributes
(`band`, …) — statically, before the code has even run. Try `platform.` too for the
top-level attributes (`radiated_noise`, `sensors`, …). Keep drilling
(`platform.radiated_noise.band[0].`) and it completes all the way down. That instant,
schema-shaped autocomplete is the real payoff of declared fields. Run the file any time with:

Expand Down
9 changes: 7 additions & 2 deletions examples/explore_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
# its type from the function's return annotation — no need to run anything first.
platform = build.build_platform_from_file("examples/calculation_input.xml")

# `radiated_noise` is Optional on the schema (it may be absent), so the type checker treats
# it as possibly-None. The pipeline's gates guarantee it is populated here; this assert tells
# Pylance the same thing — after it, `.band` is a clean, fully-typed access (no squiggle).
assert platform.radiated_noise is not None

# TODO: put your cursor at the end of the next line, after the dot, and type.
# VS Code should pop up the declared attributes (radiated_noise, sensors, ...).
# VS Code should pop up the declared attributes (band, ...).
# Keep drilling — `platform.radiated_noise.band[0].` completes too, all the way down.
# platform.
# platform.radiated_noise.

# A couple of fully-typed accesses to confirm it ran (delete or extend these freely):
print("type:", type(platform).__name__)
Expand Down
Loading