Skip to content

fix(typing): accept a built JsonValue in init_connection_params - #367

Open
Danipulok wants to merge 1 commit into
KurimuzonAkuma:devfrom
Danipulok:fix/init-connection-params-type
Open

fix(typing): accept a built JsonValue in init_connection_params#367
Danipulok wants to merge 1 commit into
KurimuzonAkuma:devfrom
Danipulok:fix/init-connection-params-type

Conversation

@Danipulok

Copy link
Copy Markdown
Contributor

What

Client(init_connection_params=...) is annotated Optional[dict], but a built JsonValue
works and is arguably the more direct thing to pass. session.py:195 converts only when the
value is a dict:

if isinstance(init_connection_params, dict):
    init_connection_params = utils.obj_to_jsonvalue(init_connection_params)

Anything else goes straight into InvokeWithLayer(..., params=init_connection_params). So a
caller who has already built a raw.types.JsonObject — because they wanted control over the
value types, or because they are forwarding one they received — passes it, it works, and
every type checker and IDE marks the call as wrong.

The change

The annotation, and the docstring line above it:

init_connection_params: Optional[Union[dict, "raw.base.JsonValue"]] = None,

No behaviour moves: the isinstance branch already draws exactly this distinction, and this
only writes down the half of it that was missing.

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.

1 participant