Repository navigation
6.0.0rc1
Pre-releaseThe first release candidate of 6.0. pip install --pre jsonrpcserver installs
it. pip install jsonrpcserver keeps installing 5.x until 6.0.0.
Migration
lists what changes, and #320
tracks the release. 5.x gets fixes on the release/5.x branch.
Added
max_concurrencyonasync_dispatchand the other async dispatch functions:
the most requests of a batch that run at once. The default, None, runs them
all at once, as before.
Changed
-
jsonrpcserver no longer uses oslash.
Successreturns aSuccessResult,
andErrorandInvalidParamsreturn anErrorResult. Both are frozen
dataclasses, andResultisSuccessResult | ErrorResult. Code that only
returnsSuccess(...)orError(...)from methods and callsdispatch
keeps working. -
dispatch_to_responsegivesSuccessResponseandErrorResponseobjects,
frozen dataclasses with the response's fields. 5.x wrapped them in oslash's
RightandLeft, read through_valueand_error. Check
isinstance(response, ErrorResponse)instead. -
Removed
InvalidResultError,validate_resultandlog_invalid_resultfrom
jsonrpcserver.dispatcher. Without the oslash wrappers there's no invalid
Result: a method's return value is its result. -
The default validator checks the JSON-RPC 2.0 rules itself instead of using
jsonschema. It accepts and rejects the same requests, which a test checks on
500 generated requests and a list of edge cases. Dispatching a small method
takes about 9.6 microseconds instead of 43 (Python 3.13). Its error is
jsonrpcserver.validator.InvalidRequestError, with a message that says what's
wrong. The client still gets the same -32600 response. -
Batches are limited to 100 requests by default (
max_batch_size). A bigger
batch gets one -32600 error, and none of it runs. Passmax_batch_size=None
for no limit, as in 5.x. -
The default deserializer rejects
NaN,Infinity,-Infinityand numbers
too big for a float, with a -32700 Parse error. They aren't valid JSON.
deserializer=json.loadsaccepts them, as in 5.x.dispatch_to_response
now uses the same default as the other dispatch functions. -
ErrorandJsonRpcErrorraiseTypeErrorfor a code that isn't an int or
a message that isn't a str.@methodraisesValueErrorfor a name starting
withrpc.. 5.0.10 warned about both. -
serve()listens on localhost unless you pass a host. 5.x listened on every
network interface by default.serve("", port)does that now. -
The sync and async dispatch functions take the same options with the same
defaults. A test keeps them that way.
Removed
serialize_error,serialize_successandto_serializable_onein
jsonrpcserver.response(andto_serializable_oneinjsonrpcserver.main),
deprecated in 5.0.10. Useto_error_dict,to_success_dictandto_dict.ResponseType. UseResponse.- The jsonschema dependency, and
jsonrpcserver/request-schema.json. 6.0 has no
runtime dependencies. - The oslash dependency, and with it the mypy setting
typing.mdasked for. - Python 3.8, 3.9 and 3.10, which have reached end of life. 6.0 needs Python
3.11 or later. Older Pythons keep installing 5.x.