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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ select = [
"E", # pycodestyle errors (same as flake8 default)
"W", # pycodestyle warnings (same as flake8 default)
"F", # Pyflakes (same as flake8 default)
"I",
# Note: B and N rules are NOT enabled by default in flake8
# They were only active through the plugins, which may not have been fully enabled
]
Expand Down
5 changes: 2 additions & 3 deletions scripts/init_serverless_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
"""

import os
import sys
import re
import sys
from typing import TYPE_CHECKING

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any

Expand Down
14 changes: 7 additions & 7 deletions scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
See scripts/populate_tox/README.md for more info.
"""

import re
import functools
import hashlib
import json
import os
import re
import subprocess
import sys
import time
from dataclasses import dataclass
from bisect import bisect_left
from collections import defaultdict
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone # noqa: F401
from importlib.metadata import PackageMetadata, distributions
from packaging.specifiers import SpecifierSet
from packaging.version import Version
from pathlib import Path
from typing import Optional, Union

from packaging.specifiers import SpecifierSet
from packaging.version import Version

# Adding the scripts directory to PATH. This is necessary in order to be able
# to import stuff from the split_tox_gh_actions script
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

import requests
from jinja2 import Environment, FileSystemLoader
from sentry_sdk.integrations import _MIN_VERSIONS

from config import TEST_SUITE_CONFIG
from jinja2 import Environment, FileSystemLoader
from split_tox_gh_actions.split_tox_gh_actions import GROUPS

from sentry_sdk.integrations import _MIN_VERSIONS

# Set CUTOFF this to a datetime to ignore packages older than CUTOFF
CUTOFF = None
Expand Down
9 changes: 3 additions & 6 deletions scripts/ready_yet/main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import time
import re
import sys

import requests

import time
from collections import defaultdict

from pathlib import Path

import requests
from tox.config.cli.parse import get_options
from tox.session.state import State
from tox.config.sets import CoreConfigSet
from tox.config.source.tox_ini import ToxIni
from tox.session.state import State

PYTHON_VERSION = "3.13"

Expand Down
2 changes: 1 addition & 1 deletion scripts/test-lambda-locally/lambda_function.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import sentry_sdk

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
from sentry_sdk.integrations.logging import LoggingIntegration

Expand Down
12 changes: 6 additions & 6 deletions sentry_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from sentry_sdk import profiler
from sentry_sdk import metrics
from sentry_sdk.scope import Scope
from sentry_sdk.transport import Transport, HttpTransport
from sentry_sdk.client import Client
from sentry_sdk import metrics, profiler

from sentry_sdk.api import * # noqa
from sentry_sdk.scope import Scope # isort: skip
from sentry_sdk.client import Client # isort: skip
from sentry_sdk.consts import VERSION
from sentry_sdk.transport import HttpTransport, Transport

from sentry_sdk.api import * # noqa # isort: skip

