Skip to content

Commit 984f623

Browse files
committed
Merge branch 'master' into ivana/populate-tox-2
2 parents 2fb3dc5 + be53273 commit 984f623

File tree

7 files changed

+41
-24
lines changed

7 files changed

+41
-24
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pytest -rs tests/integrations/flask/ # Replace "flask" with the specific integr
126126

127127
## Releasing a New Version
128128

129-
_(only relevant for Sentry employees)_
129+
_(only relevant for Python SDK core team)_
130130

131131
### Prerequisites
132132

sentry_sdk/integrations/__init__.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,36 @@ def iter_default_integrations(with_auto_enabling_integrations):
119119
del _generate_default_integrations_iterator
120120

121121
_MIN_VERSIONS = {
122-
'aiohttp': (3, 4),
123-
'anthropic': (0, 16),
124-
'ariadne': (0, 20),
125-
'arq': (0, 23),
126-
'asyncpg': (0, 23),
127-
'boto3': (1, 12), # this is actually the botocore version
122+
"aiohttp": (3, 4),
123+
"anthropic": (0, 16),
124+
"ariadne": (0, 20),
125+
"arq": (0, 23),
126+
"asyncpg": (0, 23),
127+
"boto3": (1, 12), # this is actually the botocore version
128+
"bottle": (0, 12),
129+
"celery": (4, 4, 7),
130+
"clickhouse_driver": (0, 2, 0),
131+
"django": (1, 8),
132+
"falcon": (1, 4),
133+
"flask": (0, 10),
134+
"gql": (3, 4, 1),
135+
"graphene": (3, 3),
136+
"ray": (2, 7, 0),
137+
"rq": (0, 6),
138+
"sanic": (0, 8),
139+
"sqlalchemy": (1, 2),
140+
"strawberry": (0, 209, 5),
141+
"tornado": (6, 0),
142+
}
143+
144+
145+
_MIN_VERSIONS = {
146+
"aiohttp": (3, 4),
147+
"anthropic": (0, 16),
148+
"ariadne": (0, 20),
149+
"arq": (0, 23),
150+
"asyncpg": (0, 23),
151+
"boto3": (1, 12), # this is actually the botocore version
128152
"bottle": (0, 12),
129153
"celery": (4, 4, 7),
130154
"clickhouse_driver": (0, 2, 0),
@@ -218,18 +242,20 @@ def setup_integrations(
218242

219243

220244
def _check_minimum_version(integration, version, package=None):
221-
# type: (Integration, Optional[tuple[int]], Optional[str]) -> None
245+
# type: (type[Integration], Optional[tuple[int, ...]], Optional[str]) -> None
222246
package = package or integration.identifier
223247

224248
if version is None:
225-
raise DidNotEnable(f"Unparsable {package} version: {version}")
249+
raise DidNotEnable(f"Unparsable {package} version.")
226250

227251
min_version = _MIN_VERSIONS.get(integration.identifier)
228252
if min_version is None:
229253
return
230254

231255
if version < min_version:
232-
raise DidNotEnable(f"Integration only supports {package} {'.'.join(map(str, min_version))} or newer.")
256+
raise DidNotEnable(
257+
f"Integration only supports {package} {'.'.join(map(str, min_version))} or newer."
258+
)
233259

234260

235261
class DidNotEnable(Exception): # noqa: N818

sentry_sdk/integrations/anthropic.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sentry_sdk
55
from sentry_sdk.ai.monitoring import record_token_usage
66
from sentry_sdk.consts import OP, SPANDATA
7-
from sentry_sdk.integrations import _MIN_VERSIONS, DidNotEnable, Integration
7+
from sentry_sdk.integrations import _check_minimum_version, DidNotEnable, Integration
88
from sentry_sdk.scope import should_send_default_pii
99
from sentry_sdk.utils import (
1010
capture_internal_exceptions,
@@ -37,13 +37,7 @@ def __init__(self, include_prompts=True):
3737
def setup_once():
3838
# type: () -> None
3939
version = package_version("anthropic")
40-
41-
if version is None:
42-
raise DidNotEnable("Unparsable anthropic version.")
43-
44-
min_version = _MIN_VERSIONS[AnthropicIntegration.identifier]
45-
if version < min_version:
46-
raise DidNotEnable(f"anthropic {'.'.join(map(str, min_version))} or newer required.")
40+
_check_minimum_version(AnthropicIntegration, version)
4741

4842
Messages.create = _wrap_message_create(Messages.create)
4943
AsyncMessages.create = _wrap_message_create_async(AsyncMessages.create)

sentry_sdk/integrations/asyncpg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def __init__(self, *, record_params: bool = False):
3333
def setup_once() -> None:
3434
# asyncpg.__version__ is a string containing the semantic version in the form of "<major>.<minor>.<patch>"
3535
asyncpg_version = parse_version(asyncpg.__version__)
36-
3736
_check_minimum_version(AsyncPGIntegration, asyncpg_version)
3837

3938
asyncpg.Connection.execute = _wrap_execute(

sentry_sdk/integrations/boto3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Boto3Integration(Integration):
3636
def setup_once():
3737
# type: () -> None
3838
version = parse_version(BOTOCORE_VERSION)
39-
_check_minimum_version(Boto3Integration, version, 'botocore')
39+
_check_minimum_version(Boto3Integration, version, "botocore")
4040

4141
orig_init = BaseClient.__init__
4242

sentry_sdk/integrations/clickhouse_driver.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def __getitem__(self, _):
3535
raise DidNotEnable("clickhouse-driver not installed.")
3636

3737

38-
3938
class ClickhouseDriverIntegration(Integration):
4039
identifier = "clickhouse_driver"
4140
origin = f"auto.db.{identifier}"

sentry_sdk/integrations/sanic.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ def __init__(self, unsampled_statuses=frozenset({404})):
7373
@staticmethod
7474
def setup_once():
7575
# type: () -> None
76-
7776
SanicIntegration.version = parse_version(SANIC_VERSION)
78-
_check_minimum_version(SanicIntegration.identifier, SanicIntegration.version)
77+
_check_minimum_version(SanicIntegration, SanicIntegration.version)
7978

8079
if not HAS_REAL_CONTEXTVARS:
8180
# We better have contextvars or we're going to leak state between
@@ -97,7 +96,7 @@ def setup_once():
9796
# https://github.com/huge-success/sanic/issues/1332
9897
ignore_logger("root")
9998

100-
if SanicIntegration.version < (21, 9):
99+
if SanicIntegration.version is not None and SanicIntegration.version < (21, 9):
101100
_setup_legacy_sanic()
102101
return
103102

0 commit comments

Comments
 (0)