Repository navigation
Releases
5.0.0rc1
The first release candidate of 5.0. pip install --pre jsonrpcclient installs
it. pip install jsonrpcclient keeps installing 4.x until 5.0.0.
Migration
lists every change with its replacement, and
#252 tracks the
release. 4.x gets fixes on the release/4.x branch.
Code that builds requests with request or notification, sends them, and
reads one response with parse or parse_json keeps working. A test pins
that.
Added
match_responses(batch, parse(reply))matches a batch's responses to its
requests by id and returns a dict in request order. It gives every request
the error when the server rejects the whole batch. It fills requests the
server couldn't read with their null-id errors. Anything it can't match
raisesInvalidResponse.parse(..., strict=True)andparse_json(..., strict=True)check the
JSON-RPC 2.0 rules the default skips. These are"jsonrpc": "2.0",
exactly one ofresultanderror, an interror.code, a str
error.message, and an id that's a string, a number or null.RequestandNotification,TypedDicts for whatrequestand
notificationreturn. At run time they're still plain dicts.
Changed
parseon a list, andparse_jsonon a JSON array, return alist
instead of a one-pass iterator. Every item is checked before they return,
and a bad item's message gives its index.next(parse(batch))no longer
works. Useparse(batch)[0].InvalidResponsesubclassesValueError, likejson.JSONDecodeError. It
no longer subclassesKeyErrorandTypeError, soexcept KeyErrorand
except TypeErrordon't catch it any more.request,notificationand their variants raiseTypeErrorwhen
methodisn't a str, orparamsisn't a list, tuple, dict or None. 4.x
sent the request anyway. A rejected request uses up no id.parse_json'sstrictkeyword is the new strict mode. 4.x passed it on to
json.loads.parse(json.loads(text, strict=False))does what it did.- The request functions are typed as returning
RequestorNotification,
notdict[str, Any]. mypy doesn't accept those wheredict[str, Any]is
expected. Annotate withRequest,NotificationorMapping[str, Any].
Removed
- Python 3.8, 3.9 and 3.10, which have reached end of life. 5.0 needs Python
3.11 or later. Older Pythons keep installing 4.x.
4.2.1
4.2.0
Warnings about what 5.0 changes, so an upgrade doesn't surprise you. Nothing
else changes. Each is a FutureWarning, which Python shows by default.
- A
methodthat isn't a string, orparamsthat aren't a list, tuple or
dict, warn. 4.x sends the request anyway. 5.0 raisesTypeError. This
coversrequest,notificationand their variants. parse_json(..., strict=...)warns. 4.x passesstricton to
json.loads. In 5.0 it turns on stricter checks of the response instead.
parse(json.loads(text, strict=False))keeps thejson.loadsoption.- Importing jsonrpcclient on Python 3.8, 3.9 or 3.10 warns once. 5.0 needs
Python 3.11 or later, and pip keeps installing 4.x on older Pythons.
Two more changes can't be detected at run time, so they don't warn. In 5.0
parse on a batch returns a list, not an iterator, so next(parse(batch))
stops working. And InvalidResponse stops subclassing KeyError and
TypeError. The
5.0 plan
lists everything that changes.
4.1.0
See Migration
for what to check when upgrading.
Changed
parseandparse_jsonnow raiseInvalidResponsefor an empty response
batch. They used to return an empty iterator and silently accept the invalid
reply.- If a response has both
resultanderror, anderroris not null,
parsenow returns anError. It used to returnOk(result=None)and drop
the server's error. JSON-RPC 2.0 doesn't allow both, but JSON-RPC 1.0 style
servers send"result": nullwith an error. - If a response has a
resultand a non-nullerrorthat isn't an object
withcodeandmessage(for example a string,falseor""),parse
now raisesInvalidResponse. 4.0 returnedOkand ignored the error. parse_jsonon JSON that isn't an object or array, such as"pong", used to
say "Use parse_json on strings". It now says it expected an object.parsegiven bytes now raises the same "Use parse_json on strings" error as
a str.notificationsends tuple params as a list, the same asrequestdoes.
The JSON output is unchanged, but the returned dict now holds a list.
Added
- Malformed responses now raise
InvalidResponsewith a message that says what
is wrong, for examplemissing 'id'. It subclassesKeyErrorand
TypeError, which earlier versions raised, so existingexceptclauses
still catch it.
Documentation
- The
parsedocstring now says that a batch gives a one-pass lazy iterator,
not a list. - New pages: an API reference generated from the docstrings, a migration
guide, and one page per transport. New guides cover notifications, batches,
ids, error handling, typing and threads.
4.0.4
This release fixes the links on the PyPI page. The 4.0.3 page linked to the
project's old website domain, which now belongs to someone else and serves a
gambling site. Issue #229 was closed when the link changed in this repository,
but PyPI kept showing the old link until a new release. With this release it is
really fixed (#229, #230). The links now point to
https://bensynapse.github.io/jsonrpcclient/ and
https://github.com/bensynapse/jsonrpcclient.
request_hex,request_randomandrequest_uuidare now safe to call from
several threads at once. Before, they could raiseValueError: generator already executing, and free-threaded Python could crash. The iterators from
jsonrpcclient.id_generatorsare thread-safe too.- Type hints:
paramsaccepts a list. The*_jsonfunctions returnstr, and
parsehas overloads, so a type checker knows a dict gives one response and
a list gives an iterator.parse_jsonused to be typed asAny. Code that
uses its result without anisinstancecheck now needs one to pass mypy. - Added
__version__. - Needs Python 3.8 or later (was 3.6). Tested on 3.8 to 3.14 and on
free-threaded 3.14. Older Pythons will keep installing 4.0.3. - The documentation moved to https://bensynapse.github.io/jsonrpcclient/.
- Releases now include both an sdist and a wheel. They are published from
GitHub Actions with build attestations.