Skip to content

Releases

5.0.0rc1

5.0.0rc1 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 06 Nov 03:54
54df2c2

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
    raises InvalidResponse.
  • parse(..., strict=True) and parse_json(..., strict=True) check the
    JSON-RPC 2.0 rules the default skips. These are "jsonrpc": "2.0",
    exactly one of result and error, an int error.code, a str
    error.message, and an id that's a string, a number or null.
  • Request and Notification, TypedDicts for what request and
    notification return. At run time they're still plain dicts.

Changed

  • parse on a list, and parse_json on a JSON array, return a list
    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. Use parse(batch)[0].
  • InvalidResponse subclasses ValueError, like json.JSONDecodeError. It
    no longer subclasses KeyError and TypeError, so except KeyError and
    except TypeError don't catch it any more.
  • request, notification and their variants raise TypeError when
    method isn't a str, or params isn't a list, tuple, dict or None. 4.x
    sent the request anyway. A rejected request uses up no id.
  • parse_json's strict keyword 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 Request or Notification,
    not dict[str, Any]. mypy doesn't accept those where dict[str, Any] is
    expected. Annotate with Request, Notification or Mapping[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

Choose a tag to compare

@github-actions github-actions released this 06 Nov 04:10
0de0775
  • Importing jsonrpcclient on Python 3.8, 3.9 or 3.10 no longer warns. pip
    already keeps those Pythons on 4.x, so the warning asked for nothing. It
    also broke test suites that turn warnings into errors.

4.2.0

Choose a tag to compare

@github-actions github-actions released this 06 Nov 03:29
d1f3fd0

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 method that isn't a string, or params that aren't a list, tuple or
    dict, warn. 4.x sends the request anyway. 5.0 raises TypeError. This
    covers request, notification and their variants.
  • parse_json(..., strict=...) warns. 4.x passes strict on to
    json.loads. In 5.0 it turns on stricter checks of the response instead.
    parse(json.loads(text, strict=False)) keeps the json.loads option.
  • 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

Choose a tag to compare

@github-actions github-actions released this 06 Nov 00:29
403603e

See Migration
for what to check when upgrading.

Changed

  • parse and parse_json now raise InvalidResponse for an empty response
    batch. They used to return an empty iterator and silently accept the invalid
    reply.
  • If a response has both result and error, and error is not null,
    parse now returns an Error. It used to return Ok(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": null with an error.
  • If a response has a result and a non-null error that isn't an object
    with code and message (for example a string, false or ""), parse
    now raises InvalidResponse. 4.0 returned Ok and ignored the error.
  • parse_json on 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.
  • parse given bytes now raises the same "Use parse_json on strings" error as
    a str.
  • notification sends tuple params as a list, the same as request does.
    The JSON output is unchanged, but the returned dict now holds a list.

Added

  • Malformed responses now raise InvalidResponse with a message that says what
    is wrong, for example missing 'id'. It subclasses KeyError and
    TypeError, which earlier versions raised, so existing except clauses
    still catch it.

Documentation

  • The parse docstring 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

Choose a tag to compare

@github-actions github-actions released this 06 Nov 00:18

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_random and request_uuid are now safe to call from
    several threads at once. Before, they could raise ValueError: generator already executing, and free-threaded Python could crash. The iterators from
    jsonrpcclient.id_generators are thread-safe too.
  • Type hints: params accepts a list. The *_json functions return str, and
    parse has overloads, so a type checker knows a dict gives one response and
    a list gives an iterator. parse_json used to be typed as Any. Code that
    uses its result without an isinstance check 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.