File tree Expand file tree Collapse file tree 4 files changed +21
-6
lines changed Expand file tree Collapse file tree 4 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,13 @@ You can find our backwards-compatibility policy [here](https://github.com/hynek/
15
15
16
16
## [ Unreleased] ( https://github.com/hynek/structlog/compare/24.4.0...HEAD )
17
17
18
+ ## Changed
19
+
20
+ - ` structlog.typing.BindableLogger ` protocol now returns ` Self ` instead of ` BindableLogger ` .
21
+ This adds a dependency on [ * typing-extensions* ] ( https://pypi.org/project/typing-extensions/ ) for Pythons older than 3.11.
22
+
23
+ [ #642 ] ( https://github.com/hynek/structlog/pull/642 )
24
+
18
25
19
26
## [ 24.4.0] ( https://github.com/hynek/structlog/compare/24.3.0...24.4.0 ) - 2024-07-17
20
27
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ classifiers = [
26
26
" Topic :: System :: Logging" ,
27
27
" Typing :: Typed" ,
28
28
]
29
- dependencies = []
29
+ dependencies = [" typing-extensions; python_version<'3.11' " ]
30
30
31
31
[project .urls ]
32
32
Documentation = " https://www.structlog.org/"
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ def tmp_bind(
152
152
153
153
saved = as_immutable (logger )._context
154
154
try :
155
- yield logger .bind (** tmp_values ) # type: ignore[misc]
155
+ yield logger .bind (** tmp_values )
156
156
finally :
157
157
logger ._context .clear ()
158
158
logger ._context .update (saved )
Original file line number Diff line number Diff line change 14
14
15
15
from __future__ import annotations
16
16
17
+ import sys
18
+
17
19
from types import TracebackType
18
20
from typing import (
19
21
Any ,
31
33
)
32
34
33
35
36
+ if sys .version_info >= (3 , 11 ):
37
+ from typing import Self
38
+ else :
39
+ from typing_extensions import Self
40
+
41
+
34
42
WrappedLogger = Any
35
43
"""
36
44
A logger that is wrapped by a bound logger and is ultimately responsible for
@@ -130,13 +138,13 @@ class BindableLogger(Protocol):
130
138
131
139
_context : Context
132
140
133
- def bind (self , ** new_values : Any ) -> BindableLogger : ...
141
+ def bind (self , ** new_values : Any ) -> Self : ...
134
142
135
- def unbind (self , * keys : str ) -> BindableLogger : ...
143
+ def unbind (self , * keys : str ) -> Self : ...
136
144
137
- def try_unbind (self , * keys : str ) -> BindableLogger : ...
145
+ def try_unbind (self , * keys : str ) -> Self : ...
138
146
139
- def new (self , ** new_values : Any ) -> BindableLogger : ...
147
+ def new (self , ** new_values : Any ) -> Self : ...
140
148
141
149
142
150
class FilteringBoundLogger (BindableLogger , Protocol ):
You can’t perform that action at this time.
0 commit comments