Skip to content

Commit 0c44202

Browse files
committed
move min versions to central place
1 parent 1c5300a commit 0c44202

File tree

22 files changed

+110
-68
lines changed

22 files changed

+110
-68
lines changed

sentry_sdk/integrations/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,29 @@ def iter_default_integrations(with_auto_enabling_integrations):
119119

120120
del _generate_default_integrations_iterator
121121

122+
_MIN_VERSIONS = {
123+
'aiohttp': (3, 4),
124+
'anthropic': (0, 16),
125+
'ariadne': (0, 20),
126+
'arq': (0, 23),
127+
'asyncpg': (0, 23),
128+
'boto3': (1, 12), # this is actually the botocore version
129+
"bottle": (0, 12),
130+
"celery": (4, 4, 7),
131+
"clickhouse_driver": (0, 2, 0),
132+
"django": (1, 8),
133+
"falcon": (1, 4),
134+
"flask": (0, 10),
135+
"gql": (3, 4, 1),
136+
"graphene": (3, 3),
137+
"ray": (2, 7, 0),
138+
"rq": (0, 6),
139+
"sanic": (0, 8),
140+
"sqlalchemy": (1, 2),
141+
"strawberry": (0, 209, 5),
142+
"tornado": (6, 0),
143+
}
144+
122145

