jsonrpcserver 5.0.9__tar.gz → 5.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. jsonrpcserver-5.1.0/CHANGELOG.md +404 -0
  2. jsonrpcserver-5.1.0/CODE_OF_CONDUCT.md +83 -0
  3. jsonrpcserver-5.1.0/CONTRIBUTING.md +63 -0
  4. jsonrpcserver-5.1.0/PKG-INFO +163 -0
  5. jsonrpcserver-5.1.0/README.md +120 -0
  6. jsonrpcserver-5.1.0/RELEASING.md +97 -0
  7. jsonrpcserver-5.1.0/SECURITY.md +27 -0
  8. jsonrpcserver-5.1.0/docs/assets/a11y.js +27 -0
  9. jsonrpcserver-5.1.0/docs/assets/apple-touch-icon.png +0 -0
  10. jsonrpcserver-5.1.0/docs/assets/copy-without-prompts.js +19 -0
  11. jsonrpcserver-5.1.0/docs/assets/extra.css +117 -0
  12. jsonrpcserver-5.1.0/docs/assets/favicon.png +0 -0
  13. jsonrpcserver-5.1.0/docs/assets/logo.png +0 -0
  14. jsonrpcserver-5.1.0/docs/assets/social-card.png +0 -0
  15. jsonrpcserver-5.1.0/docs/async.md +119 -0
  16. jsonrpcserver-5.1.0/docs/batches.md +135 -0
  17. jsonrpcserver-5.1.0/docs/changelog.md +5 -0
  18. jsonrpcserver-5.1.0/docs/context.md +163 -0
  19. jsonrpcserver-5.1.0/docs/contributing.md +5 -0
  20. jsonrpcserver-5.1.0/docs/dispatch.md +243 -0
  21. jsonrpcserver-5.1.0/docs/errors.md +186 -0
  22. jsonrpcserver-5.1.0/docs/examples/aiohttp_server.py +23 -0
  23. jsonrpcserver-5.1.0/docs/examples/check_examples.py +262 -0
  24. jsonrpcserver-5.1.0/docs/examples/django_server.py +41 -0
  25. jsonrpcserver-5.1.0/docs/examples/fastapi_server.py +32 -0
  26. jsonrpcserver-5.1.0/docs/examples/flask_server.py +24 -0
  27. jsonrpcserver-5.1.0/docs/examples/http_server.py +50 -0
  28. jsonrpcserver-5.1.0/docs/examples/quickstart.py +10 -0
  29. jsonrpcserver-5.1.0/docs/examples/sanic_server.py +24 -0
  30. jsonrpcserver-5.1.0/docs/examples/socketio_server.py +26 -0
  31. jsonrpcserver-5.1.0/docs/examples/tornado_server.py +32 -0
  32. jsonrpcserver-5.1.0/docs/examples/websockets_server.py +29 -0
  33. jsonrpcserver-5.1.0/docs/examples/werkzeug_server.py +26 -0
  34. jsonrpcserver-5.1.0/docs/examples/zeromq_async_server.py +26 -0
  35. jsonrpcserver-5.1.0/docs/examples/zeromq_server.py +20 -0
  36. jsonrpcserver-5.1.0/docs/examples.md +56 -0
  37. jsonrpcserver-5.1.0/docs/faq.md +135 -0
  38. jsonrpcserver-5.1.0/docs/frameworks/aiohttp.md +38 -0
  39. jsonrpcserver-5.1.0/docs/frameworks/django.md +48 -0
  40. jsonrpcserver-5.1.0/docs/frameworks/fastapi.md +44 -0
  41. jsonrpcserver-5.1.0/docs/frameworks/flask.md +41 -0
  42. jsonrpcserver-5.1.0/docs/frameworks/http-server.md +71 -0
  43. jsonrpcserver-5.1.0/docs/frameworks/sanic.md +40 -0
  44. jsonrpcserver-5.1.0/docs/frameworks/socketio.md +28 -0
  45. jsonrpcserver-5.1.0/docs/frameworks/tornado.md +37 -0
  46. jsonrpcserver-5.1.0/docs/frameworks/websockets.md +38 -0
  47. jsonrpcserver-5.1.0/docs/frameworks/werkzeug.md +43 -0
  48. jsonrpcserver-5.1.0/docs/frameworks/zeromq.md +43 -0
  49. jsonrpcserver-5.1.0/docs/index.md +108 -0
  50. jsonrpcserver-5.1.0/docs/license.md +12 -0
  51. jsonrpcserver-5.1.0/docs/methods.md +190 -0
  52. jsonrpcserver-5.1.0/docs/migration.md +172 -0
  53. jsonrpcserver-5.1.0/docs/reference.md +116 -0
  54. jsonrpcserver-5.1.0/docs/roadmap.md +58 -0
  55. jsonrpcserver-5.1.0/docs/security-policy.md +5 -0
  56. jsonrpcserver-5.1.0/docs/security.md +195 -0
  57. jsonrpcserver-5.1.0/docs/testing.md +119 -0
  58. jsonrpcserver-5.1.0/docs/threads.md +63 -0
  59. jsonrpcserver-5.1.0/docs/typing.md +76 -0
  60. jsonrpcserver-5.1.0/docs/validation.md +149 -0
  61. {jsonrpcserver-5.0.9 → jsonrpcserver-5.1.0}/jsonrpcserver/__init__.py +16 -2
  62. jsonrpcserver-5.1.0/jsonrpcserver/async_dispatcher.py +187 -0
  63. jsonrpcserver-5.1.0/jsonrpcserver/async_main.py +180 -0
  64. jsonrpcserver-5.1.0/jsonrpcserver/codes.py +20 -0
  65. jsonrpcserver-5.1.0/jsonrpcserver/dispatcher.py +478 -0
  66. jsonrpcserver-5.1.0/jsonrpcserver/exceptions.py +35 -0
  67. jsonrpcserver-5.1.0/jsonrpcserver/main.py +308 -0
  68. jsonrpcserver-5.1.0/jsonrpcserver/methods.py +92 -0
  69. {jsonrpcserver-5.0.9 → jsonrpcserver-5.1.0}/jsonrpcserver/request.py +5 -2
  70. jsonrpcserver-5.1.0/jsonrpcserver/response.py +170 -0
  71. jsonrpcserver-5.1.0/jsonrpcserver/result.py +150 -0
  72. {jsonrpcserver-5.0.9 → jsonrpcserver-5.1.0}/jsonrpcserver/sentinels.py +9 -0
  73. jsonrpcserver-5.1.0/jsonrpcserver/server.py +115 -0
  74. jsonrpcserver-5.1.0/jsonrpcserver/utils.py +51 -0
  75. jsonrpcserver-5.1.0/mkdocs.yml +136 -0
  76. jsonrpcserver-5.1.0/overrides/404.html +22 -0
  77. jsonrpcserver-5.1.0/overrides/main.html +55 -0
  78. jsonrpcserver-5.1.0/pyproject.toml +126 -0
  79. jsonrpcserver-5.1.0/requirements/build.txt +3 -0
  80. jsonrpcserver-5.1.0/requirements/docs-constraints.txt +33 -0
  81. jsonrpcserver-5.1.0/requirements/docs.txt +5 -0
  82. jsonrpcserver-5.1.0/requirements/examples.txt +21 -0
  83. jsonrpcserver-5.1.0/requirements/lint.txt +7 -0
  84. jsonrpcserver-5.1.0/requirements/site.txt +2 -0
  85. jsonrpcserver-5.1.0/requirements/test.txt +6 -0
  86. jsonrpcserver-5.1.0/tests/__init__.py +0 -0
  87. jsonrpcserver-5.1.0/tests/doc_examples.py +221 -0
  88. jsonrpcserver-5.1.0/tests/test_async_dispatcher.py +368 -0
  89. jsonrpcserver-5.1.0/tests/test_async_main.py +101 -0
  90. jsonrpcserver-5.1.0/tests/test_batch_limit.py +119 -0
  91. jsonrpcserver-5.1.0/tests/test_dispatcher.py +1009 -0
  92. jsonrpcserver-5.1.0/tests/test_docs.py +137 -0
  93. jsonrpcserver-5.1.0/tests/test_docstrings.py +31 -0
  94. jsonrpcserver-5.1.0/tests/test_main.py +87 -0
  95. jsonrpcserver-5.1.0/tests/test_methods.py +37 -0
  96. jsonrpcserver-5.1.0/tests/test_request.py +15 -0
  97. jsonrpcserver-5.1.0/tests/test_response.py +158 -0
  98. jsonrpcserver-5.1.0/tests/test_result.py +67 -0
  99. jsonrpcserver-5.1.0/tests/test_robustness.py +377 -0
  100. jsonrpcserver-5.1.0/tests/test_sentinels.py +9 -0
  101. jsonrpcserver-5.1.0/tests/test_server.py +163 -0
  102. jsonrpcserver-5.1.0/tests/test_threading.py +92 -0
  103. jsonrpcserver-5.1.0/tests/test_typing.py +46 -0
  104. jsonrpcserver-5.1.0/tests/test_version.py +9 -0
  105. jsonrpcserver-5.1.0/tests/test_warnings.py +80 -0
  106. jsonrpcserver-5.1.0/tox.ini +12 -0
  107. jsonrpcserver-5.0.9/CHANGELOG.md +0 -209
  108. jsonrpcserver-5.0.9/MANIFEST.in +0 -2
  109. jsonrpcserver-5.0.9/PKG-INFO +0 -50
  110. jsonrpcserver-5.0.9/README.md +0 -35
  111. jsonrpcserver-5.0.9/jsonrpcserver/async_dispatcher.py +0 -106
  112. jsonrpcserver-5.0.9/jsonrpcserver/async_main.py +0 -53
  113. jsonrpcserver-5.0.9/jsonrpcserver/codes.py +0 -8
  114. jsonrpcserver-5.0.9/jsonrpcserver/dispatcher.py +0 -284
  115. jsonrpcserver-5.0.9/jsonrpcserver/exceptions.py +0 -10
  116. jsonrpcserver-5.0.9/jsonrpcserver/main.py +0 -115
  117. jsonrpcserver-5.0.9/jsonrpcserver/methods.py +0 -43
  118. jsonrpcserver-5.0.9/jsonrpcserver/response.py +0 -103
  119. jsonrpcserver-5.0.9/jsonrpcserver/result.py +0 -67
  120. jsonrpcserver-5.0.9/jsonrpcserver/server.py +0 -21
  121. jsonrpcserver-5.0.9/jsonrpcserver/utils.py +0 -16
  122. jsonrpcserver-5.0.9/jsonrpcserver.egg-info/PKG-INFO +0 -50
  123. jsonrpcserver-5.0.9/jsonrpcserver.egg-info/SOURCES.txt +0 -27
  124. jsonrpcserver-5.0.9/jsonrpcserver.egg-info/dependency_links.txt +0 -1
  125. jsonrpcserver-5.0.9/jsonrpcserver.egg-info/not-zip-safe +0 -1
  126. jsonrpcserver-5.0.9/jsonrpcserver.egg-info/requires.txt +0 -13
  127. jsonrpcserver-5.0.9/jsonrpcserver.egg-info/top_level.txt +0 -1
  128. jsonrpcserver-5.0.9/setup.cfg +0 -4
  129. jsonrpcserver-5.0.9/setup.py +0 -41
  130. {jsonrpcserver-5.0.9 → jsonrpcserver-5.1.0}/LICENSE +0 -0
  131. {jsonrpcserver-5.0.9 → jsonrpcserver-5.1.0}/jsonrpcserver/py.typed +0 -0
  132. {jsonrpcserver-5.0.9 → jsonrpcserver-5.1.0}/jsonrpcserver/request-schema.json +0 -0
