Skip to content

Add Patch-style partial reads to WebSocket get_prop - #3977

Open
CNFeffery wants to merge 6 commits into
plotly:devfrom
CNFeffery:feat/3975-get-prop-path
Open

Add Patch-style partial reads to WebSocket get_prop#3977
CNFeffery wants to merge 6 commits into
plotly:devfrom
CNFeffery:feat/3975-get-prop-path

Conversation

@CNFeffery

@CNFeffery CNFeffery commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This PR adds optional Patch-style partial reads to WebSocket get_prop().

  • Add a keyword-only path argument that accepts string keys and integer list indices, including negative indices.
  • Resolve the selected value client-side before WebSocket serialization, while preserving existing full-property reads when path is omitted, None, or [].
  • Return None for missing or structurally incompatible locations; reject malformed path arguments before sending a request.
  • Add unit and WebSocket integration coverage, and document the API in the architecture guide.

Usage examples

# Existing behavior: read the complete property.
data = await ws.get_prop("store", "data")

# Read a nested object value.
value = await ws.get_prop(
    "store", "data", path=["event", "target", "value"]
)

# Read a list item by its zero-based index.
first_value = await ws.get_prop(
    "store", "data", path=["records", 0, "value"]
)

# Read from a list; negative indices count from the end.
last_value = await ws.get_prop(
    "store", "data", path=["records", -1, "value"]
)

# A string key is not coerced to a list index, so this returns None.
not_found = await ws.get_prop(
    "store", "data", path=["records", "0"]
)
assert not_found is None

# An explicit empty path is also a full-property read.
data = await ws.get_prop("store", "data", path=[])

path accepts string dictionary keys and integer list indices. A returned
None may represent a real null value, a missing location, or a
structurally incompatible path. Object keys must be strings and list indices
must be integers (so "0" is not coerced to 0); malformed path arguments
raise before a request is sent.

Closes #3975

@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support Patch-style partial reads in WebSocket get_prop()

1 participant