MCPcopy Create free account
hub / github.com/hynek/structlog / wrap_dict

Function wrap_dict

src/structlog/threadlocal.py:81–99  ·  view source on GitHub ↗

Wrap a dict-like class and return the resulting class. The wrapped class and used to keep global in the current thread. Args: dict_class: Class used for keeping context. .. deprecated:: 22.1.0

(dict_class: type[Context])

Source from the content-addressed store, hash-verified

79
80
81def wrap_dict(dict_class: type[Context]) -> type[Context]:
82 """
83 Wrap a dict-like class and return the resulting class.
84
85 The wrapped class and used to keep global in the current thread.
86
87 Args:
88 dict_class: Class used for keeping context.
89
90 .. deprecated:: 22.1.0
91 """
92 _deprecated()
93 Wrapped = type(
94 "WrappedDict-" + str(uuid.uuid4()), (_ThreadLocalDictWrapper,), {}
95 )
96 Wrapped._tl = ThreadLocal() # type: ignore[attr-defined]
97 Wrapped._dict_class = dict_class # type: ignore[attr-defined]
98
99 return Wrapped
100
101
102TLLogger = TypeVar("TLLogger", bound=BindableLogger)

Calls 1

_deprecatedFunction · 0.85

Tested by 8

_DFunction · 0.72
_logFunction · 0.72
test_tmp_bind_lazyMethod · 0.72
test_is_thread_localMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…