@@ -0,0 +1,404 @@
1
+ # Changelog
2
+
3
+ ## 5.1.0 (2026-11-06)
4
+
5
+ ### Added
6
+
7
+ - A method can return a plain value. `return "pong"` sends the same response as
8
+ `return Success("pong")`, as in 4.x (#285). Before, a plain value gave the
9
+ client an Internal error. `Success` and `Error` work as before.
10
+
11
+ ### Changed
12
+
13
+ - A method that returns an oslash `Left` or `Right` not made by `Success` or
14
+ `Error`, or a bare `SuccessResult` or `ErrorResult`, still gets an Internal
15
+ error. Its log line and `InvalidResultError` message now say "Return a value,
16
+ Success(value) or Error(code, message)", and the log line links the Methods
17
+ page.
18
+
19
+ ## 5.0.10 (2026-11-06)
20
+
21
+ The first release since the project moved to
22
+ [bensynapse/jsonrpcserver](https://github.com/bensynapse/jsonrpcserver). It
23
+ fixes a security problem, so please upgrade. Code that works with 5.0.9 keeps
24
+ working, apart from the security fix and the "Behaviour changes" below. The
25
+ [migration guide](https://bensynapse.github.io/jsonrpcserver/migration/#from-509-to-5010)
26
+ lists what you might notice.
27
+
28
+ ### Security
29
+
30
+ When a method raised an exception it didn't catch, the error response sent to
31
+ the client included the exception message in `error.data`. Exception messages
32
+ from database drivers, HTTP clients and the like often contain connection
33
+ strings, passwords, hostnames, file paths or SQL. Anyone who could call a method
34
+ could read them.
35
+
36
+ The response now leaves `data` out:
37
+
38
+ ```json
39
+ {"jsonrpc": "2.0", "error": {"code": -32603, "message": "Internal error"}, "id": 1}
40
+ ```
41
+
42
+ The same applies to the -32000 "Server error" response for errors inside
43
+ jsonrpcserver itself. The exception and its traceback are still logged, on the
44
+ `jsonrpcserver` logger, so you can find them in your server logs. The
45
+ [logging section](https://bensynapse.github.io/jsonrpcserver/errors/#logging)
46
+ of the docs lists its child loggers.
47
+
48
+ To get the old behaviour back while developing, pass `debug=True` to
49
+ `dispatch`, `async_dispatch` or any of the other dispatch functions. Don't turn
50
+ it on in production.
51
+
52
+ Errors you return on purpose, with `Error`, `InvalidParams` or by raising
53
+ `JsonRpcError`, are not affected. Their `data` is sent as before.
54
+
55
+ ### New
56
+
57
+ - `max_batch_size` keyword on all the dispatch functions, sync and async. A
58
+ batch with more requests than this gets a single -32600 "Invalid request"
59
+ response, and none of its requests are run. The default is no limit, as
60
+ before. Each request in a batch costs schema validation time. A 5 MB batch
61
+ of 100,000 pings took about 4 seconds of CPU, so a public server should set
62
+ a limit. 100 is a sensible starting point.
63
+ - `Error` and `JsonRpcError` give a `UserWarning` if the code isn't an integer
64
+ or the message isn't a string. The spec requires an integer code, and some
65
+ clients can't parse anything else. The response is still sent as before.
66
+ - `@method` gives a `UserWarning` for a name that starts with `rpc.`, because
67
+ the spec reserves those names.
68
+ - A method that returns a plain value instead of `Success(value)` is a common
69
+ mistake when upgrading from 4.x. It's now logged with a message that says
70
+ what to change, instead of a traceback. The client still gets an Internal
71
+ error.
72
+ - `serve()` says where it's listening when it starts, including a note when it
73
+ listens on every network interface (the default). It logs the line on the
74
+ `jsonrpcserver.server` logger, and writes it to stderr if logging isn't
75
+ configured.
76
+ - Every public function and class has a full docstring, which the new API
77
+ reference on the docs site is built from.
78
+
79
+ ### Behaviour changes
80
+
81
+ Batches that mix valid and invalid requests are now handled per request, as
82
+ the JSON-RPC spec says (#291). `[1, {"jsonrpc": "2.0", "method": "ping", "id":
83
+ 1}]` used to get a single "Invalid request" response. Now `1` gets its own
84
+ error and `ping` runs.
85
+
86
+ As part of that change, a custom `validator` is now called once for each
87
+ request in a batch, with just that request. Before, it was called once with
88
+ the whole list. Some validators enforced a rule about the batch as a whole,
89
+ such as a size limit or refusing batches. Those no longer see the list, so the
90
+ rule silently stops working. Use `max_batch_size` for a size limit. Validators
91
+ that check one request at a time, including the default and `lambda _: None`,
92
+ are not affected.
93
+
94
+ `dispatch` no longer writes `NaN`, `Infinity` or `-Infinity` into a response.
95
+ They aren't valid JSON, and strict parsers (JavaScript's `JSON.parse`, Go,
96
+ Rust) reject the whole response. A result containing one now gives an Internal
97
+ error instead. If you depend on the old output, pass `serializer=json.dumps`.
98
+
99
+ ### Typing
100
+
101
+ - `@method` now returns the decorated function unchanged as far as type
102
+ checkers are concerned. Before, mypy and pyright saw every decorated
103
+ function as `(*Any, **Any) -> Any`, so they couldn't check calls to your own
104
+ methods.
105
+ - `Result` had its two type arguments the wrong way round for oslash's
106
+ `Either`. It is now `Either[SuccessResult, ErrorResult]`. Nothing changes at
107
+ run time.
108
+ - `Success`, `Error` and `InvalidParams` have real signatures instead of
109
+ `*args, **kwargs`. `Error` expects an `int` code and a `str` message.
110
+ - The `methods` argument accepts any mapping, and async methods type-check.
111
+ - oslash ships type hints but no `py.typed` marker, so mypy treats `Result` as
112
+ `Any` unless you tell it to read them. pyright reads them without help. For
113
+ mypy, add this to `pyproject.toml`:
114
+
115
+ ```toml
116
+ [[tool.mypy.overrides]]
117
+ module = ["oslash", "oslash.*"]
118
+ follow_untyped_imports = true
119
+ ```
120
+
121
+ ### Documentation
122
+
123
+ The documentation now lives in this repository, under `docs/`, and is
124
+ published at https://bensynapse.github.io/jsonrpcserver/. The framework
125
+ examples moved there from the wiki. CI starts each example server and sends
126
+ it requests, and runs every code example in the docs. The websockets example
127
+ uses the current `websockets.asyncio` API (#287). A new Security page covers
128
+ the settings to check before exposing a server.
129
+
130
+ The site has an API reference built from the docstrings and a migration
131
+ guide from 4.x. New pages cover errors and logging, notifications and
132
+ batches, context, validation, typing, testing and threads. Each framework has its own
133
+ page, and every example sets `max_batch_size` and a request size limit. The
134
+ examples listen on `localhost:8000`, where the jsonrpcclient examples
135
+ connect.
136
+
137
+ ### Packaging
138
+
139
+ - A wheel is published as well as the source distribution, so installs no
140
+ longer have to build the package.
141
+ - The package metadata says it needs Python 3.8 or later, and lists 3.8 to
142
+ 3.14. CI tests all of those, plus free-threaded 3.14.
143
+ - The project links on PyPI point to this repository and the new docs. The
144
+ old website domains belong to someone else now. Please don't follow links
145
+ to them from older releases.
146
+ - `jsonrpcserver.__version__` gives the version.
147
+ - The `test` extra now includes everything the tests need (`pytest-asyncio`
148
+ and `hypothesis` were missing). The `examples` extra is gone, because the
149
+ examples it was for are in the docs now, with their own requirements file.
150
+ - The build uses `pyproject.toml` with flit instead of `setup.py`. The
151
+ dependencies are the same as in 5.0.9.
152
+
153
+ ### Deprecations
154
+
155
+ Three functions in `jsonrpcserver.response` have new names. The old names still
156
+ work in 5.x but give a `DeprecationWarning`, and will be removed in 6.0.
157
+
158
+ - `serialize_error` is now `to_error_dict`.
159
+ - `serialize_success` is now `to_success_dict`.
160
+ - `to_serializable_one` is now `to_dict`. It's also still importable from
161
+ `jsonrpcserver.main`.
162
+
163
+ ### Fixes
164
+
165
+ - `@method(name="")` now registers the empty name. It used to ignore that
166
+ name and register the function's name instead.
167
+ - The development server, `serve()`, dropped every connection without a
168
+ response when `sys.stderr` was `None`. That's the case in a PyInstaller app
169
+ built with `--noconsole` (#269). It now logs requests through the logging
170
+ module, on the `jsonrpcserver.server` logger at INFO level, instead of
171
+ writing to stderr. Use `logging.basicConfig(level=logging.INFO)` to see them.
172
+ - `serve()` also answers a body that isn't valid UTF-8 with a -32700 "Parse
173
+ error". A missing or invalid `Content-Length` gets 411 or 400. Before, all
174
+ of these closed the connection with no response. Notifications get 204 No
175
+ Content instead of 200 with an empty body. It handles requests in threads,
176
+ and closes its socket when it stops.
177
+ - `import jsonrpcserver` gave a `DeprecationWarning` on Python 3.11 and 3.12,
178
+ which is an error when tests run with `-W error`. The request schema is now
179
+ loaded with `pkgutil.get_data`.
180
+ - If a method returned something `json.dumps` can't handle, such as a
181
+ `datetime`, `dispatch` raised `TypeError` instead of responding. In a batch,
182
+ the other responses were lost too. That response is now an Internal error,
183
+ and the rest of the batch is sent as usual.
184
+ - A failure outside the method itself used to turn a whole batch into a single
185
+ "Server error" with a null id. Now only the member that failed gets the
186
+ error. One way to hit it was a builtin such as `max`, whose signature can't
187
+ be inspected. Another was a batch member that isn't an object, with
188
+ validation turned off.
189
+ - Methods whose signature can't be inspected are now called, instead of
190
+ failing before the call.
191
+ - `async_dispatch` now accepts plain (non-async) methods as well. Calling an
192
+ async method through `dispatch` gives a clear message in the log, and no
193
+ "coroutine was never awaited" warning.
194
+ - Under `python -O`, a method that returned something other than a `Result`
195
+ broke the whole batch, because the check was an `assert` statement. The
196
+ check now works with `-O` too.
197
+
198
+ ## 5.0.9 (Sep 15, 2022)
199
+
200
+ - Remove unncessary `package_data` from setup.py (#243)
201
+ - Use a custom logger when logging exceptions, not root
202
+
203
+ ## 5.0.8 (Aug 16, 2022)
204
+
205
+ - Use importlib.resources instead of pkg_resources.
206
+
207
+ ## 5.0.7 (Mar 10, 2022)
208
+
209
+ - Upgrade to jsonschema 4.
210
+
211
+ ## 5.0.6 (Jan 14, 2022)
212
+
213
+ - Fix reversed Result Either type ([#227](https://github.com/bensynapse/jsonrpcserver/pull/227)).
214
+
215
+ ## 5.0.5 (Nov 27, 2021)
216
+
217
+ - Documentation.
218
+
219
+ ## 5.0.4 (Oct 27, 2021)
220
+
221
+ - Add to FAQ.
222
+
223
+ ## 5.0.3 (Aug 31, 2021)
224
+
225
+ - Update readme and documentation.
226
+ - Internal function `compose` has been replaced with a better one.
227
+
228
+ ## 5.0.2 (Aug 18, 2021)
229
+
230
+ - Update readme and setup.py, minor adjustments.
231
+
232
+ ## 5.0.1 (Aug 18, 2021)
233
+
234
+ No changelog entry was written for this release. See the `5.0.1` tag.
235
+
236
+ ## 5.0.0 (Aug 16, 2021)
237
+
238
+ A complete rebuild, with a few important usage changes. The
239
+ [migration guide](https://bensynapse.github.io/jsonrpcserver/migration/#from-4x-to-5x)
240
+ shows how to update 4.x code.
241
+
242
+ - Methods must now return a Result (Success or Error).
243
+ - The dispatch function now returns a string.
244
+ - Methods collection is now a simple dict, the Methods class has been removed.
245
+ - Changed all classes (Request, Response, Methods, etc) to namedtuples.
246
+ - Logging removed. User can log instead.
247
+ - Config file removed. Configure with arguments to dispatch.
248
+ - Removed "trim log values" and "convert camel case" options.
249
+ - Removed the custom exceptions, replaced with one JsonRpcError exception.
250
+
251
+ ## 4.2.0 (Nov 9, 2020)
252
+
253
+ - Add ability to use custom serializer and deserializer ([#125](https://github.com/bensynapse/jsonrpcserver/pull/125))
254
+ - Add ability to use custom method name ([#127](https://github.com/bensynapse/jsonrpcserver/pull/127))
255
+ - Deny additional parameters in json-rpc request ([#128](https://github.com/bensynapse/jsonrpcserver/pull/128))
256
+
257
+ Thanks to deptyped.
258
+
259
+ ## 4.1.3 (May 2, 2020)
260
+
261
+ - In the case of a method returning a non-serializable value, return a JSON-RPC
262
+ error response. It was previously erroring server-side without responding to
263
+ the client. (#119)
264
+ - Fix for Python 3.8 - ensures the same exceptions will be raised in 3.8 and
265
+ pre-3.8. (#122)
266
+
267
+ ## 4.1.2 (Jan 9, 2020)
268
+
269
+ - Fix the egg-info directory in package.
270
+
271
+ ## 4.1.1 (Jan 8, 2020)
272
+
273
+ - Fix file permission on all files.
274
+
275
+ ## 4.1.0 (Jan 6, 2020)
276
+
277
+ - Add InvalidParamsError exception, for input validation. Previously the
278
+ advice was to `assert` on input values. However, AssertionError was too
279
+ generic an exception. Instead, raise InvalidParamsError. Note `assert` will
280
+ still work but will be removed in the next major release (5.0).
281
+ - Add an ApiError exception; raise it to send an application defined error
282
+ response. This covers the line in the JSON-RPC spec, "The remainder of the
283
+ space is available for application defined errors."
284
+ - A KeyError raised inside methods will no longer send a "method not found"
285
+ response.
286
+ - Uncaught exceptions raised inside methods will now be logged. We've been
287
+ simply responding to the client with a Server Error. Now the traceback will
288
+ also be logged server-side.
289
+ - Fix a deprecation warning related to collections.abc.
290
+ - Add py.typed to indicate this package supports typing. (PEP 561)
291
+
292
+ Thanks to steinymity for his work on this release.
293
+
294
+ ## 4.0.5 (Sep 10, 2019)
295
+
296
+ - Include license in package.
297
+
298
+ ## 4.0.4 (Jun 22, 2019)
299
+
300
+ - Use faster method of jsonschema validation
301
+ - Use inspect from stdlib, removing the need for funcsigs
302
+
303
+ ## 4.0.3 (Jun 15, 2019)
304
+
305
+ - Update dependencies to allow jsonschema version 3.x
306
+ - Support Python 3.8
307
+
308
+ ## 4.0.2 (Apr 13, 2019)
309
+
310
+ - Fix to allow passing context when no parameters are passed.
311
+
312
+ ## 4.0.1 (Dec 21, 2018)
313
+
314
+ - Include exception in ExceptionResponse. Closes #74.
315
+
316
+ ## 4.0.0 (Oct 14, 2018)
317
+
318
+ _The 4.x releases will support Python 3.6+ only._
319
+
320
+ - Dispatch now works only with `Methods` object. No longer accepts a
321
+ dictionary or list.
322
+ - `dispatch` no longer requires a "methods" argument. If not passed, uses the
323
+ global methods object.
324
+ - Methods initialiser has a simpler api - Methods(func1, func2, ...) or
325
+ Methods(name1=func1, name2=func2, ...).
326
+ - No more jsonrpcserver exceptions. Calling code will _always_ get a valid
327
+ JSON-RPC response from `dispatch`. The old `InvalidParamsError` is gone
328
+ - instead do a regular `assert` on arguments.
329
+ - `response.is_notification` renamed to `response.wanted`, which is the
330
+ opposite of is_notification. This means the original request was not a
331
+ notification, it had an id, and does expect a response.
332
+ - Removed "respond to notification errors" option, which broke the
333
+ specification. We still respond to invalid json/json-rpc requests, in which
334
+ case it's not possible to know if the request is a notification.
335
+ - Removed the "config" module. Added external config file, `.jsonrpcserverrc`.
336
+ (alternatively configure with arguments to dispatch)
337
+ - Removed the "six" dependency, no longer needed.
338
+ - Configure logging Pythonically.
339
+ - Add type hints
340
+ - Move tests to pytest
341
+ - Passing a context object to dispatch now sets it as the first positional
342
+ argument to the method. `def fruits(ctx, color):`
343
+ - Check params with regular asserts.
344
+
345
+ ## 3.5.6 (Jun 28, 2018)
346
+ - Add trim_log_values dispatch param. (#65)
347
+ - Fix a missing import
348
+
349
+ ## 3.5.5 (Jun 19, 2018)
350
+ - Rewrite of dispatch(), adding parameters to configure the dispatch that were
351
+ previously configured by modifying the `config` module. That module is now
352
+ deprecated and will be removed in 4.0.
353
+
354
+ ## 3.5.4 (Apr 30, 2018)
355
+ - Refactoring
356
+
357
+ ## 3.5.3 (Dec 19, 2017)
358
+ - Allow requests to have any non-None id
359
+
360
+ ## 3.5.2 (Sep 19, 2017)
361
+ - Refactor for Request subclassing
362
+
363
+ ## 3.5.1 (Aug 12, 2017)
364
+ - Include context data in regular (synchronous) methods.dispatch
365
+
366
+ ## 3.5.0 (Aug 12, 2017)
367
+ - Pass some context data through dispatch to the methods.
368
+ - Fix not calling notifications in batch requests.
369
+
370
+ ## 3.4.4 (Jul 13, 2017)
371
+ - Fix AttributeError on batch responses
372
+
373
+ ## 3.4.3 (Jul 12, 2017)
374
+ - Add `Response.is_notification` attribute
375
+
376
+ ## 3.4.2 (Jun 9, 2017)
377
+ - Fix `convert_camel_case` with array params
378
+
379
+ ## 3.4.1 (Oct 4, 2016)
380
+ - Disable logging in config
381
+ - Performance improved
382
+ - Fix async batch requests
383
+
384
+ ## 3.4.0 (Sep 27, 2016)
385
+ - Added asyncio support. (Python 3.5+)
386
+ - Added a *methods* object to the jsonrpcserver module (so you can import
387
+ jsonrpcserver.methods, rather than instantiating your own).
388
+ - Added methods.dispatch().
389
+
390
+ ## 3.3.4 (Sep 22, 2016)
391
+ - Fix Methods.serve_forever in python 2 (thanks @bplower)
392
+
393
+ ## 3.3.3 (Sep 15, 2016)
394
+ - Updated method of logging exception (thanks @bplower)
395
+
396
+ ## 3.3.2 (Aug 19, 2016)
397
+ - Pass Methods named args onto MutableMapping
398
+ - Remove unused logger
399
+
400
+ ## 3.3.1 (Aug 5, 2016)
401
+ - Allow passing dict to Methods constructor
402
+
403
+ ## 3.3.0 (Aug 5, 2016)
404
+ - A basic HTTP server has been added.
@@ -0,0 +1,83 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
22
+ * Trolling, insulting or derogatory comments, and personal or political attacks
23
+ * Public or private harassment
24
+ * Publishing others' private information, such as a physical or email address, without their explicit permission
25
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
26
+
27
+ ## Enforcement Responsibilities
28
+
29
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32
+
33
+ ## Scope
34
+
35
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36
+
37
+ ## Enforcement
38
+
39
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ben@synapsereality.io. All complaints will be reviewed and investigated promptly and fairly.
40
+
41
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42
+
43
+ ## Enforcement Guidelines
44
+
45
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46
+
47
+ ### 1. Correction
48
+
49
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50
+
51
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52
+
53
+ ### 2. Warning
54
+
55
+ **Community Impact**: A violation through a single incident or series of actions.
56
+
57
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58
+
59
+ ### 3. Temporary Ban
60
+
61
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62
+
63
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64
+
65
+ ### 4. Permanent Ban
66
+
67
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68
+
69
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
70
+
71
+ ## Attribution
72
+
73
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
74
+
75
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
76
+
77
+ For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
78
+
79
+ [homepage]: https://www.contributor-covenant.org
80
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
81
+ [Mozilla CoC]: https://github.com/mozilla/diversity
82
+ [FAQ]: https://www.contributor-covenant.org/faq
83
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,63 @@
1
+ # Contributing
2
+
3
+ Bug reports and pull requests are welcome. For a bigger change, open an issue
4
+ first so we can agree on the approach. Breaking changes wait for 6.0. See the
5
+ [roadmap](https://bensynapse.github.io/jsonrpcserver/roadmap/).
6
+
7
+ Everyone who takes part in this project, in issues, pull requests or
8
+ discussions, is expected to follow the
9
+ [Code of Conduct](https://github.com/bensynapse/jsonrpcserver/blob/main/CODE_OF_CONDUCT.md).
10
+
11
+ ## Setting up
12
+
13
+ ```sh
14
+ python -m venv .venv
15
+ . .venv/bin/activate
16
+ pip install -e . -r requirements/test.txt -r requirements/lint.txt
17
+ ```
18
+
19
+ ## Checks
20
+
21
+ CI runs these, and a pull request needs all of them to pass:
22
+
23
+ ```sh
24
+ pytest --cov # tests, 100% line and branch coverage required
25
+ ruff check .
26
+ ruff format --check .
27
+ mypy
28
+ pyright
29
+ ```
30
+
31
+ To run the tests on every Python version you have installed, use `tox`.
32
+
33
+ ## Docs
34
+
35
+ The docs are in `docs/`, built with MkDocs. To preview them:
36
+
37
+ ```sh
38
+ pip install -r requirements/docs.txt
39
+ mkdocs serve
40
+ ```
41
+
42
+ `tests/test_docs.py` runs every Python block in the README and docs, so keep
43
+ the shown output accurate. `tests/doc_examples.py` explains the markers that
44
+ skip a block or start the quickstart server for it. Blocks that need a
45
+ framework are skipped unless it's installed, so to run them all, install
46
+ `requirements/examples.txt` first, as CI's docs job does.
47
+
48
+ The framework examples are files in `docs/examples/`. To start each one and
49
+ send it real requests, install `requirements/examples.txt` and run
50
+ `python docs/examples/check_examples.py`. It also needs curl. The examples
51
+ listen on `localhost:8000`, so free that port first.
52
+
53
+ The API reference is built from the docstrings with mkdocstrings. Use Google
54
+ style, and add every new public name to `docs/reference.md`. A test checks
55
+ that every name in `__all__` is there.
56
+
57
+ ## Pull requests
58
+
59
+ - Keep each pull request to one change, with a test for it.
60
+ - Add a line to CHANGELOG.md if users will notice the change.
61
+ - 5.x supports Python 3.8 and later, and its public API must not change.
62
+ That includes the names importable from each module, not just
63
+ `jsonrpcserver` itself.