123146
def setup_integrations(
124147
integrations,

sentry_sdk/integrations/aiohttp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from sentry_sdk.consts import OP, SPANSTATUS, SPANDATA
88
from sentry_sdk.integrations import (
99
_DEFAULT_FAILED_REQUEST_STATUS_CODES,
10+
_MIN_VERSIONS,
1011
Integration,
1112
DidNotEnable,
1213
)
@@ -95,8 +96,9 @@ def setup_once():
9596
if version is None:
9697
raise DidNotEnable("Unparsable AIOHTTP version: {}".format(AIOHTTP_VERSION))
9798

98-
if version < (3, 4):
99-
raise DidNotEnable("AIOHTTP 3.4 or newer required.")
99+
min_version = _MIN_VERSIONS[AioHttpIntegration.identifier]
100+
if version < min_version:
101+
raise DidNotEnable(f"AIOHTTP {'.'.join(map(str, min_version))} or newer required.")
100102

101103
if not HAS_REAL_CONTEXTVARS:
102104
# We better have contextvars or we're going to leak state between

sentry_sdk/integrations/anthropic.py

Lines changed: 4 additions & 3 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 DidNotEnable, Integration
7+
from sentry_sdk.integrations import _MIN_VERSIONS, DidNotEnable, Integration
88
from sentry_sdk.scope import should_send_default_pii
99
from sentry_sdk.utils import (
1010
capture_internal_exceptions,
@@ -41,8 +41,9 @@ def setup_once():
4141
if version is None:
4242
raise DidNotEnable("Unparsable anthropic version.")
4343

44-
if version < (0, 16):
45-
raise DidNotEnable("anthropic 0.16 or newer required.")
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.")
4647

4748
Messages.create = _wrap_message_create(Messages.create)
4849
AsyncMessages.create = _wrap_message_create_async(AsyncMessages.create)

sentry_sdk/integrations/ariadne.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sentry_sdk
44
from sentry_sdk import get_client, capture_event
5-
from sentry_sdk.integrations import DidNotEnable, Integration
5+
from sentry_sdk.integrations import _MIN_VERSIONS, DidNotEnable, Integration
66
from sentry_sdk.integrations.logging import ignore_logger
77
from sentry_sdk.integrations._wsgi_common import request_body_within_bounds
88
from sentry_sdk.scope import should_send_default_pii
@@ -40,8 +40,9 @@ def setup_once():
4040
if version is None:
4141
raise DidNotEnable("Unparsable ariadne version.")
4242

43-
if version < (0, 20):
44-
raise DidNotEnable("ariadne 0.20 or newer required.")
43+
min_version = _MIN_VERSIONS[AriadneIntegration.identifier]
44+
if version < min_version:
45+
raise DidNotEnable(f"ariadne {'.'.join(map(str, min_version))} or newer required.")
4546

4647
ignore_logger("ariadne")
4748

sentry_sdk/integrations/arq.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sentry_sdk
44
from sentry_sdk.consts import OP, SPANSTATUS
5-
from sentry_sdk.integrations import DidNotEnable, Integration
5+
from sentry_sdk.integrations import _MIN_VERSIONS, DidNotEnable, Integration
66
from sentry_sdk.integrations.logging import ignore_logger
77
from sentry_sdk.scope import should_send_default_pii
88
from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_TASK
@@ -58,8 +58,9 @@ def setup_once():
5858
if version is None:
5959
raise DidNotEnable("Unparsable arq version: {}".format(ARQ_VERSION))
6060

61-
if version < (0, 23):
62-
raise DidNotEnable("arq 0.23 or newer required.")
61+
min_version = _MIN_VERSIONS[ArqIntegration.identifier]
62+
if version < min_version:
63+
raise DidNotEnable(f"arq {'.'.join(map(str, min_version))} or newer required.")
6364

6465
patch_enqueue_job()
6566
patch_run_job()

sentry_sdk/integrations/asyncpg.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import sentry_sdk
66
from sentry_sdk.consts import OP, SPANDATA
7-
from sentry_sdk.integrations import Integration, DidNotEnable
7+
from sentry_sdk.integrations import _MIN_VERSIONS, Integration, DidNotEnable
88
from sentry_sdk.tracing import Span
99
from sentry_sdk.tracing_utils import add_query_source, record_sql_queries
1010
from sentry_sdk.utils import (
@@ -20,12 +20,6 @@
2020
except ImportError:
2121
raise DidNotEnable("asyncpg not installed.")
2222

23-
# asyncpg.__version__ is a string containing the semantic version in the form of "<major>.<minor>.<patch>"
24-
asyncpg_version = parse_version(asyncpg.__version__)
25-
26-
if asyncpg_version is not None and asyncpg_version < (0, 23, 0):
27-
raise DidNotEnable("asyncpg >= 0.23.0 required")
28-
2923

3024
class AsyncPGIntegration(Integration):
3125
identifier = "asyncpg"
@@ -37,6 +31,13 @@ def __init__(self, *, record_params: bool = False):
3731

3832
@staticmethod
3933
def setup_once() -> None:
34+
# asyncpg.__version__ is a string containing the semantic version in the form of "<major>.<minor>.<patch>"
35+
asyncpg_version = parse_version(asyncpg.__version__)
36+
37+
min_version = _MIN_VERSIONS[AsyncPGIntegration.identifier]
38+
if asyncpg_version is not None and asyncpg_version < min_version:
39+
raise DidNotEnable(f"asyncpg >= {'.'.join(map(str, min_version))} required")
40+
4041
asyncpg.Connection.execute = _wrap_execute(
4142
asyncpg.Connection.execute,
4243
)

sentry_sdk/integrations/boto3.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sentry_sdk
44
from sentry_sdk.consts import OP, SPANDATA
5-
from sentry_sdk.integrations import Integration, DidNotEnable
5+
from sentry_sdk.integrations import _MIN_VERSIONS, Integration, DidNotEnable
66
from sentry_sdk.tracing import Span
77
from sentry_sdk.utils import (
88
capture_internal_exceptions,
@@ -43,8 +43,9 @@ def setup_once():
4343
"Unparsable botocore version: {}".format(BOTOCORE_VERSION)
4444
)
4545

46-
if version < (1, 12):
47-
raise DidNotEnable("Botocore 1.12 or newer is required.")
46+
min_version = _MIN_VERSIONS[Boto3Integration.identifier]
47+
if version < min_version:
48+
raise DidNotEnable(f"Botocore {'.'.join(map(str, min_version))} or newer is required.")
4849

4950
orig_init = BaseClient.__init__
5051

sentry_sdk/integrations/bottle.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Integration,
1414
DidNotEnable,
1515
_DEFAULT_FAILED_REQUEST_STATUS_CODES,
16+
_MIN_VERSIONS,
1617
)
1718
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
1819
from sentry_sdk.integrations._wsgi_common import RequestExtractor
@@ -76,8 +77,9 @@ def setup_once():
7677
if version is None:
7778
raise DidNotEnable("Unparsable Bottle version: {}".format(BOTTLE_VERSION))
7879

79-
if version < (0, 12):
80-
raise DidNotEnable("Bottle 0.12 or newer required.")
80+
min_version = _MIN_VERSIONS[BottleIntegration.identifier]
81+
if version < min_version:
82+
raise DidNotEnable(f"Bottle {'.'.join(map(str, min_version))} or newer required.")
8183

8284
old_app = Bottle.__call__
8385

sentry_sdk/integrations/celery/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from sentry_sdk import isolation_scope
77
from sentry_sdk.api import continue_trace
88
from sentry_sdk.consts import OP, SPANSTATUS, SPANDATA
9-
from sentry_sdk.integrations import Integration, DidNotEnable
9+
from sentry_sdk.integrations import _MIN_VERSIONS, Integration, DidNotEnable
1010
from sentry_sdk.integrations.celery.beat import (
1111
_patch_beat_apply_entry,
1212
_patch_redbeat_maybe_due,
@@ -79,8 +79,9 @@ def __init__(
7979
@staticmethod
8080
def setup_once():
8181
# type: () -> None
82-
if CELERY_VERSION < (4, 4, 7):
83-
raise DidNotEnable("Celery 4.4.7 or newer required.")
82+
min_version = _MIN_VERSIONS[CeleryIntegration.identifier]
83+
if CELERY_VERSION < min_version:
84+
raise DidNotEnable(f"Celery {'.'.join(map(str, min_version))} or newer required.")
8485

8586
_patch_build_tracer()
8687
_patch_task_apply_async()

sentry_sdk/integrations/chalice.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ class ChaliceIntegration(Integration):
101101
@staticmethod
102102
def setup_once():
103103
# type: () -> None
104-
105104
version = parse_version(CHALICE_VERSION)
106105

107106
if version is None:

0 commit comments

Comments
 (0)