File tree Expand file tree Collapse file tree 5 files changed +28
-11
lines changed Expand file tree Collapse file tree 5 files changed +28
-11
lines changed Original file line number Diff line number Diff line change 1
- from .array import * # NOQA
2
1
from .bounded import * # NOQA
3
2
from .citext import * # NOQA
4
3
from .foreignkey import * # NOQA
Original file line number Diff line number Diff line change
1
+ """DO NOT USE ME. USE django.contrib.postgres.fields.array.ArrayField
2
+
3
+ I am only here for migration compatibility
4
+ """
5
+
1
6
from __future__ import annotations
2
7
3
8
import ast
Original file line number Diff line number Diff line change 12
12
from sentry_relay .exceptions import RelayError
13
13
from sentry_relay .processing import parse_release
14
14
15
- from sentry .db .models import ArrayField
16
15
from sentry .db .models .manager .base_query_set import BaseQuerySet
17
16
from sentry .exceptions import InvalidSearchQuery
18
17
from sentry .models .releases .release_project import ReleaseProject
@@ -133,7 +132,9 @@ def filter_by_semver(
133
132
)
134
133
cols = self .model .SEMVER_COLS [: len (semver_filter .version_parts )]
135
134
qs = qs .annotate (
136
- semver = Func (* (F (col ) for col in cols ), function = "ROW" , output_field = ArrayField ())
135
+ semver = Func (
136
+ * (F (col ) for col in cols ), function = "ROW" , output_field = models .JSONField ()
137
+ )
137
138
)
138
139
qs = getattr (qs , query_func )(** {f"semver__{ semver_filter .operator } " : filter_func })
139
140
return qs
Original file line number Diff line number Diff line change @@ -57,10 +57,10 @@ def bad_code():
57
57
58
58
errors = _run (S003_py )
59
59
assert errors == [
60
- "t.py:1:0: S003 Use `` from sentry.utils import json` ` instead." ,
61
- "t.py:2:0: S003 Use `` from sentry.utils import json` ` instead." ,
62
- "t.py:3:0: S003 Use `` from sentry.utils import json` ` instead." ,
63
- "t.py:4:0: S003 Use `` from sentry.utils import json` ` instead." ,
60
+ "t.py:1:0: S003 Use `from sentry.utils import json` instead." ,
61
+ "t.py:2:0: S003 Use `from sentry.utils import json` instead." ,
62
+ "t.py:3:0: S003 Use `from sentry.utils import json` instead." ,
63
+ "t.py:4:0: S003 Use `from sentry.utils import json` instead." ,
64
64
]
65
65
66
66
@@ -221,6 +221,14 @@ def test_S012():
221
221
"""
222
222
223
223
expected = [
224
- "t.py:1:0: S012 Use `` from sentry.api.permissions import SentryIsAuthenticated` ` instead"
224
+ "t.py:1:0: S012 Use `from sentry.api.permissions import SentryIsAuthenticated` instead"
225
225
]
226
- assert _run (src , filename = "tests/test_example.py" ) == expected
226
+ assert _run (src ) == expected
227
+
228
+
229
+ def test_S013 ():
230
+ src = """\
231
+ from sentry.db.models.fields.array import ArrayField
232
+ """
233
+ expected = ["t.py:1:0: S013 Use `django.contrib.postgres.fields.array.ArrayField` instead" ]
234
+ assert _run (src ) == expected
Original file line number Diff line number Diff line change 13
13
14
14
S002_msg = "S002 print functions or statements are not allowed."
15
15
16
- S003_msg = "S003 Use `` from sentry.utils import json` ` instead."
16
+ S003_msg = "S003 Use `from sentry.utils import json` instead."
17
17
S003_modules = frozenset (("json" , "simplejson" ))
18
18
19
19
S004_msg = "S004 Use `pytest.raises` instead for better debuggability."
34
34
S011_msg = "S011 Use override_options(...) instead to ensure proper cleanup"
35
35
36
36
# SentryIsAuthenticated extends from IsAuthenticated and provides additional checks for demo users
37
- S012_msg = "S012 Use ``from sentry.api.permissions import SentryIsAuthenticated`` instead"
37
+ S012_msg = "S012 Use `from sentry.api.permissions import SentryIsAuthenticated` instead"
38
+
39
+ S013_msg = "S013 Use `django.contrib.postgres.fields.array.ArrayField` instead"
38
40
39
41
40
42
class SentryVisitor (ast .NodeVisitor ):
@@ -71,6 +73,8 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
71
73
x .name == "IsAuthenticated" for x in node .names
72
74
):
73
75
self .errors .append ((node .lineno , node .col_offset , S012_msg ))
76
+ elif node .module == "sentry.db.models.fields.array" :
77
+ self .errors .append ((node .lineno , node .col_offset , S013_msg ))
74
78
75
79
self .generic_visit (node )
76
80
You can’t perform that action at this time.
0 commit comments