From 21ed6c2b8b015dd0cc8cce62df4cad52aa839263 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Sun, 10 Dec 2023 12:10:32 -0800 Subject: [PATCH] release v0.5 --- README.md | 10 ++++++++++ docs/conf.py | 4 ++-- docs/index.rst | 31 ++++++++++++++++++++++++++----- lexrpc/client.py | 3 +++ pyproject.toml | 2 +- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9f442cd..2a88fa5 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ output = client.com.example.my_procedure({'foo': 'bar'}, baz=5) Note that `-` characters in method NSIDs are converted to `_`s, eg the call above is for the method `com.example.my-procedure`. +To call a method with non-JSON (eg binary) input, pass `bytes` to the call instead of a `dict`, and pass the content type with `headers={'Content-Type': '...'}`. + [Event stream methods](https://atproto.com/specs/event-stream) with type `subscription` are generators that `yield` (header, payload) tuples sent by the server. They take parameters as kwargs, but no positional `input`. ```py @@ -228,6 +230,14 @@ Here's how to package, test, and ship a new release. ## Changelog +### 0.5 - 2023-12-10 + +* `Client`: + * Support binary request data automatically based on input type, eg `dict` vs `bytes`. + * Add new `headers` kwarg to `call` and auto-generated lexicon method calls, useful for providing an explicit `Content-Type` when sending binary data. + * Bug fix: don't infinite loop if `refreshSession` fails. + * Other minor authentication bug fixes. + ### 0.4 - 2023-10-28 * Bundle [the official lexicons](https://github.com/bluesky-social/atproto/tree/main/lexicons/) for `app.bsky` and `com.atproto`, use them by default. diff --git a/docs/conf.py b/docs/conf.py index 7c65324..ebd9b20 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -88,9 +88,9 @@ # built documents. # # The short X.Y version. -version = '0.4' +version = '0.5' # The full version, including alpha/beta/rc tags. -release = '0.4' +release = '0.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index c5256a9..c15451b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -13,7 +13,9 @@ schemas. Install from `PyPI `__ with ``pip install lexrpc`` or ``pip install lexrpc[flask]``. -License: This project is placed in the public domain. +License: This project is placed in the public domain. You may also use +it under the `CC0 +License `__. - `Client <#client>`__ - `Server <#server>`__ @@ -71,6 +73,10 @@ or use custom lexicons by passing them to the ``Client`` constructor: Note that ``-`` characters in method NSIDs are converted to ``_``\ s, eg the call above is for the method ``com.example.my-procedure``. +To call a method with non-JSON (eg binary) input, pass ``bytes`` to the +call instead of a ``dict``, and pass the content type with +``headers={'Content-Type': '...'}``. + `Event stream methods `__ with type ``subscription`` are generators that ``yield`` (header, payload) tuples sent by the server. They take parameters as kwargs, but no @@ -315,6 +321,21 @@ Here’s how to package, test, and ship a new release. Changelog --------- +0.5 - 2023-12-10 +~~~~~~~~~~~~~~~~ + +- ``Client``: + + - Support binary request data automatically based on input type, eg + ``dict`` vs ``bytes``. + - Add new ``headers`` kwarg to ``call`` and auto-generated lexicon + method calls, useful for providing an explicit ``Content-Type`` + when sending binary data. + - Bug fix: don’t infinite loop if ``refreshSession`` fails. + - Other minor authentication bug fixes. + +.. _section-1: + 0.4 - 2023-10-28 ~~~~~~~~~~~~~~~~ @@ -339,7 +360,7 @@ Changelog ``User-Agent: lexrpc (https://lexrpc.readthedocs.io/)`` request header. -- ``server``: +- ``Server``: - Add new ``Redirect`` class. Handlers can raise this to indicate that the web server should serve an HTTP redirect. `Whether this @@ -354,7 +375,7 @@ Changelog - Add the ``error`` field to the JSON response bodies for most error responses. -.. _section-1: +.. _section-2: 0.3 - 2023-08-29 ~~~~~~~~~~~~~~~~ @@ -366,7 +387,7 @@ Changelog - Add new ``Server.register`` method for manually registering handlers. - Bug fix for server ``@method`` decorator. -.. _section-2: +.. _section-3: 0.2 - 2023-03-13 ~~~~~~~~~~~~~~~~ @@ -383,7 +404,7 @@ put more effort into matching and fully implementing them. Stay tuned! format `__. Original format is no longer supported. -.. _section-3: +.. _section-4: 0.1 - 2022-12-13 ~~~~~~~~~~~~~~~~ diff --git a/lexrpc/client.py b/lexrpc/client.py index 728bad0..e5b058b 100644 --- a/lexrpc/client.py +++ b/lexrpc/client.py @@ -121,6 +121,8 @@ def call(self, nsid, input=None, headers={}, **params): Args: nsid (str): method NSID input (dict or bytes): input body, optional for subscriptions + headers (dict): HTTP headers to include in this request. Overrides any + headers passed to the constructor. params: optional method parameters Returns: @@ -135,6 +137,7 @@ def call(self, nsid, input=None, headers={}, **params): output don't validate against the method's schemas requests.RequestException: if the connection or HTTP request to the remote server failed + """ def loggable(val): return f'{len(val)} bytes' if isinstance(val, bytes) else val diff --git a/pyproject.toml b/pyproject.toml index b55f71d..c1eae8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ where = ['.'] [project] name = 'lexrpc' -version = '0.4' +version = '0.5' authors = [ { name='Ryan Barrett', email='lexrpc@ryanb.org' }, ]