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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ ignore = [
"N804", # First argument of classmethod should be named cls

# Additional ignores for codebase compatibility
"F401", # Unused imports - many in TYPE_CHECKING blocks used for type comments
"E721", # Use isinstance instead of type() == - existing pattern in this codebase
]

Expand Down
1 change: 0 additions & 1 deletion scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from packaging.specifiers import SpecifierSet
from packaging.version import Version
from pathlib import Path
from textwrap import dedent
from typing import Optional, Union

# Adding the scripts directory to PATH. This is necessary in order to be able
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime, timezone
from typing import TYPE_CHECKING, TypeVar, Generic

from sentry_sdk.utils import format_timestamp, safe_repr, serialize_attribute
from sentry_sdk.utils import format_timestamp
from sentry_sdk.envelope import Envelope, Item, PayloadRef

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/_log_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sentry_sdk._batcher import Batcher
from sentry_sdk.utils import serialize_attribute
from sentry_sdk.envelope import Envelope, Item, PayloadRef
from sentry_sdk.envelope import Item, PayloadRef

if TYPE_CHECKING:
from typing import Any
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/_metrics_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from sentry_sdk._batcher import Batcher
from sentry_sdk.utils import serialize_attribute
from sentry_sdk.envelope import Item

if TYPE_CHECKING:
from typing import Any
Expand Down
4 changes: 1 addition & 3 deletions sentry_sdk/_span_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
from typing import TYPE_CHECKING

from sentry_sdk._batcher import Batcher
from sentry_sdk.consts import SPANSTATUS
from sentry_sdk.envelope import Envelope, Item, PayloadRef
from sentry_sdk.utils import format_timestamp, serialize_attribute, safe_repr
from sentry_sdk.utils import format_timestamp, serialize_attribute

if TYPE_CHECKING:
from typing import Any, Callable, Optional
from sentry_sdk.traces import StreamedSpan
from sentry_sdk._types import SerializedAttributeValue


class SpanBatcher(Batcher["StreamedSpan"]):
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def substituted_because_contains_sensitive_data(cls) -> "AnnotatedValue":
from typing import Mapping
from typing import NotRequired
from typing import Optional
from typing import Tuple
from typing import Type
from typing_extensions import Literal, TypedDict

Expand Down
14 changes: 7 additions & 7 deletions sentry_sdk/ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .utils import (
set_data_normalized,
GEN_AI_MESSAGE_ROLE_MAPPING,
GEN_AI_MESSAGE_ROLE_REVERSE_MAPPING,
normalize_message_role,
normalize_message_roles,
set_conversation_id,
) # noqa: F401
set_data_normalized, # noqa: F401
GEN_AI_MESSAGE_ROLE_MAPPING, # noqa: F401
GEN_AI_MESSAGE_ROLE_REVERSE_MAPPING, # noqa: F401
normalize_message_role, # noqa: F401
normalize_message_roles, # noqa: F401
set_conversation_id, # noqa: F401
)
2 changes: 0 additions & 2 deletions sentry_sdk/ai/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import inspect
import json
from collections import deque
from copy import deepcopy
from sys import getsizeof
from typing import TYPE_CHECKING

from sentry_sdk._types import BLOB_DATA_SUBSTITUTE
Expand Down
4 changes: 1 addition & 3 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from typing import TYPE_CHECKING, List, Dict, cast, overload
import warnings

