Skip to content

Commit ea3b7c6

Browse files
committed
wip
1 parent 94e1a48 commit ea3b7c6

File tree

1 file changed

+284
-1
lines changed

1 file changed

+284
-1
lines changed

docs/release-notes/changelog.rst

Lines changed: 284 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,289 @@
33
2.x Changelog
44
=============
55

6+
.. changelog:: 2.16.0
7+
:date: 2025-05-04
8+
9+
.. change:: disable stack trace
10+
:type: feature
11+
:pr: 4086
12+
:issue: 4081
13+
14+
## Example
15+
16+
```py
17+
import uvicorn
18+
19+
from litestar import Litestar, get
20+
from litestar.logging import LoggingConfig
21+
22+
23+
@get("/")
24+
async def index() -> str:
25+
return "Hello, world!"
26+
27+
28+
@get("/value-error")
29+
async def value_error() -> None:
30+
raise ValueError("This is a test value error.") # not log the stack trace
31+
32+
33+
@get("/name-error")
34+
async def name_error() -> None:
35+
raise NameError("This is a test name error.")
36+
37+
38+
app = Litestar(
39+
route_handlers=[index, value_error, name_error],
40+
debug=True,
41+
logging_config=LoggingConfig(
42+
disable_stack_trace={404, ValueError} # disable_stack_trace: set[Union[int, type[Exception]]]
43+
),
44+
)
45+
46+
47+
if __name__ == "__main__":
48+
uvicorn.run(app=app, port=8621)
49+
50+
```
51+
52+
.. change:: add custom example ids support
53+
:type: feature
54+
:pr: 4133
55+
:issue: 4013
56+
57+
- resolved #4013
58+
59+
.. change:: add self to validate_handler_fn error message
60+
:type: feature
61+
:pr: 4157
62+
63+
<!--
64+
By submitting this pull request, you agree to:
65+
- follow [Litestar's Code of Conduct](https://github.com/litestar-org/.github/blob/main/CODE_OF_CONDUCT.md)
66+
- follow [Litestar's contribution guidelines](https://github.com/litestar-org/.github/blob/main/CONTRIBUTING.md)
67+
- follow the [PSFs's Code of Conduct](https://www.python.org/psf/conduct/)
68+
-->
69+
## Description
70+
annotated a @\delete with a response type dict; and this was bugging me.
71+
72+
-
73+
74+
<!--
75+
Please add in issue numbers this pull request will close, if applicable
76+
Examples: Fixes #4321 or Closes #1234
77+
78+
Ensure you are using a supported keyword to properly link an issue:
79+
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
80+
-->
81+
## Closes
82+
83+
.. change:: Populate `linecache` for generated transfer functions
84+
:type: feature
85+
:pr: 4159
86+
87+
Doing this enables:
88+
89+
- Better tracebacks, that include references to the actual program source
90+
- Introspection via e.g. `inspect.getsource`
91+
92+
93+
**Before**
94+
```
95+
File "/home/.../projekte/litestar-django/.venv/lib/python3.13/site-packages/litestar/dto/base_dto.py", line 121, in data_to_encodable_type
96+
return backend.encode_data(data)
97+
~~~~~~~~~~~~~~~~~~~^^^^^^
98+
File "/home/.../projekte/litestar-django/.venv/lib/python3.13/site-packages/litestar/dto/_codegen_backend.py", line 163, in encode_data
99+
return cast("LitestarEncodableType", self._encode_data(data))
100+
~~~~~~~~~~~~~~~~~^^^^^^
101+
File "<string>", line 18, in func
102+
TypeError: <something's wrong>
103+
```
104+
105+
**After**
106+
```
107+
File "/home/john/projekte/litestar-django/.venv/lib/python3.13/site-packages/litestar/dto/_codegen_backend.py", line 163, in encode_data
108+
return cast("LitestarEncodableType", self._encode_data(data))
109+
~~~~~~~~~~~~~~~~~^^^^^^
110+
File "dto_transfer_function_0971e01f653c", line 18, in func
111+
unstructured_data_0['items'] = origin_1(transfer_type_data_1(item) for item in source_instance_0.items)
112+
^^^^^^^^^^^^^^^^^^^^^^^
113+
TypeError: <something's wrong>
114+
115+
```
116+
117+
.. change:: Add custom attribute accessor callable
118+
:type: feature
119+
:pr: 4160
120+
121+
Add a new `attribute_accessor` property to `AbstractDTO`, which can be used by both the codegen and functional backend to access attributes on an object.
122+
123+
This can be useful to implement DTOs for types that do not adhere to the plain protocol of `obj.data_field` or need to add additional checks, e.g. using `obj.related_field.all()` on a Django model to access related objects, while ensuring no I/O occurs.
124+
125+
.. change:: add scalar configuration
126+
:type: feature
127+
:pr: 4162
128+
129+
<!--
130+
By submitting this pull request, you agree to:
131+
- follow [Litestar's Code of Conduct](https://github.com/litestar-org/.github/blob/main/CODE_OF_CONDUCT.md)
132+
- follow [Litestar's contribution guidelines](https://github.com/litestar-org/.github/blob/main/CONTRIBUTING.md)
133+
- follow the [PSFs's Code of Conduct](https://www.python.org/psf/conduct/)
134+
-->
135+
## Description
136+
137+
Hello! I'm currently work on adding scalar configuration and during work got some questions:
138+
139+
- I start adding config params from [here](https://github.com/scalar/scalar/blob/main/documentation/configuration.md), but not sure about including every param. What should we add?
140+
- Here is MRE for how to work with configuration:
141+
```python
142+
from litestar import Litestar, get
143+
from litestar.openapi.config import OpenAPIConfig
144+
from litestar.openapi.datastructures import ScalarConfig
145+
from litestar.openapi.plugins import ScalarRenderPlugin
146+
147+
scalar_plugin = ScalarRenderPlugin(version="1.19.5", config=ScalarConfig(show_sidebar=False))
148+
149+
@get("/")
150+
async def hello_world() -> dict[str, str]:
151+
"""Keeping the tradition alive with hello world."""
152+
return {"hello": "world"}
153+
154+
app = Litestar(
155+
route_handlers=[hello_world],
156+
openapi_config=OpenAPIConfig(
157+
title="Litestar Example",
158+
description="Example of Litestar with Scalar OpenAPI docs",
159+
version="0.0.1",
160+
render_plugins=[scalar_plugin],
161+
path="/docs",
162+
),
163+
)
164+
```
165+
I'm not sure about config `dataclass` object location. Maybe it must be somewhere else?
166+
- The config could change with changing Scalar version and we have `version` arg in `ScalarRenderPlugin`. So should we somehow detect difference?
167+
168+
<!--
169+
Please add in issue numbers this pull request will close, if applicable
170+
Examples: Fixes #4321 or Closes #1234
171+
172+
Ensure you are using a supported keyword to properly link an issue:
173+
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
174+
-->
175+
## Closes
176+
#3951
177+
178+
.. change:: update Makefile to include install in output
179+
:type: bugfix
180+
:pr: 4079
181+
:issue: 4057
182+
183+
<!--
184+
By submitting this pull request, you agree to:
185+
- follow [Litestar's Code of Conduct](https://github.com/litestar-org/.github/blob/main/CODE_OF_CONDUCT.md)
186+
- follow [Litestar's contribution guidelines](https://github.com/litestar-org/.github/blob/main/CONTRIBUTING.md)
187+
- follow the [PSFs's Code of Conduct](https://www.python.org/psf/conduct/)
188+
-->
189+
## Description
190+
191+
-
192+
193+
<!--
194+
Please add in issue numbers this pull request will close, if applicable
195+
Examples: Fixes #4321 or Closes #1234
196+
197+
Ensure you are using a supported keyword to properly link an issue:
198+
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
199+
-->
200+
## Closes
201+
202+
203+
Closed https://github.com/litestar-org/litestar/issues/4057
204+
205+
.. change:: Remove usage of private `_AnnotatedAlias`
206+
:type: bugfix
207+
:pr: 4126
208+
209+
See https://github.com/python/typing_extensions/issues/586.
210+
211+
We're not using this functionality anymore, so keeping this around just for backwards compatibility.
212+
213+
.. change:: Ensure dependencies are cleaned up when exception occurrs during cleanup
214+
:type: bugfix
215+
:pr: 4148
216+
217+
Fix a bug where a dependencies' cleanup was not guaranteed to be called would not be called if an exception was thrown:
218+
219+
- Late during ASGI response rendering
220+
- During cleanup of another dependency when recovering from an exception
221+
222+
<hr>
223+
224+
Refactor the code such that:
225+
226+
- Exceptions are always caught and thrown into dependencies as long as the dependencies are alive
227+
- If the handler raises an exception and during dependency cleanup other exceptions are raised, the sub-exceptions are grouped into an `ExceptionGroup`. This behaviour is now equivalent to regular dependency cleanup
228+
229+
.. change:: misleading error message upon ImportError with --app argument to CLI
230+
:type: bugfix
231+
:pr: 4152
232+
:issue: 4129
233+
234+
## Description
235+
236+
Fixes #4129
237+
238+
Before this PR, if the `--app` CLI option is used, any `ImportErrors` that occur while instantiating the application are assumed to be caused by a bad `--app` argument. This does not account for cases where the `--app` option is actually fine, but the `ImportError` arose from inside the applicaiton code, and this results in a misleading error message.
239+
240+
This PR adds a check on whether the exception resulted from a failure to import the module named in the `--app` option. If the error arose while attempting some other import, it is not caught. This is consistent with the behaviour that occurs when `--app` is not used.
241+
242+
.. change:: subprocess client raises exc when fails to start
243+
:type: bugfix
244+
:pr: 4153
245+
:issue: 4021
246+
247+
## Description
248+
249+
Fix #4021
250+
- Added two new parameters to `run_app` method: `retry_count` and `retry_timeout`
251+
- `run_app` now throws `StartupError` if application doesn't start on time
252+
253+
## Closes
254+
- litestar-org/litestar#4021
255+
256+
.. change:: support prefixItems for tuple schema
257+
:type: bugfix
258+
:pr: 4132
259+
:issue: 4130
260+
261+
- resolved #4130
262+
263+
The previous implementation incorrectly treated Python tuples as arrays with items of a single, uniform type.
264+
265+
This change utilizes prefixItems (OpenAPI 3.1+) to correctly specify the type for each element at its specific position when the field is a tuple. This results in a more accurate and modern OpenAPI schema that precisely reflects the Python tuple structure.
266+
267+
Additionally:
268+
269+
- Adjusted assertions in `test_schema_tuple_with_union` as the original expectations seemed incorrect with the proper schema generation.
270+
- Added a new test case `test_schema_tuple`.
271+
272+
.. change:: pre parse launch arguments when cli command executed
273+
:type: bugfix
274+
:pr: 4161
275+
:issue: 2783
276+
277+
## Description
278+
279+
Fix #2783
280+
281+
The issue was that when the `--help` command was passed, Click did not parse the others incoming arguments (e.g. `--app`), and autodiscovery feature didn't work as planned because the file containing the application was not in the default list (`AUTODISCOVERY_FILE_NAMES`). As a result, we ignored the `--app` argument and didn't loading plugins, which led to plugin commands not appearing in the list.
282+
283+
As a solution, I propose to override the `Group.parse_args` method to manually parse the arguments that tell us where the application is located.
284+
285+
## Closes
286+
- litestar-org/litestar#2783
287+
288+
6289
.. changelog:: 2.15.2
7290
:date: 2025-04-06
8291

@@ -5995,4 +6278,4 @@
59956278
:issue: 1149
59966279

59976280
A middleware's ``exclude`` parameter would sometimes not be honoured if the path was used to serve static files
5998-
using ``StaticFilesConfig``
6281+
using ``StaticFilesConfig``

0 commit comments

Comments
 (0)