blackbull¶
blackbull
¶
BlackBull — async ASGI 3.0 web framework.
Early Alpha — API may break between MINOR versions; see
KNOWN_LIMITATIONS.md before building production-shape work on top.
Public API exports:
BlackBull: the main application object; wraps routing, middleware, and lifespan hooks.AppConfig: declarative, immutable holder for the startup settingsrun()accepts (port, TLS, workers, …).serve: synchronous entry point that runs any ASGI 3.0 callable (also used by theblackbullconsole script).Response,JSONResponse,RedirectResponse,StreamingResponse,EventSourceResponse,WebSocketResponse: response helpers.RouteInfo: immutable(method, path, name)snapshot returned byapp.get_routes().QUERY: the HTTP QUERY method (RFC 10008) as a plain string —http.HTTPMethodlacks the member until Python ≥3.16.UnprocessableQuery: raise from a QUERY handler for422when the (accepted) request media type carries a semantically unprocessable query (RFC 10008).Headers: case-insensitive, ordered, multi-valued HTTP header store.Connection: the typed internal request representation (Sprint 79); the handler context object exposingmethod/path/headers/cookies/body()/json()/text(). The ASGIscopeis a derived view (Connection.as_scope()).Request: deprecated alias ofConnection(Sprint 79 Phase 5). Accessingblackbull.Requestemits aDeprecationWarning; replacerequest: Requesthandler params withconn: Connection(identical API). Removal no earlier than 2027-08-01.Depends: per-request provider injection for simplified handlers (async-generator providers get teardown after the response is sent).cookie_header: builds aSet-Cookieheader tuple.read_body: reads and buffers the full request body from the ASGI receive channel.read_json: reads the body and parses it as JSON (Noneon empty/invalid).read_text: reads the body and decodes it as text.parse_cookies: parses theCookieheader into a plaindict.CORS: addsAccess-Control-*headers; handles preflight OPTIONS requests.as_middleware: decorator that marks an async function or class as middleware; normalisessendso inner wrappers see only ASGI event dicts.TrustedProxy: rewritesscope['client']/scope['scheme']from proxy headers.
Importing this package does not load the server stack
(blackbull.server.*). Use ASGIServer from blackbull.server
when you want to embed BlackBull's own server; otherwise pass the
BlackBull instance to any external ASGI server (uvicorn, hypercorn,
granian, …) since BlackBull.__call__ is ASGI 3.0 compliant.
__getattr__(name)
¶
Lazy, deprecated attribute access — blackbull.Request.
Request was the opt-in HTTP context object; Sprint 79 Phase 5 merged
it into :class:Connection and demoted the name to an alias. Resolving it
through the module __getattr__ (PEP 562) means the DeprecationWarning
fires only if code actually touches Request — importing the package
stays warning-free — and the alias still evaluates to Connection so
existing request: Request handler signatures keep working unchanged
during the migration window (removal no earlier than 2027-08-01).