import sentry_sdk
from sentry_sdk._compat import PY37, check_uwsgi_thread_support
from sentry_sdk._compat import check_uwsgi_thread_support
from sentry_sdk._metrics_batcher import MetricsBatcher
from sentry_sdk._span_batcher import SpanBatcher
from sentry_sdk.utils import (
Expand All @@ -23,7 +22,6 @@
get_type_name,
get_default_release,
handle_in_app,
is_gevent,
logger,
get_before_send_log,
get_before_send_metric,
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class CompressionAlgo(Enum):
Hint,
IgnoreSpansConfig,
Log,
MeasurementUnit,
Metric,
ProfilerMode,
TracesSampler,
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
raise DidNotEnable("Anthropic not installed")

if TYPE_CHECKING:
from typing import Any, AsyncIterator, Iterator, List, Optional, Union
from typing import Any, AsyncIterator, Iterator, Optional, Union
from sentry_sdk.tracing import Span
from sentry_sdk._types import TextPart

Expand Down
3 changes: 1 addition & 2 deletions sentry_sdk/integrations/django/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import sentry_sdk
from sentry_sdk.consts import OP
from sentry_sdk.tracing import SPANSTATUS
from sentry_sdk.utils import qualname_from_function

try:
# django.tasks were added in Django 6.0
from django.tasks.base import Task, TaskResultStatus
from django.tasks.base import Task
except ImportError:
Task = None

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/google_genai/streaming.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Any, List, TypedDict, Optional, Union
from typing import TYPE_CHECKING, Any, List, TypedDict, Optional

from sentry_sdk.ai.utils import set_data_normalized
from sentry_sdk.consts import SPANDATA
Expand Down
2 changes: 0 additions & 2 deletions sentry_sdk/integrations/google_genai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from .consts import ORIGIN, TOOL_ATTRIBUTES_MAP, GEN_AI_SYSTEM
from sentry_sdk._types import BLOB_DATA_SUBSTITUTE
from typing import (
cast,
TYPE_CHECKING,
Iterable,
Any,
Expand All @@ -22,7 +21,6 @@
set_data_normalized,
truncate_and_annotate_messages,
normalize_message_roles,
redact_blob_message_parts,
transform_google_content_part,
get_modality_from_mime_type,
)
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/grpc/aio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from sentry_sdk.consts import OP
from sentry_sdk.integrations import DidNotEnable
from sentry_sdk.integrations.grpc.consts import SPAN_ORIGIN
from sentry_sdk.tracing import Transaction, TransactionSource
from sentry_sdk.tracing import TransactionSource
from sentry_sdk.utils import event_from_exception

from typing import TYPE_CHECKING
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/grpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from sentry_sdk.consts import OP
from sentry_sdk.integrations import DidNotEnable
from sentry_sdk.integrations.grpc.consts import SPAN_ORIGIN
from sentry_sdk.tracing import Transaction, TransactionSource
from sentry_sdk.tracing import TransactionSource

from typing import TYPE_CHECKING

Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/integrations/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
from openai.types.chat import (
ChatCompletionMessageParam,
ChatCompletionChunk,
ChatCompletionSystemMessageParam,
)
except ImportError:
raise DidNotEnable("OpenAI not installed")
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/integrations/openai_agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# not installed. That's why we're adding the second, more specific import
# after it, even if we don't use it.
import agents
from agents.run import DEFAULT_AGENT_RUNNER
from agents.run import AgentRunner
from agents.version import __version__ as OPENAI_AGENTS_VERSION

Expand Down
10 changes: 5 additions & 5 deletions sentry_sdk/integrations/openai_agents/patches/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from .tools import _get_all_tools # noqa: F401
from .runner import _create_run_wrapper, _create_run_streamed_wrapper # noqa: F401
from .agent_run import (
_run_single_turn,
_run_single_turn_streamed,
_execute_handoffs,
_execute_final_output,
) # noqa: F401
_run_single_turn, # noqa: F401
_run_single_turn_streamed, # noqa: F401
_execute_handoffs, # noqa: F401
_execute_final_output, # noqa: F401
)
from .error_tracing import _patch_error_tracing # noqa: F401
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from functools import wraps

from sentry_sdk.consts import SPANDATA
from sentry_sdk.integrations import DidNotEnable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from functools import wraps

import sentry_sdk
from sentry_sdk.consts import SPANSTATUS
from sentry_sdk.tracing_utils import set_span_errored
from ..utils import _record_exception_on_span

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any, Callable, Optional
from typing import Any


def _patch_error_tracing() -> None:
Expand Down
8 changes: 4 additions & 4 deletions sentry_sdk/integrations/openai_agents/spans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .execute_tool import execute_tool_span, update_execute_tool_span # noqa: F401
from .handoff import handoff_span # noqa: F401
from .invoke_agent import (
invoke_agent_span,
update_invoke_agent_span,
end_invoke_agent_span,
) # noqa: F401
invoke_agent_span, # noqa: F401
update_invoke_agent_span, # noqa: F401
end_invoke_agent_span, # noqa: F401
)
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/pydantic_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


