Nebula - 3.1.2
Nebula 3.1.2 - Release Notes
What’s New
Route return values are now automatically converted into the appropriate response type, removing the need to explicitly specify return_class in most cases.
New Behavior
Previously, you had to define a response class explicitly:
@app.get("/", return_class=HTMLResponse)
async def root() -> None:
return "<h1>Welcome to Nebula!</h1>"Now, Nebula automatically detects the response type:
@app.get("/")
async def root() -> None:
return "<h1>Welcome to Nebula!</h1>"Auto-Detection Rules
Nebula will now automatically wrap return values using the following rules:
-
dictorlist→JSONResponse -
str:- Starts with
<→HTMLResponse - Otherwise →
PlainTextResponse
- Starts with
-
Other types → converted to
strand wrapped inPlainTextResponse
Examples
✅ JSON Response (automatic)
@app.get("/json")
async def json_route():
return {"message": "Hello, world!"}✅ HTML Response (automatic)
@app.get("/html")
async def html_route():
return "<h1>Hello, world!</h1>"✅ Plain Text Response (automatic)
@app.get("/text")
async def text_route():
return "Hello, world!"❌ Old behavior (no longer required)
@app.get("/", return_class=HTMLResponse)
async def root() -> None:
return "<h1>Welcome to Nebula!</h1>"Migration Guide
If your routes previously relied on return_class, you can safely:
- ❌ Remove
return_classfrom your route definitions - ✅ Keep your return values unchanged
Before
@app.get("/", return_class=HTMLResponse)
async def root() -> None:
return "<h1>Welcome to Nebula!</h1>"After
@app.get("/")
async def root() -> None:
return "<h1>Welcome to Nebula!</h1>"Notes
- This change simplifies route definitions and reduces boilerplate.
- Response behavior is now inferred automatically based on return type.
- You can still explicitly return a
Responseinstance to bypass auto-detection.