This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Improve type hints relating to query parameters #12411
Labels
T-Task
Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
The regression fixed by #12410 was not spotted because we annotated
args
as aDict[str, Any]
but then addedargs["limit"]
as anint
. This is fine becauseint
is a subtype ofAny
.synapse/synapse/federation/transport/client.py
Lines 506 to 519 in 1a90c1e
We pass args to
get_json
, which expectsargs: Optional[QueryArgs]
, which is:synapse/synapse/http/matrixfederationclient.py
Line 102 in bc9dff1
This isn't found by mypy because
args: Dict[str, Any]
means that we do no typechecking of the values in args.All functions which accept
args: QueryArgs
forward args as thequery
attribute ofMatrixFederationRequest
. That attribute is typed more weakly asDict[Any, Any]
.synapse/synapse/http/matrixfederationclient.py
Lines 147 to 149 in bc9dff1
The
query
attribute is seems to only ever be passed toencode_query_args
. That expects a type similar toQueryArgs
, and converts its argument list in a form that can be passed tourlencode
.synapse/synapse/http/client.py
Lines 914 to 935 in a121507
We also have a
QueryParams
type elsewhere, which again is only forwarded to or passed tourlencode
.synapse/synapse/http/client.py
Lines 100 to 102 in a121507
I would like to see:
MatrixFederationRequest.params
QueryArgs
andQueryParams
MatrixFederationRequest
The text was updated successfully, but these errors were encountered: