Skip to content
Merged
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
9 changes: 1 addition & 8 deletions sentry_sdk/integrations/_wsgi_common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from contextlib import contextmanager
from copy import deepcopy

import sentry_sdk
Expand All @@ -18,7 +17,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any, Dict, Iterator, Mapping, MutableMapping, Optional, Union
from typing import Any, Dict, Mapping, MutableMapping, Optional, Union

from sentry_sdk._types import Event, HttpStatusCodeRange

Expand Down Expand Up @@ -52,12 +51,6 @@
)


# This noop context manager can be replaced with "from contextlib import nullcontext" when we drop Python 3.6 support
@contextmanager
def nullcontext() -> "Iterator[None]":
yield


def request_body_within_bounds(
client: "Optional[sentry_sdk.client.BaseClient]", content_length: int
) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
)
from sentry_sdk.integrations._wsgi_common import (
DEFAULT_HTTP_METHODS_TO_CAPTURE,
nullcontext,
)
from sentry_sdk.scope import Scope, should_send_default_pii
from sentry_sdk.sessions import track_session
Expand All @@ -49,6 +48,7 @@
capture_internal_exceptions,
event_from_exception,
logger,
nullcontext,
qualname_from_function,
reraise,
transaction_from_function,
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import sentry_sdk
from sentry_sdk.consts import OP
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations._wsgi_common import nullcontext
from sentry_sdk.traces import StreamedSpan
from sentry_sdk.tracing import Span
from sentry_sdk.tracing_utils import has_span_streaming_enabled
Expand All @@ -13,6 +12,7 @@
event_from_exception,
is_internal_task,
logger,
nullcontext,
reraise,
)

Expand Down
3 changes: 1 addition & 2 deletions sentry_sdk/integrations/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
from sentry_sdk.ai.utils import _set_span_data_attribute, get_start_span_function
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations._wsgi_common import nullcontext
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.traces import StreamedSpan
from sentry_sdk.tracing_utils import has_span_streaming_enabled
from sentry_sdk.utils import package_version, safe_serialize
from sentry_sdk.utils import nullcontext, package_version, safe_serialize

MCP_PACKAGE_VERSION = package_version("mcp")

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from sentry_sdk.integrations._wsgi_common import (
DEFAULT_HTTP_METHODS_TO_CAPTURE,
_filter_headers,
nullcontext,
)
from sentry_sdk.scope import Scope, should_send_default_pii, use_isolation_scope
from sentry_sdk.sessions import track_session
Expand All @@ -20,6 +19,7 @@
ContextVar,
capture_internal_exceptions,
event_from_exception,
nullcontext,
reraise,
)

Expand Down
6 changes: 6 additions & 0 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2176,3 +2176,9 @@ def serialize_attribute(val: "AttributeValue") -> "SerializedAttributeValue":
# Coerce to string if we don't know what to do with the value. This should
# never happen as we pre-format early in format_attribute, but let's be safe.
return {"value": safe_repr(val), "type": "string"}


# This noop context manager can be replaced with "from contextlib import nullcontext" when we drop Python 3.6 support
@contextmanager
def nullcontext() -> "Iterator[None]":
yield
Loading