jsonrpcserver 5.0.8__tar.gz → 5.0.10__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.0.10/CHANGELOG.md +388 -0
  2. jsonrpcserver-5.0.10/CODE_OF_CONDUCT.md +83 -0
  3. jsonrpcserver-5.0.10/CONTRIBUTING.md +63 -0
  4. jsonrpcserver-5.0.10/PKG-INFO +163 -0
  5. jsonrpcserver-5.0.10/README.md +120 -0
  6. jsonrpcserver-5.0.10/RELEASING.md +95 -0
  7. jsonrpcserver-5.0.10/SECURITY.md +27 -0
  8. jsonrpcserver-5.0.10/docs/assets/a11y.js +27 -0
  9. jsonrpcserver-5.0.10/docs/assets/apple-touch-icon.png +0 -0
  10. jsonrpcserver-5.0.10/docs/assets/copy-without-prompts.js +19 -0
  11. jsonrpcserver-5.0.10/docs/assets/extra.css +117 -0
  12. jsonrpcserver-5.0.10/docs/assets/favicon.png +0 -0
  13. jsonrpcserver-5.0.10/docs/assets/logo.png +0 -0
  14. jsonrpcserver-5.0.10/docs/assets/social-card.png +0 -0
  15. jsonrpcserver-5.0.10/docs/async.md +119 -0
  16. jsonrpcserver-5.0.10/docs/batches.md +135 -0
  17. jsonrpcserver-5.0.10/docs/changelog.md +5 -0
  18. jsonrpcserver-5.0.10/docs/context.md +163 -0
  19. jsonrpcserver-5.0.10/docs/contributing.md +5 -0
  20. jsonrpcserver-5.0.10/docs/dispatch.md +243 -0
  21. jsonrpcserver-5.0.10/docs/errors.md +183 -0
  22. jsonrpcserver-5.0.10/docs/examples/aiohttp_server.py +23 -0
  23. jsonrpcserver-5.0.10/docs/examples/check_examples.py +262 -0
  24. jsonrpcserver-5.0.10/docs/examples/django_server.py +41 -0
  25. jsonrpcserver-5.0.10/docs/examples/fastapi_server.py +32 -0
  26. jsonrpcserver-5.0.10/docs/examples/flask_server.py +24 -0
  27. jsonrpcserver-5.0.10/docs/examples/http_server.py +50 -0
  28. jsonrpcserver-5.0.10/docs/examples/quickstart.py +10 -0
  29. jsonrpcserver-5.0.10/docs/examples/sanic_server.py +24 -0
  30. jsonrpcserver-5.0.10/docs/examples/socketio_server.py +26 -0
  31. jsonrpcserver-5.0.10/docs/examples/tornado_server.py +32 -0
  32. jsonrpcserver-5.0.10/docs/examples/websockets_server.py +29 -0
  33. jsonrpcserver-5.0.10/docs/examples/werkzeug_server.py +26 -0
  34. jsonrpcserver-5.0.10/docs/examples/zeromq_async_server.py +26 -0
  35. jsonrpcserver-5.0.10/docs/examples/zeromq_server.py +20 -0
  36. jsonrpcserver-5.0.10/docs/examples.md +56 -0
  37. jsonrpcserver-5.0.10/docs/faq.md +135 -0
  38. jsonrpcserver-5.0.10/docs/frameworks/aiohttp.md +38 -0
  39. jsonrpcserver-5.0.10/docs/frameworks/django.md +48 -0
  40. jsonrpcserver-5.0.10/docs/frameworks/fastapi.md +44 -0
  41. jsonrpcserver-5.0.10/docs/frameworks/flask.md +41 -0
  42. jsonrpcserver-5.0.10/docs/frameworks/http-server.md +71 -0
  43. jsonrpcserver-5.0.10/docs/frameworks/sanic.md +40 -0
  44. jsonrpcserver-5.0.10/docs/frameworks/socketio.md +28 -0
  45. jsonrpcserver-5.0.10/docs/frameworks/tornado.md +37 -0
  46. jsonrpcserver-5.0.10/docs/frameworks/websockets.md +38 -0
  47. jsonrpcserver-5.0.10/docs/frameworks/werkzeug.md +43 -0
  48. jsonrpcserver-5.0.10/docs/frameworks/zeromq.md +43 -0
  49. jsonrpcserver-5.0.10/docs/index.md +108 -0
  50. jsonrpcserver-5.0.10/docs/license.md +12 -0
  51. jsonrpcserver-5.0.10/docs/methods.md +183 -0
  52. jsonrpcserver-5.0.10/docs/migration.md +168 -0
  53. jsonrpcserver-5.0.10/docs/reference.md +116 -0
  54. jsonrpcserver-5.0.10/docs/roadmap.md +57 -0
  55. jsonrpcserver-5.0.10/docs/security-policy.md +5 -0
  56. jsonrpcserver-5.0.10/docs/security.md +195 -0
  57. jsonrpcserver-5.0.10/docs/testing.md +119 -0
  58. jsonrpcserver-5.0.10/docs/threads.md +63 -0
  59. jsonrpcserver-5.0.10/docs/typing.md +76 -0
  60. jsonrpcserver-5.0.10/docs/validation.md +149 -0
  61. {jsonrpcserver-5.0.8 → jsonrpcserver-5.0.10}/jsonrpcserver/__init__.py +16 -2
  62. jsonrpcserver-5.0.10/jsonrpcserver/async_dispatcher.py +187 -0
  63. jsonrpcserver-5.0.10/jsonrpcserver/async_main.py +180 -0
  64. jsonrpcserver-5.0.10/jsonrpcserver/codes.py +20 -0
  65. jsonrpcserver-5.0.10/jsonrpcserver/dispatcher.py +460 -0
  66. jsonrpcserver-5.0.10/jsonrpcserver/exceptions.py +35 -0
  67. jsonrpcserver-5.0.10/jsonrpcserver/main.py +308 -0
  68. jsonrpcserver-5.0.10/jsonrpcserver/methods.py +91 -0
  69. {jsonrpcserver-5.0.8 → jsonrpcserver-5.0.10}/jsonrpcserver/request.py +5 -2
  70. jsonrpcserver-5.0.10/jsonrpcserver/response.py +170 -0
  71. jsonrpcserver-5.0.10/jsonrpcserver/result.py +150 -0
  72. {jsonrpcserver-5.0.8 → jsonrpcserver-5.0.10}/jsonrpcserver/sentinels.py +9 -0
  73. jsonrpcserver-5.0.10/jsonrpcserver/server.py +115 -0
  74. jsonrpcserver-5.0.10/jsonrpcserver/utils.py +51 -0
  75. jsonrpcserver-5.0.10/mkdocs.yml +136 -0
  76. jsonrpcserver-5.0.10/overrides/404.html +22 -0
  77. jsonrpcserver-5.0.10/overrides/main.html +55 -0
  78. jsonrpcserver-5.0.10/pyproject.toml +126 -0
  79. jsonrpcserver-5.0.10/requirements/build.txt +3 -0
  80. jsonrpcserver-5.0.10/requirements/docs-constraints.txt +33 -0
  81. jsonrpcserver-5.0.10/requirements/docs.txt +5 -0
  82. jsonrpcserver-5.0.10/requirements/examples.txt +21 -0
  83. jsonrpcserver-5.0.10/requirements/lint.txt +7 -0
  84. jsonrpcserver-5.0.10/requirements/site.txt +2 -0
  85. jsonrpcserver-5.0.10/requirements/test.txt +6 -0
  86. jsonrpcserver-5.0.10/tests/__init__.py +0 -0
  87. jsonrpcserver-5.0.10/tests/doc_examples.py +221 -0
  88. jsonrpcserver-5.0.10/tests/test_async_dispatcher.py +360 -0
  89. jsonrpcserver-5.0.10/tests/test_async_main.py +101 -0
  90. jsonrpcserver-5.0.10/tests/test_batch_limit.py +119 -0
  91. jsonrpcserver-5.0.10/tests/test_dispatcher.py +980 -0
  92. jsonrpcserver-5.0.10/tests/test_docs.py +137 -0
  93. jsonrpcserver-5.0.10/tests/test_docstrings.py +31 -0
  94. jsonrpcserver-5.0.10/tests/test_main.py +87 -0
  95. jsonrpcserver-5.0.10/tests/test_methods.py +37 -0
  96. jsonrpcserver-5.0.10/tests/test_request.py +15 -0
  97. jsonrpcserver-5.0.10/tests/test_response.py +158 -0
  98. jsonrpcserver-5.0.10/tests/test_result.py +67 -0
  99. jsonrpcserver-5.0.10/tests/test_robustness.py +375 -0
  100. jsonrpcserver-5.0.10/tests/test_sentinels.py +9 -0
  101. jsonrpcserver-5.0.10/tests/test_server.py +163 -0
  102. jsonrpcserver-5.0.10/tests/test_threading.py +92 -0
  103. jsonrpcserver-5.0.10/tests/test_typing.py +46 -0
  104. jsonrpcserver-5.0.10/tests/test_version.py +9 -0
  105. jsonrpcserver-5.0.10/tests/test_warnings.py +80 -0
  106. jsonrpcserver-5.0.10/tox.ini +12 -0
  107. jsonrpcserver-5.0.8/CHANGELOG.md +0 -204
  108. jsonrpcserver-5.0.8/MANIFEST.in +0 -2
  109. jsonrpcserver-5.0.8/PKG-INFO +0 -50
  110. jsonrpcserver-5.0.8/README.md +0 -35
  111. jsonrpcserver-5.0.8/jsonrpcserver/async_dispatcher.py +0 -104
  112. jsonrpcserver-5.0.8/jsonrpcserver/async_main.py +0 -53
  113. jsonrpcserver-5.0.8/jsonrpcserver/codes.py +0 -8
  114. jsonrpcserver-5.0.8/jsonrpcserver/dispatcher.py +0 -282
  115. jsonrpcserver-5.0.8/jsonrpcserver/exceptions.py +0 -10
  116. jsonrpcserver-5.0.8/jsonrpcserver/main.py +0 -115
  117. jsonrpcserver-5.0.8/jsonrpcserver/methods.py +0 -43
  118. jsonrpcserver-5.0.8/jsonrpcserver/response.py +0 -103
  119. jsonrpcserver-5.0.8/jsonrpcserver/result.py +0 -67
  120. jsonrpcserver-5.0.8/jsonrpcserver/server.py +0 -21
  121. jsonrpcserver-5.0.8/jsonrpcserver/utils.py +0 -16
  122. jsonrpcserver-5.0.8/jsonrpcserver.egg-info/PKG-INFO +0 -50
  123. jsonrpcserver-5.0.8/jsonrpcserver.egg-info/SOURCES.txt +0 -27
  124. jsonrpcserver-5.0.8/jsonrpcserver.egg-info/dependency_links.txt +0 -1
  125. jsonrpcserver-5.0.8/jsonrpcserver.egg-info/not-zip-safe +0 -1
  126. jsonrpcserver-5.0.8/jsonrpcserver.egg-info/requires.txt +0 -13
  127. jsonrpcserver-5.0.8/jsonrpcserver.egg-info/top_level.txt +0 -1
  128. jsonrpcserver-5.0.8/setup.cfg +0 -4
  129. jsonrpcserver-5.0.8/setup.py +0 -42
  130. {jsonrpcserver-5.0.8 → jsonrpcserver-5.0.10}/LICENSE +0 -0
  131. {jsonrpcserver-5.0.8 → jsonrpcserver-5.0.10}/jsonrpcserver/py.typed +0 -0
  132. {jsonrpcserver-5.0.8 → jsonrpcserver-5.0.10}/jsonrpcserver/request-schema.json +0 -0