__all__ = [ # noqa
"Hub",
Expand Down
8 changes: 4 additions & 4 deletions sentry_sdk/_batcher.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
import random
import threading
from datetime import datetime, timezone
from typing import TYPE_CHECKING, TypeVar, Generic
import weakref
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Generic, TypeVar

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

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

T = TypeVar("T")

Expand Down
4 changes: 1 addition & 3 deletions sentry_sdk/_compat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import sys

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any
from typing import TypeVar
from typing import Any, TypeVar

T = TypeVar("T")

Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/_init_implementation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import warnings

from typing import TYPE_CHECKING

import sentry_sdk
Expand Down
3 changes: 2 additions & 1 deletion sentry_sdk/_log_batcher.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import TYPE_CHECKING

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

if TYPE_CHECKING:
from typing import Any

from sentry_sdk._types import Log


Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/_metrics_batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

if TYPE_CHECKING:
from typing import Any

from sentry_sdk._types import Metric


Expand Down
2 changes: 0 additions & 2 deletions sentry_sdk/_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@
"""

import threading

from collections import deque
from time import time

from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand Down
5 changes: 3 additions & 2 deletions sentry_sdk/_span_batcher.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import os
import random
import threading
import time
import weakref
from collections import defaultdict
from datetime import datetime, timezone
import os
from typing import TYPE_CHECKING
import weakref

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

if TYPE_CHECKING:
from typing import Any, Callable, Optional

from sentry_sdk.traces import StreamedSpan


Expand Down
5 changes: 1 addition & 4 deletions sentry_sdk/_werkzeug.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Dict
from typing import Iterator
from typing import Tuple
from typing import Optional
from typing import Dict, Iterator, Optional, Tuple


#
Expand Down
2 changes: 1 addition & 1 deletion 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, # 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
set_data_normalized, # noqa: F401
)
6 changes: 3 additions & 3 deletions sentry_sdk/ai/_openai_completions_api.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from collections.abc import Iterable

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from sentry_sdk._types import TextPart
from typing import Union

from openai.types.chat import (
ChatCompletionContentPartParam,
ChatCompletionMessageParam,
ChatCompletionSystemMessageParam,
ChatCompletionContentPartParam,
)

from sentry_sdk._types import TextPart


def _is_system_instruction(message: "ChatCompletionMessageParam") -> bool:
return isinstance(message, dict) and message.get("role") == "system"
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/ai/_openai_responses_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if TYPE_CHECKING:
from typing import Union

from openai.types.responses import ResponseInputParam, ResponseInputItemParam
from openai.types.responses import ResponseInputItemParam, ResponseInputParam


def _is_system_instruction(message: "ResponseInputItemParam") -> bool:
Expand Down
13 changes: 6 additions & 7 deletions sentry_sdk/ai/monitoring.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import inspect
import sys
from functools import wraps
from typing import TYPE_CHECKING

from sentry_sdk.ai.utils import _set_span_data_attribute
from sentry_sdk.consts import SPANDATA
import sentry_sdk.utils
from sentry_sdk import start_span
from sentry_sdk.tracing import Span
from sentry_sdk.ai.utils import _set_span_data_attribute
from sentry_sdk.consts import SPANDATA
from sentry_sdk.traces import StreamedSpan
from sentry_sdk.utils import ContextVar, reraise, capture_internal_exceptions

from typing import TYPE_CHECKING
from sentry_sdk.tracing import Span
from sentry_sdk.utils import ContextVar, capture_internal_exceptions, reraise

if TYPE_CHECKING:
from typing import Optional, Callable, Awaitable, Any, Union, TypeVar
from typing import Any, Awaitable, Callable, Optional, TypeVar, Union

F = TypeVar("F", bound=Union[Callable[..., Any], Callable[..., Awaitable[Any]]])

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/ai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from sentry_sdk.tracing import Span

import sentry_sdk
from sentry_sdk.utils import logger
from sentry_sdk.traces import StreamedSpan
from sentry_sdk.tracing_utils import has_span_streaming_enabled
from sentry_sdk.utils import logger

MAX_GEN_AI_MESSAGE_BYTES = 20_000 # 20KB
# Maximum characters when only a single message is left after bytes truncation
Expand Down
38 changes: 19 additions & 19 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import inspect
import warnings
from contextlib import contextmanager
from typing import TYPE_CHECKING

from sentry_sdk import tracing_utils, Client
from sentry_sdk import Client, tracing_utils
from sentry_sdk._init_implementation import init
from sentry_sdk.consts import INSTRUMENTER
from sentry_sdk.scope import Scope, _ScopeManager, new_scope, isolation_scope
from sentry_sdk.crons import monitor
from sentry_sdk.scope import Scope, _ScopeManager, isolation_scope, new_scope
from sentry_sdk.traces import StreamedSpan, _get_current_streamed_span
from sentry_sdk.tracing import NoOpSpan, Transaction, trace
from sentry_sdk.crons import monitor

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Mapping

from typing import Any
from typing import Dict
from typing import Generator
from typing import Optional
from typing import overload
from typing import Callable
from typing import TypeVar
from typing import ContextManager
from typing import Union
from typing import (
Any,
Callable,
ContextManager,
Dict,
Generator,
Optional,
TypeVar,
Union,
overload,
)

from typing_extensions import Unpack

from sentry_sdk.client import BaseClient
from sentry_sdk._types import (
Event,
Hint,
Breadcrumb,
BreadcrumbHint,
Event,
ExcInfo,
MeasurementUnit,
Hint,
LogLevelStr,
MeasurementUnit,
SamplingContext,
)
from sentry_sdk.client import BaseClient
from sentry_sdk.traces import StreamedSpan
from sentry_sdk.tracing import Span, TransactionKwargs

Expand Down
7 changes: 3 additions & 4 deletions sentry_sdk/attachments.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
import mimetypes
import os
from typing import TYPE_CHECKING

from sentry_sdk.envelope import Item, PayloadRef

from typing import TYPE_CHECKING

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


class Attachment:
Expand Down
Loading
Loading