Build and Push Docker Container / build-and-push (push) Successful in 2m25s
- Require Python 3.15 for the server and Python 3.14 for the CLI. - Match the server requirement to quart_common's Python 3.15 features. - Replace future annotations with native deferred evaluation. - Defer CLI command dependencies and QR imports on Python 3.15. - Enable argparse suggestions for mistyped CLI commands. - Remove the obsolete tomllib import fallback. - Update my_helpers and quart_common submodule references. - Lock test dependencies and exclude them from Docker installations. - Add regression coverage for lazy imports and deferred annotations. - Document runtime requirements and standalone CLI validation. - Validate 276 tests on Python 3.15 and 18 CLI tests on Python 3.14. BREAKING CHANGE: The server now requires Python 3.15+ and the standalone CLI requires Python 3.14+.
30 lines
868 B
Python
30 lines
868 B
Python
import time
|
|
import uuid
|
|
|
|
PROTOCOL_VERSION = 1
|
|
JSON_CT = 'application/json'
|
|
|
|
def request_envelope(method: str, params: dict | None = None, *, source: str, target: str) -> dict:
|
|
return {
|
|
'sl': PROTOCOL_VERSION,
|
|
'id': uuid.uuid4().hex,
|
|
'kind': 'request',
|
|
'method': method,
|
|
'source': source,
|
|
'target': target,
|
|
'params': dict(params or {}),
|
|
'meta': {'ts': time.time()},
|
|
}
|
|
|
|
def unwrap_response(data: dict):
|
|
if data.get('kind') == 'response':
|
|
if data.get('ok') is True:
|
|
return data.get('result')
|
|
error = data.get('error') if isinstance(data.get('error'), dict) else {}
|
|
code = error.get('code', 'remote_error')
|
|
message = error.get('message', 'remote error')
|
|
raise RuntimeError(f'{code}: {message}')
|
|
if data.get('ok') is False and data.get('error'):
|
|
raise RuntimeError(str(data.get('error')))
|
|
return data
|