Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/structlog/contextvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

from collections.abc import Generator, Mapping
from types import FrameType
from typing import Any
from typing import Any, Final

import structlog

from .typing import BindableLogger, EventDict, WrappedLogger


STRUCTLOG_KEY_PREFIX = "structlog_"
STRUCTLOG_KEY_PREFIX_LEN = len(STRUCTLOG_KEY_PREFIX)
STRUCTLOG_KEY_PREFIX: Final = "structlog_"
STRUCTLOG_KEY_PREFIX_LEN: Final = len(STRUCTLOG_KEY_PREFIX)

_ASYNC_CALLING_STACK: contextvars.ContextVar[FrameType] = (
contextvars.ContextVar("_ASYNC_CALLING_STACK")
Expand Down
2 changes: 1 addition & 1 deletion src/structlog/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def __call__(self, sio: TextIO, exc_info: ExcInfo) -> None:

if rich is None:

def rich_traceback(*args, **kw):
def rich_traceback(sio: TextIO, exc_info: ExcInfo) -> None:
raise ModuleNotFoundError(
"RichTracebackFormatter requires Rich to be installed.",
name="rich",
Expand Down
5 changes: 3 additions & 2 deletions src/structlog/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from typing import (
Any,
ClassVar,
Final,
NamedTuple,
TextIO,
cast,
Expand Down Expand Up @@ -424,7 +425,7 @@ def __call__(
return event_dict


format_exc_info = ExceptionRenderer()
format_exc_info: Final = ExceptionRenderer()
"""
Replace an ``exc_info`` field with an ``exception`` string field using Python's
built-in traceback formatting.
Expand All @@ -445,7 +446,7 @@ def __call__(
features.
"""

dict_tracebacks = ExceptionRenderer(ExceptionDictTransformer())
dict_tracebacks: Final = ExceptionRenderer(ExceptionDictTransformer())
"""
Replace an ``exc_info`` field with an ``exception`` field containing structured
tracebacks suitable for, e.g., JSON output.
Expand Down
4 changes: 2 additions & 2 deletions src/structlog/threadlocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import warnings

from collections.abc import Generator, Iterator
from typing import Any, TypeVar
from typing import Any, Final, TypeVar

import structlog

Expand All @@ -44,7 +44,7 @@ def _determine_threadlocal() -> type[Any]:
return GreenThreadLocal # pragma: no cover


ThreadLocal = _determine_threadlocal()
ThreadLocal: Final[type] = _determine_threadlocal()


def _deprecated() -> None:
Expand Down