Skip to content

Commit 3f8be84

Browse files
committed
v2.16.0
1 parent 94e1a48 commit 3f8be84

File tree

3 files changed

+157
-2
lines changed

3 files changed

+157
-2
lines changed

docs/release-notes/changelog.rst

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,161 @@
22

33
2.x Changelog
44
=============
5+
.. changelog:: 2.16.0
6+
:date: 2025-05-04
7+
8+
.. change:: Logging: Selectively disable logging for status codes or exception types
9+
:type: feature
10+
:pr: 4086
11+
:issue: 4081
12+
13+
14+
Add support for disabling stack traces for specific status codes or exception
15+
types when in debug mode or running with ``log_exceptions="always"``
16+
17+
.. code-block:: python
18+
:caption: Disable tracebacks for '404 - Not Found' exceptions
19+
20+
from litestar import Litestar, get
21+
from litestar.logging import LoggingConfig
22+
23+
app = Litestar(
24+
route_handlers=[index, value_error, name_error],
25+
logging_config=LoggingConfig(
26+
disable_stack_trace={404},
27+
log_exceptions="always",
28+
),
29+
)
30+
31+
32+
.. change:: Reference route handler in error message for return value / status code mismatch
33+
:type: feature
34+
:pr: 4157
35+
36+
Improve error message of :exc:`ImproperlyConfiguredException` raised when a
37+
route handler's return value annotation is incompatible with its status code.
38+
39+
40+
.. change:: DTO: Improve inspection and tracebacks for generated functions
41+
:type: feature
42+
:pr: 4159
43+
44+
Generated transfer functions now populate :mod:`linecache` to improve
45+
tracebacks and support introspection of the generated functions e.g. via
46+
:func:`inspect.getsource`
47+
48+
**Before:**
49+
50+
.. code-block:: text
51+
52+
File "<string>", line 18, in func
53+
TypeError: <something's wrong>
54+
55+
**After:**
56+
57+
.. code-block:: text
58+
59+
File "dto_transfer_function_0971e01f653c", line 18, in func
60+
TypeError: <something's wrong>
61+
62+
63+
.. change:: DTO: Add custom attribute accessor callable
64+
:type: feature
65+
:pr: 4160
66+
67+
Add :attr:`~litestar.dto.base_dto.AbstractDTO.attribute_accessor` property to
68+
``AbstractDTO``, that can be set to a custom :func:`getattr`\ -like function
69+
which will be used every time an attribute is accessed on a source instance
70+
71+
72+
.. change:: Typing: remove usage of private ``_AnnotatedAlias``
73+
:type: bugfix
74+
:pr: 4126
75+
76+
Remove deprecated usage of ``_AnnotatedAlias``, which is no longer needed for
77+
backwards compatibility.
78+
79+
.. change:: DI: Ensure generator dependencies always handle error during clean up
80+
:type: bugfix
81+
:pr: 4148
82+
83+
Fix issue where dependency cleanup could be skipped during exception handling,
84+
if another exception happened during the cleanup itself.
85+
86+
- Ensure all dependencies are cleaned up, even if exceptions occur.
87+
- Group exceptions using :exc:`ExceptionGroup` during cleanup phase.
88+
89+
90+
.. change:: CLI: Improve error message on ``ImportError``
91+
:type: bugfix
92+
:pr: 4152
93+
:issue: 4129
94+
95+
Fix misleading error message when using ``--app`` CLI argument and an unrelated
96+
:exc:`ImportError` occurs. Unrelated import errors will now propagate as usual
97+
98+
.. change:: CLI: Ensure dynamically added commands / groups are always visible
99+
:type: bugfix
100+
:pr: 4161
101+
:issue: 2783
102+
103+
Fix an issue where dynamically added commands or groups were not always visible
104+
during listing e.g. via ``--help``
105+
106+
.. change:: Testing: Ensure subprocess client does not swallow startup failure
107+
:type: bugfix
108+
:pr: 4153
109+
:issue: 4021
110+
111+
Ensure ``StartupError`` is raised by
112+
:func:`~litestar.testing.subprocess_sync_client` and
113+
:func:`~litestar.testing.subprocess_async_client`
114+
if the application failed to start within the timeout.
115+
116+
.. change:: OpenAPI: Use ``prefixItems`` for fixed-length tuples
117+
:type: bugfix
118+
:pr: 4132
119+
:issue: 4130
120+
121+
Use ``prefixItems`` instead of ``array`` syntax to render fixed-length tuples
122+
123+
124+
.. change:: OpenAPI: Add custom example ids support
125+
:type: feature
126+
:pr: 4133
127+
:issue: 4013
128+
129+
Add a new field ``id`` to :class:`~litestar.openapi.spec.Example`, to set a
130+
custom ID for examples
131+
132+
.. change:: OpenAPI: Allow passing scalar configuration options
133+
:type: feature
134+
:pr: 4162
135+
:issue: 3951
136+
137+
Add an ``options`` parameter to
138+
:class:`~litestar.openapi.plugins.ScalarRenderPlugin`, that can be used to pass
139+
options directly to scalar.
140+
141+
.. code-block:: python
142+
143+
from litestar import Litestar, get
144+
from litestar.openapi.config import OpenAPIConfig
145+
from litestar.openapi.plugins import ScalarRenderPlugin
146+
147+
scalar_plugin = ScalarRenderPlugin(version="1.19.5", options={"showSidebar": False})
148+
149+
app = Litestar(
150+
route_handlers=[hello_world],
151+
openapi_config=OpenAPIConfig(
152+
title="Litestar Example",
153+
description="Example of Litestar with Scalar OpenAPI docs",
154+
version="0.0.1",
155+
render_plugins=[scalar_plugin],
156+
path="/docs",
157+
),
158+
)
159+
5160
6161
.. changelog:: 2.15.2
7162
:date: 2025-04-06

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ maintainers = [
6464
name = "litestar"
6565
readme = "README.md"
6666
requires-python = ">=3.8,<4.0"
67-
version = "2.15.2"
67+
version = "2.16.0"
6868

6969
[project.urls]
7070
Blog = "https://blog.litestar.dev"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)