Skip to content

Commit d711353

Browse files
committed
ref: stop including line number ranges in sentrydata - reduces noise
1 parent 8cbcdf5 commit d711353

File tree

2 files changed

+32
-43
lines changed

2 files changed

+32
-43
lines changed

internal/sentrydata/generate.py

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import httpx
99
import jinja2
1010

11+
REPO = "getsentry/sentry"
12+
BRANCH = "master"
1113
TEMPLATE = """package sentrydata
1214
1315
{% for key, value in result.items() %}
@@ -46,33 +48,20 @@ def is_list(value: Any) -> TypeGuard[list[Any]]:
4648

4749
def get_text(path: str) -> str:
4850
r = httpx.get(
49-
f"https://raw.githubusercontent.com/getsentry/sentry/refs/heads/master/{path}"
51+
f"https://raw.githubusercontent.com/{REPO}/refs/heads/{BRANCH}/{path}"
5052
)
5153
r.raise_for_status()
5254
return r.text
5355

5456

55-
class GitHubUrl(str):
56-
def for_stmt(self, stmt: ast.stmt) -> GitHubUrl:
57-
return self.lineno(stmt.lineno).end_lineno(stmt.end_lineno)
58-
59-
def lineno(self, lineno: int) -> GitHubUrl:
60-
return GitHubUrl(f"{self}#L{lineno}")
61-
62-
def end_lineno(self, lineno: int | None) -> GitHubUrl:
63-
if lineno is None:
64-
return self
65-
return GitHubUrl(f"{self}-L{lineno}")
66-
67-
6857
class FileData(NamedTuple):
69-
github_url: GitHubUrl
58+
github_url: str
7059
tree: ast.Module
7160

7261

7362
def get_file_data(path: str) -> FileData:
7463
return FileData(
75-
github_url=GitHubUrl(f"https://github.com/getsentry/sentry/blob/master/{path}"),
64+
github_url=f"https://github.com/{REPO}/blob/{BRANCH}/{path}",
7665
tree=ast.parse(get_text(path)),
7766
)
7867

@@ -97,15 +86,15 @@ def parse_constants() -> dict[str, ResultData[Any]]:
9786
value=ast.Dict(keys=keys, values=values),
9887
):
9988
out["LogLevels"] = ResultData(
100-
github_url=data.github_url.for_stmt(node),
89+
github_url=data.github_url,
10190
result=[],
10291
)
10392
out["LogLevelNameToId"] = ResultData(
104-
github_url=data.github_url.for_stmt(node),
93+
github_url=data.github_url,
10594
result=OrderedDict(),
10695
)
10796
out["LogLevelIdToName"] = ResultData(
108-
github_url=data.github_url.for_stmt(node),
97+
github_url=data.github_url,
10998
result=OrderedDict(),
11099
)
111100
for key, value in zip(keys, values):
@@ -127,15 +116,15 @@ def parse_issues_grouptype() -> dict[str, ResultData[Any]]:
127116
match node:
128117
case ast.ClassDef(name="GroupCategory", body=body):
129118
out["IssueGroupCategories"] = ResultData(
130-
github_url=data.github_url.for_stmt(node),
119+
github_url=data.github_url,
131120
result=[],
132121
)
133122
out["IssueGroupCategoryNameToId"] = ResultData(
134-
github_url=data.github_url.for_stmt(node),
123+
github_url=data.github_url,
135124
result=OrderedDict(),
136125
)
137126
out["IssueGroupCategoryIdToName"] = ResultData(
138-
github_url=data.github_url.for_stmt(node),
127+
github_url=data.github_url,
139128
result=OrderedDict(),
140129
)
141130
for node in body:
@@ -167,7 +156,7 @@ def parse_rules_conditions_event_attribute() -> dict[str, ResultData[Any]]:
167156
value=ast.Dict(keys=keys),
168157
):
169158
out["EventAttributes"] = ResultData(
170-
github_url=data.github_url.for_stmt(node),
159+
github_url=data.github_url,
171160
result=[],
172161
)
173162
for key in keys:
@@ -185,15 +174,15 @@ def parse_rules_match() -> dict[str, ResultData[Any]]:
185174
match node:
186175
case ast.ClassDef(name="MatchType", body=body):
187176
out["MatchTypes"] = ResultData(
188-
github_url=data.github_url.for_stmt(node),
177+
github_url=data.github_url,
189178
result=[],
190179
)
191180
out["MatchTypeNameToId"] = ResultData(
192-
github_url=data.github_url.for_stmt(node),
181+
github_url=data.github_url,
193182
result=OrderedDict(),
194183
)
195184
out["MatchTypeIdToName"] = ResultData(
196-
github_url=data.github_url.for_stmt(node),
185+
github_url=data.github_url,
197186
result=OrderedDict(),
198187
)
199188
for node in body:
@@ -214,7 +203,7 @@ def parse_rules_match() -> dict[str, ResultData[Any]]:
214203
value=ast.Dict(keys=keys),
215204
):
216205
out["LevelMatchTypes"] = ResultData(
217-
github_url=data.github_url.for_stmt(node),
206+
github_url=data.github_url,
218207
result=[],
219208
)
220209
for key in keys:
@@ -254,7 +243,7 @@ def extract_types(classdef: ast.ClassDef) -> list[str]:
254243
types = extract_types(node)
255244
if types:
256245
out[name] = ResultData(
257-
github_url=data.github_url.for_stmt(node),
246+
github_url=data.github_url,
258247
result=types,
259248
)
260249
case _:
@@ -272,7 +261,7 @@ def parse_models_project() -> dict[str, ResultData[Any]]:
272261
value=ast.List(elts=elts),
273262
):
274263
out["Platforms"] = ResultData(
275-
github_url=data.github_url.for_stmt(node),
264+
github_url=data.github_url,
276265
result=["other"],
277266
)
278267
for elt in elts:

internal/sentrydata/sentrydata.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package sentrydata
22

3-
// https://github.com/getsentry/sentry/blob/master/src/sentry/constants.py#L246-L253
3+
// https://github.com/getsentry/sentry/blob/master/src/sentry/constants.py
44
var LogLevels = []string{
55
"sample",
66
"debug",
@@ -10,7 +10,7 @@ var LogLevels = []string{
1010
"fatal",
1111
}
1212

13-
// https://github.com/getsentry/sentry/blob/master/src/sentry/constants.py#L246-L253
13+
// https://github.com/getsentry/sentry/blob/master/src/sentry/constants.py
1414
var LogLevelNameToId = map[string]string{
1515
"sample": "0",
1616
"debug": "10",
@@ -20,7 +20,7 @@ var LogLevelNameToId = map[string]string{
2020
"fatal": "50",
2121
}
2222

23-
// https://github.com/getsentry/sentry/blob/master/src/sentry/constants.py#L246-L253
23+
// https://github.com/getsentry/sentry/blob/master/src/sentry/constants.py
2424
var LogLevelIdToName = map[string]string{
2525
"0": "sample",
2626
"10": "debug",
@@ -30,7 +30,7 @@ var LogLevelIdToName = map[string]string{
3030
"50": "fatal",
3131
}
3232

33-
// https://github.com/getsentry/sentry/blob/master/src/sentry/issues/grouptype.py#L30-L67
33+
// https://github.com/getsentry/sentry/blob/master/src/sentry/issues/grouptype.py
3434
var IssueGroupCategories = []string{
3535
"Error",
3636
"Performance",
@@ -49,7 +49,7 @@ var IssueGroupCategories = []string{
4949
"Mobile",
5050
}
5151

52-
// https://github.com/getsentry/sentry/blob/master/src/sentry/issues/grouptype.py#L30-L67
52+
// https://github.com/getsentry/sentry/blob/master/src/sentry/issues/grouptype.py
5353
var IssueGroupCategoryNameToId = map[string]string{
5454
"Error": "1",
5555
"Performance": "2",
@@ -68,7 +68,7 @@ var IssueGroupCategoryNameToId = map[string]string{
6868
"Mobile": "15",
6969
}
7070

71-
// https://github.com/getsentry/sentry/blob/master/src/sentry/issues/grouptype.py#L30-L67
71+
// https://github.com/getsentry/sentry/blob/master/src/sentry/issues/grouptype.py
7272
var IssueGroupCategoryIdToName = map[string]string{
7373
"1": "Error",
7474
"2": "Performance",
@@ -87,7 +87,7 @@ var IssueGroupCategoryIdToName = map[string]string{
8787
"15": "Mobile",
8888
}
8989

90-
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/conditions/event_attribute.py#L41-L72
90+
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/conditions/event_attribute.py
9191
var EventAttributes = []string{
9292
"message",
9393
"platform",
@@ -121,7 +121,7 @@ var EventAttributes = []string{
121121
"ota_updates.update_id",
122122
}
123123

124-
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py#L6-L22
124+
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py
125125
var MatchTypes = []string{
126126
"CONTAINS",
127127
"ENDS_WITH",
@@ -141,7 +141,7 @@ var MatchTypes = []string{
141141
"STARTS_WITH",
142142
}
143143

144-
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py#L6-L22
144+
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py
145145
var MatchTypeNameToId = map[string]string{
146146
"CONTAINS": "co",
147147
"ENDS_WITH": "ew",
@@ -161,7 +161,7 @@ var MatchTypeNameToId = map[string]string{
161161
"STARTS_WITH": "sw",
162162
}
163163

164-
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py#L6-L22
164+
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py
165165
var MatchTypeIdToName = map[string]string{
166166
"co": "CONTAINS",
167167
"ew": "ENDS_WITH",
@@ -181,14 +181,14 @@ var MatchTypeIdToName = map[string]string{
181181
"sw": "STARTS_WITH",
182182
}
183183

184-
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py#L25-L29
184+
// https://github.com/getsentry/sentry/blob/master/src/sentry/rules/match.py
185185
var LevelMatchTypes = []string{
186186
"EQUAL",
187187
"GREATER_OR_EQUAL",
188188
"LESS_OR_EQUAL",
189189
}
190190

191-
// https://github.com/getsentry/sentry/blob/master/src/sentry/models/dashboard_widget.py#L49-L83
191+
// https://github.com/getsentry/sentry/blob/master/src/sentry/models/dashboard_widget.py
192192
var DashboardWidgetTypes = []string{
193193
"discover",
194194
"issue",
@@ -199,7 +199,7 @@ var DashboardWidgetTypes = []string{
199199
"logs",
200200
}
201201

202-
// https://github.com/getsentry/sentry/blob/master/src/sentry/models/dashboard_widget.py#L133-L150
202+
// https://github.com/getsentry/sentry/blob/master/src/sentry/models/dashboard_widget.py
203203
var DashboardWidgetDisplayTypes = []string{
204204
"line",
205205
"area",
@@ -210,7 +210,7 @@ var DashboardWidgetDisplayTypes = []string{
210210
"top_n",
211211
}
212212

213-
// https://github.com/getsentry/sentry/blob/master/src/sentry/models/project.py#L61-L170
213+
// https://github.com/getsentry/sentry/blob/master/src/sentry/models/project.py
214214
var Platforms = []string{
215215
"other",
216216
"android",

0 commit comments

Comments
 (0)