try:
import pydantic_ai # type: ignore
import pydantic_ai # type: ignore # noqa: F401
except ImportError:
raise DidNotEnable("pydantic-ai not installed")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from contextlib import asynccontextmanager
from functools import wraps

import sentry_sdk
from sentry_sdk.integrations import DidNotEnable

from ..spans import (
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/integrations/pydantic_ai/spans/ai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

if TYPE_CHECKING:
from typing import Any, List, Dict
from pydantic_ai.usage import RequestUsage # type: ignore
from pydantic_ai.messages import ModelMessage, SystemPromptPart # type: ignore
from sentry_sdk._types import TextPart as SentryTextPart

Expand Down
2 changes: 0 additions & 2 deletions sentry_sdk/integrations/strawberry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
capture_internal_exceptions,
ensure_integration_enabled,
event_from_exception,
logger,
package_version,
_get_installed_modules,
)

try:
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from typing import Any, TYPE_CHECKING

import sentry_sdk
from sentry_sdk.utils import format_attribute, safe_repr, capture_internal_exceptions
from sentry_sdk.utils import format_attribute, capture_internal_exceptions

if TYPE_CHECKING:
from sentry_sdk._types import Attributes, Log
from sentry_sdk._types import Attributes


OTEL_RANGES = [
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/metrics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import time
from typing import Any, Optional, TYPE_CHECKING, Union
from typing import Any, Optional, TYPE_CHECKING

import sentry_sdk
from sentry_sdk.utils import format_attribute, safe_repr
from sentry_sdk.utils import format_attribute

if TYPE_CHECKING:
from sentry_sdk._types import Attributes, Metric, MetricType
Expand Down
2 changes: 0 additions & 2 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
has_span_streaming_enabled,
is_ignored_span,
_make_sampling_decision,
normalize_incoming_data,
PropagationContext,
)
from sentry_sdk.traces import _DEFAULT_PARENT_SPAN, StreamedSpan, NoOpStreamedSpan
Expand All @@ -57,7 +56,6 @@
has_metrics_enabled,
)

import typing
from typing import TYPE_CHECKING, cast

if TYPE_CHECKING:
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
List,
Optional,
ParamSpec,
Set,
Tuple,
TypeVar,
Union,
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
Dict,
Iterator,
List,
Literal,
NoReturn,
Optional,
ParamSpec,
Expand Down
1 change: 0 additions & 1 deletion tests/integrations/django/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

import sentry_sdk
from sentry_sdk import start_span
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.consts import OP

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pytest
import re
import responses
import httpx

from huggingface_hub import InferenceClient

Expand Down
1 change: 0 additions & 1 deletion tests/integrations/litellm/test_litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ async def __call__(self, *args, **kwargs):
except ImportError:
pytest.skip("litellm not installed", allow_module_level=True)

import sentry_sdk
from sentry_sdk import start_transaction
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk._types import BLOB_DATA_SUBSTITUTE
Expand Down
2 changes: 0 additions & 2 deletions tests/integrations/openai/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
OpenAIIntegration,
_calculate_token_usage,
)
from sentry_sdk._types import AnnotatedValue
from sentry_sdk.serializer import serialize
from sentry_sdk.utils import safe_serialize

from unittest import mock # python 3.3 and above
Expand Down
5 changes: 0 additions & 5 deletions tests/integrations/openai_agents/test_openai_agents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import re
import pytest
from unittest.mock import MagicMock, patch
import os
Expand All @@ -19,7 +18,6 @@
from agents.models.openai_responses import OpenAIResponsesModel

from unittest import mock
from unittest.mock import AsyncMock

import agents
from agents import (
Expand All @@ -46,15 +44,12 @@
ResponseCompletedEvent,
Response,
ResponseUsage,
ResponseStreamEvent,
)
from openai.types.responses.response_usage import (
InputTokensDetails,
OutputTokensDetails,
)

from openai._response import AsyncAPIResponse
from openai._models import FinalRequestOptions

test_run_config = agents.RunConfig(tracing_disabled=True)

Expand Down
Loading
Loading