@@ -0,0 +1,388 @@
1
+ # Changelog
2
+
3
+ ## 5.0.10 (2026-11-06)
4
+
5
+ The first release since the project moved to
6
+ [bensynapse/jsonrpcserver](https://github.com/bensynapse/jsonrpcserver). It
7
+ fixes a security problem, so please upgrade. Code that works with 5.0.9 keeps
8
+ working, apart from the security fix and the "Behaviour changes" below. The
9
+ [migration guide](https://bensynapse.github.io/jsonrpcserver/migration/#from-509-to-5010)
10
+ lists what you might notice.
11
+
12
+ ### Security
13
+
14
+ When a method raised an exception it didn't catch, the error response sent to
15
+ the client included the exception message in `error.data`. Exception messages
16
+ from database drivers, HTTP clients and the like often contain connection
17
+ strings, passwords, hostnames, file paths or SQL. Anyone who could call a method
18
+ could read them.
19
+
20
+ The response now leaves `data` out:
21
+
22
+ ```json
23
+ {"jsonrpc": "2.0", "error": {"code": -32603, "message": "Internal error"}, "id": 1}
24
+ ```
25
+
26
+ The same applies to the -32000 "Server error" response for errors inside
27
+ jsonrpcserver itself. The exception and its traceback are still logged, on the
28
+ `jsonrpcserver` logger, so you can find them in your server logs. The
29
+ [logging section](https://bensynapse.github.io/jsonrpcserver/errors/#logging)
30
+ of the docs lists its child loggers.
31
+
32
+ To get the old behaviour back while developing, pass `debug=True` to
33
+ `dispatch`, `async_dispatch` or any of the other dispatch functions. Don't turn
34
+ it on in production.
35
+
36
+ Errors you return on purpose, with `Error`, `InvalidParams` or by raising
37
+ `JsonRpcError`, are not affected. Their `data` is sent as before.
38
+
39
+ ### New
40
+
41
+ - `max_batch_size` keyword on all the dispatch functions, sync and async. A
42
+ batch with more requests than this gets a single -32600 "Invalid request"
43
+ response, and none of its requests are run. The default is no limit, as
44
+ before. Each request in a batch costs schema validation time. A 5 MB batch
45
+ of 100,000 pings took about 4 seconds of CPU, so a public server should set
46
+ a limit. 100 is a sensible starting point.
47
+ - `Error` and `JsonRpcError` give a `UserWarning` if the code isn't an integer
48
+ or the message isn't a string. The spec requires an integer code, and some
49
+ clients can't parse anything else. The response is still sent as before.
50
+ - `@method` gives a `UserWarning` for a name that starts with `rpc.`, because
51
+ the spec reserves those names.
52
+ - A method that returns a plain value instead of `Success(value)` is a common
53
+ mistake when upgrading from 4.x. It's now logged with a message that says
54
+ what to change, instead of a traceback. The client still gets an Internal
55
+ error.
56
+ - `serve()` says where it's listening when it starts, including a note when it
57
+ listens on every network interface (the default). It logs the line on the
58
+ `jsonrpcserver.server` logger, and writes it to stderr if logging isn't
59
+ configured.
60
+ - Every public function and class has a full docstring, which the new API
61
+ reference on the docs site is built from.
62
+
63
+ ### Behaviour changes
64
+
65
+ Batches that mix valid and invalid requests are now handled per request, as
66
+ the JSON-RPC spec says (#291). `[1, {"jsonrpc": "2.0", "method": "ping", "id":
67
+ 1}]` used to get a single "Invalid request" response. Now `1` gets its own
68
+ error and `ping` runs.
69
+
70
+ As part of that change, a custom `validator` is now called once for each
71
+ request in a batch, with just that request. Before, it was called once with
72
+ the whole list. Some validators enforced a rule about the batch as a whole,
73
+ such as a size limit or refusing batches. Those no longer see the list, so the
74
+ rule silently stops working. Use `max_batch_size` for a size limit. Validators
75
+ that check one request at a time, including the default and `lambda _: None`,
76
+ are not affected.
77
+
78
+ `dispatch` no longer writes `NaN`, `Infinity` or `-Infinity` into a response.
79
+ They aren't valid JSON, and strict parsers (JavaScript's `JSON.parse`, Go,
80
+ Rust) reject the whole response. A result containing one now gives an Internal
81
+ error instead. If you depend on the old output, pass `serializer=json.dumps`.
82
+
83
+ ### Typing
84
+
85
+ - `@method` now returns the decorated function unchanged as far as type
86
+ checkers are concerned. Before, mypy and pyright saw every decorated
87
+ function as `(*Any, **Any) -> Any`, so they couldn't check calls to your own
88
+ methods.
89
+ - `Result` had its two type arguments the wrong way round for oslash's
90
+ `Either`. It is now `Either[SuccessResult, ErrorResult]`. Nothing changes at
91
+ run time.
92
+ - `Success`, `Error` and `InvalidParams` have real signatures instead of
93
+ `*args, **kwargs`. `Error` expects an `int` code and a `str` message.
94
+ - The `methods` argument accepts any mapping, and async methods type-check.
95
+ - oslash ships type hints but no `py.typed` marker, so mypy treats `Result` as
96
+ `Any` unless you tell it to read them. pyright reads them without help. For
97
+ mypy, add this to `pyproject.toml`:
98
+
99
+ ```toml
100
+ [[tool.mypy.overrides]]
101
+ module = ["oslash", "oslash.*"]
102
+ follow_untyped_imports = true
103
+ ```
104
+
105
+ ### Documentation
106
+
107
+ The documentation now lives in this repository, under `docs/`, and is
108
+ published at https://bensynapse.github.io/jsonrpcserver/. The framework
109
+ examples moved there from the wiki. CI starts each example server and sends
110
+ it requests, and runs every code example in the docs. The websockets example
111
+ uses the current `websockets.asyncio` API (#287). A new Security page covers
112
+ the settings to check before exposing a server.
113
+
114
+ The site has an API reference built from the docstrings and a migration
115
+ guide from 4.x. New pages cover errors and logging, notifications and
116
+ batches, context, validation, typing, testing and threads. Each framework has its own
117
+ page, and every example sets `max_batch_size` and a request size limit. The
118
+ examples listen on `localhost:8000`, where the jsonrpcclient examples
119
+ connect.
120
+
121
+ ### Packaging
122
+
123
+ - A wheel is published as well as the source distribution, so installs no
124
+ longer have to build the package.
125
+ - The package metadata says it needs Python 3.8 or later, and lists 3.8 to
126
+ 3.14. CI tests all of those, plus free-threaded 3.14.
127
+ - The project links on PyPI point to this repository and the new docs. The
128
+ old website domains belong to someone else now. Please don't follow links
129
+ to them from older releases.
130
+ - `jsonrpcserver.__version__` gives the version.
131
+ - The `test` extra now includes everything the tests need (`pytest-asyncio`
132
+ and `hypothesis` were missing). The `examples` extra is gone, because the
133
+ examples it was for are in the docs now, with their own requirements file.
134
+ - The build uses `pyproject.toml` with flit instead of `setup.py`. The
135
+ dependencies are the same as in 5.0.9.
136
+
137
+ ### Deprecations
138
+
139
+ Three functions in `jsonrpcserver.response` have new names. The old names still
140
+ work in 5.x but give a `DeprecationWarning`, and will be removed in 6.0.
141
+
142
+ - `serialize_error` is now `to_error_dict`.
143
+ - `serialize_success` is now `to_success_dict`.
144
+ - `to_serializable_one` is now `to_dict`. It's also still importable from
145
+ `jsonrpcserver.main`.
146
+
147
+ ### Fixes
148
+
149
+ - `@method(name="")` now registers the empty name. It used to ignore that
150
+ name and register the function's name instead.
151
+ - The development server, `serve()`, dropped every connection without a
152
+ response when `sys.stderr` was `None`. That's the case in a PyInstaller app
153
+ built with `--noconsole` (#269). It now logs requests through the logging
154
+ module, on the `jsonrpcserver.server` logger at INFO level, instead of
155
+ writing to stderr. Use `logging.basicConfig(level=logging.INFO)` to see them.
156
+ - `serve()` also answers a body that isn't valid UTF-8 with a -32700 "Parse
157
+ error". A missing or invalid `Content-Length` gets 411 or 400. Before, all
158
+ of these closed the connection with no response. Notifications get 204 No
159
+ Content instead of 200 with an empty body. It handles requests in threads,
160
+ and closes its socket when it stops.
161
+ - `import jsonrpcserver` gave a `DeprecationWarning` on Python 3.11 and 3.12,
162
+ which is an error when tests run with `-W error`. The request schema is now
163
+ loaded with `pkgutil.get_data`.
164
+ - If a method returned something `json.dumps` can't handle, such as a
165
+ `datetime`, `dispatch` raised `TypeError` instead of responding. In a batch,
166
+ the other responses were lost too. That response is now an Internal error,
167
+ and the rest of the batch is sent as usual.
168
+ - A failure outside the method itself used to turn a whole batch into a single
169
+ "Server error" with a null id. Now only the member that failed gets the
170
+ error. One way to hit it was a builtin such as `max`, whose signature can't
171
+ be inspected. Another was a batch member that isn't an object, with
172
+ validation turned off.
173
+ - Methods whose signature can't be inspected are now called, instead of
174
+ failing before the call.
175
+ - `async_dispatch` now accepts plain (non-async) methods as well. Calling an
176
+ async method through `dispatch` gives a clear message in the log, and no
177
+ "coroutine was never awaited" warning.
178
+ - Under `python -O`, a method that returned something other than a `Result`
179
+ broke the whole batch, because the check was an `assert` statement. The
180
+ check now works with `-O` too.
181
+
182
+ ## 5.0.9 (Sep 15, 2022)
183
+
184
+ - Remove unncessary `package_data` from setup.py (#243)
185
+ - Use a custom logger when logging exceptions, not root
186
+
187
+ ## 5.0.8 (Aug 16, 2022)
188
+
189
+ - Use importlib.resources instead of pkg_resources.
190
+
191
+ ## 5.0.7 (Mar 10, 2022)
192
+
193
+ - Upgrade to jsonschema 4.
194
+
195
+ ## 5.0.6 (Jan 14, 2022)
196
+
197
+ - Fix reversed Result Either type ([#227](https://github.com/bensynapse/jsonrpcserver/pull/227)).
198
+
199
+ ## 5.0.5 (Nov 27, 2021)
200
+
201
+ - Documentation.
202
+
203
+ ## 5.0.4 (Oct 27, 2021)
204
+
205
+ - Add to FAQ.
206
+
207
+ ## 5.0.3 (Aug 31, 2021)
208
+
209
+ - Update readme and documentation.
210
+ - Internal function `compose` has been replaced with a better one.
211
+
212
+ ## 5.0.2 (Aug 18, 2021)
213
+
214
+ - Update readme and setup.py, minor adjustments.
215
+
216
+ ## 5.0.1 (Aug 18, 2021)
217
+
218
+ No changelog entry was written for this release. See the `5.0.1` tag.
219
+
220
+ ## 5.0.0 (Aug 16, 2021)
221
+
222
+ A complete rebuild, with a few important usage changes. The
223
+ [migration guide](https://bensynapse.github.io/jsonrpcserver/migration/#from-4x-to-5x)
224
+ shows how to update 4.x code.
225
+
226
+ - Methods must now return a Result (Success or Error).
227
+ - The dispatch function now returns a string.
228
+ - Methods collection is now a simple dict, the Methods class has been removed.
229
+ - Changed all classes (Request, Response, Methods, etc) to namedtuples.
230
+ - Logging removed. User can log instead.
231
+ - Config file removed. Configure with arguments to dispatch.
232
+ - Removed "trim log values" and "convert camel case" options.
233
+ - Removed the custom exceptions, replaced with one JsonRpcError exception.
234
+
235
+ ## 4.2.0 (Nov 9, 2020)
236
+
237
+ - Add ability to use custom serializer and deserializer ([#125](https://github.com/bensynapse/jsonrpcserver/pull/125))
238
+ - Add ability to use custom method name ([#127](https://github.com/bensynapse/jsonrpcserver/pull/127))
239
+ - Deny additional parameters in json-rpc request ([#128](https://github.com/bensynapse/jsonrpcserver/pull/128))
240
+
241
+ Thanks to deptyped.
242
+
243
+ ## 4.1.3 (May 2, 2020)
244
+
245
+ - In the case of a method returning a non-serializable value, return a JSON-RPC
246
+ error response. It was previously erroring server-side without responding to
247
+ the client. (#119)
248
+ - Fix for Python 3.8 - ensures the same exceptions will be raised in 3.8 and
249
+ pre-3.8. (#122)
250
+
251
+ ## 4.1.2 (Jan 9, 2020)
252
+
253
+ - Fix the egg-info directory in package.
254
+
255
+ ## 4.1.1 (Jan 8, 2020)
256
+
257
+ - Fix file permission on all files.
258
+
259
+ ## 4.1.0 (Jan 6, 2020)
260
+
261
+ - Add InvalidParamsError exception, for input validation. Previously the
262
+ advice was to `assert` on input values. However, AssertionError was too
263
+ generic an exception. Instead, raise InvalidParamsError. Note `assert` will
264
+ still work but will be removed in the next major release (5.0).
265
+ - Add an ApiError exception; raise it to send an application defined error
266
+ response. This covers the line in the JSON-RPC spec, "The remainder of the
267
+ space is available for application defined errors."
268
+ - A KeyError raised inside methods will no longer send a "method not found"
269
+ response.
270
+ - Uncaught exceptions raised inside methods will now be logged. We've been
271
+ simply responding to the client with a Server Error. Now the traceback will
272
+ also be logged server-side.
273
+ - Fix a deprecation warning related to collections.abc.
274
+ - Add py.typed to indicate this package supports typing. (PEP 561)
275
+
276
+ Thanks to steinymity for his work on this release.
277
+
278
+ ## 4.0.5 (Sep 10, 2019)
279
+
280
+ - Include license in package.
281
+
282
+ ## 4.0.4 (Jun 22, 2019)
283
+
284
+ - Use faster method of jsonschema validation
285
+ - Use inspect from stdlib, removing the need for funcsigs
286
+
287
+ ## 4.0.3 (Jun 15, 2019)
288
+
289
+ - Update dependencies to allow jsonschema version 3.x
290
+ - Support Python 3.8
291
+
292
+ ## 4.0.2 (Apr 13, 2019)
293
+
294
+ - Fix to allow passing context when no parameters are passed.
295
+
296
+ ## 4.0.1 (Dec 21, 2018)
297
+
298
+ - Include exception in ExceptionResponse. Closes #74.
299
+
300
+ ## 4.0.0 (Oct 14, 2018)
301
+
302
+ _The 4.x releases will support Python 3.6+ only._
303
+
304
+ - Dispatch now works only with `Methods` object. No longer accepts a
305
+ dictionary or list.
306
+ - `dispatch` no longer requires a "methods" argument. If not passed, uses the
307
+ global methods object.
308
+ - Methods initialiser has a simpler api - Methods(func1, func2, ...) or
309
+ Methods(name1=func1, name2=func2, ...).
310
+ - No more jsonrpcserver exceptions. Calling code will _always_ get a valid
311
+ JSON-RPC response from `dispatch`. The old `InvalidParamsError` is gone
312
+ - instead do a regular `assert` on arguments.
313
+ - `response.is_notification` renamed to `response.wanted`, which is the
314
+ opposite of is_notification. This means the original request was not a
315
+ notification, it had an id, and does expect a response.
316
+ - Removed "respond to notification errors" option, which broke the
317
+ specification. We still respond to invalid json/json-rpc requests, in which
318
+ case it's not possible to know if the request is a notification.
319
+ - Removed the "config" module. Added external config file, `.jsonrpcserverrc`.
320
+ (alternatively configure with arguments to dispatch)
321
+ - Removed the "six" dependency, no longer needed.
322
+ - Configure logging Pythonically.
323
+ - Add type hints
324
+ - Move tests to pytest
325
+ - Passing a context object to dispatch now sets it as the first positional
326
+ argument to the method. `def fruits(ctx, color):`
327
+ - Check params with regular asserts.
328
+
329
+ ## 3.5.6 (Jun 28, 2018)
330
+ - Add trim_log_values dispatch param. (#65)
331
+ - Fix a missing import
332
+
333
+ ## 3.5.5 (Jun 19, 2018)
334
+ - Rewrite of dispatch(), adding parameters to configure the dispatch that were
335
+ previously configured by modifying the `config` module. That module is now
336
+ deprecated and will be removed in 4.0.
337
+
338
+ ## 3.5.4 (Apr 30, 2018)
339
+ - Refactoring
340
+
341
+ ## 3.5.3 (Dec 19, 2017)
342
+ - Allow requests to have any non-None id
343
+
344
+ ## 3.5.2 (Sep 19, 2017)
345
+ - Refactor for Request subclassing
346
+
347
+ ## 3.5.1 (Aug 12, 2017)
348
+ - Include context data in regular (synchronous) methods.dispatch
349
+
350
+ ## 3.5.0 (Aug 12, 2017)
351
+ - Pass some context data through dispatch to the methods.
352
+ - Fix not calling notifications in batch requests.
353
+
354
+ ## 3.4.4 (Jul 13, 2017)
355
+ - Fix AttributeError on batch responses
356
+
357
+ ## 3.4.3 (Jul 12, 2017)
358
+ - Add `Response.is_notification` attribute
359
+
360
+ ## 3.4.2 (Jun 9, 2017)
361
+ - Fix `convert_camel_case` with array params
362
+
363
+ ## 3.4.1 (Oct 4, 2016)
364
+ - Disable logging in config
365
+ - Performance improved
366
+ - Fix async batch requests
367
+
368
+ ## 3.4.0 (Sep 27, 2016)
369
+ - Added asyncio support. (Python 3.5+)
370
+ - Added a *methods* object to the jsonrpcserver module (so you can import
371
+ jsonrpcserver.methods, rather than instantiating your own).
372
+ - Added methods.dispatch().
373
+
374
+ ## 3.3.4 (Sep 22, 2016)
375
+ - Fix Methods.serve_forever in python 2 (thanks @bplower)
376
+
377
+ ## 3.3.3 (Sep 15, 2016)
378
+ - Updated method of logging exception (thanks @bplower)
379
+
380
+ ## 3.3.2 (Aug 19, 2016)
381
+ - Pass Methods named args onto MutableMapping
382
+ - Remove unused logger
383
+
384
+ ## 3.3.1 (Aug 5, 2016)
385
+ - Allow passing dict to Methods constructor
386
+
387
+ ## 3.3.0 (Aug 5, 2016)
388
+ - 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.