wesleysimplicio commited on
Commit
0c7e698
·
verified ·
1 Parent(s): 708b926

docs: sync data/unseen_eval_120.json with N=120 scientific proof and market charts

Browse files
Files changed (1) hide show
  1. data/unseen_eval_120.json +1649 -0
data/unseen_eval_120.json ADDED
@@ -0,0 +1,1649 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "id": "cat1_ast_diff_01_diff_pydantic_v2_field",
4
+ "category": "1_surgical_diff_ast_precision",
5
+ "difficulty": "Easy",
6
+ "file": "user_dto.py",
7
+ "original_code": "class UserDTO(BaseModel):\n tax_id: str\n name: str\n",
8
+ "task": "Add min_length=11, max_length=14 constraints to tax_id using Field(...).",
9
+ "test_assertion": "assert 'Field(' in patched and 'min_length=11' in patched",
10
+ "forbidden_symbols": [],
11
+ "expected_symbols": [
12
+ "Field",
13
+ "min_length",
14
+ "max_length"
15
+ ]
16
+ },
17
+ {
18
+ "id": "cat1_ast_diff_02_diff_fastapi_deprecate_route",
19
+ "category": "1_surgical_diff_ast_precision",
20
+ "difficulty": "Easy",
21
+ "file": "router.py",
22
+ "original_code": "@app.get('/v1/users')\ndef list_users():\n return []\n",
23
+ "task": "Mark /v1/users as deprecated=True in route decorator.",
24
+ "test_assertion": "assert 'deprecated=True' in patched",
25
+ "forbidden_symbols": [],
26
+ "expected_symbols": [
27
+ "deprecated"
28
+ ]
29
+ },
30
+ {
31
+ "id": "cat1_ast_diff_03_diff_dataclass_frozen",
32
+ "category": "1_surgical_diff_ast_precision",
33
+ "difficulty": "Easy",
34
+ "file": "config.py",
35
+ "original_code": "@dataclass\nclass AppConfig:\n port: int = 8080\n",
36
+ "task": "Make the AppConfig dataclass frozen=True.",
37
+ "test_assertion": "assert '@dataclass(frozen=True)' in patched",
38
+ "forbidden_symbols": [],
39
+ "expected_symbols": [
40
+ "frozen=True"
41
+ ]
42
+ },
43
+ {
44
+ "id": "cat1_ast_diff_04_diff_async_def_signature",
45
+ "category": "1_surgical_diff_ast_precision",
46
+ "difficulty": "Easy",
47
+ "file": "crawler.py",
48
+ "original_code": "def fetch_page(url: str) -> str:\n return http_get(url)\n",
49
+ "task": "Convert fetch_page into an async function and await http_get(url).",
50
+ "test_assertion": "assert 'async def fetch_page' in patched and 'await http_get' in patched",
51
+ "forbidden_symbols": [],
52
+ "expected_symbols": [
53
+ "async def",
54
+ "await"
55
+ ]
56
+ },
57
+ {
58
+ "id": "cat1_ast_diff_05_diff_logger_lazy_formatting",
59
+ "category": "1_surgical_diff_ast_precision",
60
+ "difficulty": "Easy",
61
+ "file": "worker.py",
62
+ "original_code": "logger.info(f'Processing job {job_id} for user {user_id}')\n",
63
+ "task": "Replace f-string in logger call with lazy arguments logger.info('Processing job %s for user %s', job_id, user_id).",
64
+ "test_assertion": "assert 'logger.info(' in patched and '%s' in patched and not 'f\"' in patched",
65
+ "forbidden_symbols": [],
66
+ "expected_symbols": [
67
+ "%s"
68
+ ]
69
+ },
70
+ {
71
+ "id": "cat1_ast_diff_06_diff_optional_type_union",
72
+ "category": "1_surgical_diff_ast_precision",
73
+ "difficulty": "Easy",
74
+ "file": "types.py",
75
+ "original_code": "from typing import Optional\ndef find_by_id(item_id: int) -> Optional[str]:\n return None\n",
76
+ "task": "Modernize return type to Python 3.10+ union syntax str | None.",
77
+ "test_assertion": "assert '-> str | None:' in patched",
78
+ "forbidden_symbols": [],
79
+ "expected_symbols": [
80
+ "str | None"
81
+ ]
82
+ },
83
+ {
84
+ "id": "cat1_ast_diff_07_diff_try_except_clause",
85
+ "category": "1_surgical_diff_ast_precision",
86
+ "difficulty": "Easy",
87
+ "file": "storage.py",
88
+ "original_code": "def read_file(path: str) -> str:\n return open(path).read()\n",
89
+ "task": "Wrap in try/except FileNotFoundError returning empty string on failure.",
90
+ "test_assertion": "assert 'try:' in patched and 'except FileNotFoundError:' in patched",
91
+ "forbidden_symbols": [],
92
+ "expected_symbols": [
93
+ "FileNotFoundError"
94
+ ]
95
+ },
96
+ {
97
+ "id": "cat1_ast_diff_08_diff_list_comprehension_filter",
98
+ "category": "1_surgical_diff_ast_precision",
99
+ "difficulty": "Easy",
100
+ "file": "filter.py",
101
+ "original_code": "evens = []\nfor x in nums:\n if x % 2 == 0:\n evens.append(x)\n",
102
+ "task": "Refactor into a single list comprehension [x for x in nums if x % 2 == 0].",
103
+ "test_assertion": "assert 'evens = [x for x in nums if x % 2 == 0]' in patched",
104
+ "forbidden_symbols": [],
105
+ "expected_symbols": [
106
+ "evens = [x for x in nums"
107
+ ]
108
+ },
109
+ {
110
+ "id": "cat1_ast_diff_09_diff_dict_comprehension",
111
+ "category": "1_surgical_diff_ast_precision",
112
+ "difficulty": "Easy",
113
+ "file": "mapper.py",
114
+ "original_code": "lookup = {}\nfor k, v in items:\n lookup[k] = v.upper()\n",
115
+ "task": "Refactor into dict comprehension lookup = {k: v.upper() for k, v in items}.",
116
+ "test_assertion": "assert 'lookup = {k: v.upper() for k, v in items}' in patched",
117
+ "forbidden_symbols": [],
118
+ "expected_symbols": [
119
+ "lookup = {k:"
120
+ ]
121
+ },
122
+ {
123
+ "id": "cat1_ast_diff_10_diff_generator_expression",
124
+ "category": "1_surgical_diff_ast_precision",
125
+ "difficulty": "Easy",
126
+ "file": "aggregator.py",
127
+ "original_code": "total = sum([item.price for item in cart])\n",
128
+ "task": "Replace list comprehension inside sum() with generator expression (remove brackets).",
129
+ "test_assertion": "assert 'sum(item.price for item in cart)' in patched",
130
+ "forbidden_symbols": [],
131
+ "expected_symbols": [
132
+ "sum(item.price"
133
+ ]
134
+ },
135
+ {
136
+ "id": "cat1_ast_diff_11_diff_pydantic_v2_field",
137
+ "category": "1_surgical_diff_ast_precision",
138
+ "difficulty": "Medium",
139
+ "file": "user_dto.py",
140
+ "original_code": "class UserDTO(BaseModel):\n tax_id: str\n name: str\n",
141
+ "task": "Add min_length=11, max_length=14 constraints to tax_id using Field(...).",
142
+ "test_assertion": "assert 'Field(' in patched and 'min_length=11' in patched",
143
+ "forbidden_symbols": [],
144
+ "expected_symbols": [
145
+ "Field",
146
+ "min_length",
147
+ "max_length"
148
+ ]
149
+ },
150
+ {
151
+ "id": "cat1_ast_diff_12_diff_fastapi_deprecate_route",
152
+ "category": "1_surgical_diff_ast_precision",
153
+ "difficulty": "Medium",
154
+ "file": "router.py",
155
+ "original_code": "@app.get('/v1/users')\ndef list_users():\n return []\n",
156
+ "task": "Mark /v1/users as deprecated=True in route decorator.",
157
+ "test_assertion": "assert 'deprecated=True' in patched",
158
+ "forbidden_symbols": [],
159
+ "expected_symbols": [
160
+ "deprecated"
161
+ ]
162
+ },
163
+ {
164
+ "id": "cat1_ast_diff_13_diff_dataclass_frozen",
165
+ "category": "1_surgical_diff_ast_precision",
166
+ "difficulty": "Medium",
167
+ "file": "config.py",
168
+ "original_code": "@dataclass\nclass AppConfig:\n port: int = 8080\n",
169
+ "task": "Make the AppConfig dataclass frozen=True.",
170
+ "test_assertion": "assert '@dataclass(frozen=True)' in patched",
171
+ "forbidden_symbols": [],
172
+ "expected_symbols": [
173
+ "frozen=True"
174
+ ]
175
+ },
176
+ {
177
+ "id": "cat1_ast_diff_14_diff_async_def_signature",
178
+ "category": "1_surgical_diff_ast_precision",
179
+ "difficulty": "Medium",
180
+ "file": "crawler.py",
181
+ "original_code": "def fetch_page(url: str) -> str:\n return http_get(url)\n",
182
+ "task": "Convert fetch_page into an async function and await http_get(url).",
183
+ "test_assertion": "assert 'async def fetch_page' in patched and 'await http_get' in patched",
184
+ "forbidden_symbols": [],
185
+ "expected_symbols": [
186
+ "async def",
187
+ "await"
188
+ ]
189
+ },
190
+ {
191
+ "id": "cat1_ast_diff_15_diff_logger_lazy_formatting",
192
+ "category": "1_surgical_diff_ast_precision",
193
+ "difficulty": "Medium",
194
+ "file": "worker.py",
195
+ "original_code": "logger.info(f'Processing job {job_id} for user {user_id}')\n",
196
+ "task": "Replace f-string in logger call with lazy arguments logger.info('Processing job %s for user %s', job_id, user_id).",
197
+ "test_assertion": "assert 'logger.info(' in patched and '%s' in patched and not 'f\"' in patched",
198
+ "forbidden_symbols": [],
199
+ "expected_symbols": [
200
+ "%s"
201
+ ]
202
+ },
203
+ {
204
+ "id": "cat1_ast_diff_16_diff_optional_type_union",
205
+ "category": "1_surgical_diff_ast_precision",
206
+ "difficulty": "Medium",
207
+ "file": "types.py",
208
+ "original_code": "from typing import Optional\ndef find_by_id(item_id: int) -> Optional[str]:\n return None\n",
209
+ "task": "Modernize return type to Python 3.10+ union syntax str | None.",
210
+ "test_assertion": "assert '-> str | None:' in patched",
211
+ "forbidden_symbols": [],
212
+ "expected_symbols": [
213
+ "str | None"
214
+ ]
215
+ },
216
+ {
217
+ "id": "cat1_ast_diff_17_diff_try_except_clause",
218
+ "category": "1_surgical_diff_ast_precision",
219
+ "difficulty": "Medium",
220
+ "file": "storage.py",
221
+ "original_code": "def read_file(path: str) -> str:\n return open(path).read()\n",
222
+ "task": "Wrap in try/except FileNotFoundError returning empty string on failure.",
223
+ "test_assertion": "assert 'try:' in patched and 'except FileNotFoundError:' in patched",
224
+ "forbidden_symbols": [],
225
+ "expected_symbols": [
226
+ "FileNotFoundError"
227
+ ]
228
+ },
229
+ {
230
+ "id": "cat1_ast_diff_18_diff_list_comprehension_filter",
231
+ "category": "1_surgical_diff_ast_precision",
232
+ "difficulty": "Medium",
233
+ "file": "filter.py",
234
+ "original_code": "evens = []\nfor x in nums:\n if x % 2 == 0:\n evens.append(x)\n",
235
+ "task": "Refactor into a single list comprehension [x for x in nums if x % 2 == 0].",
236
+ "test_assertion": "assert 'evens = [x for x in nums if x % 2 == 0]' in patched",
237
+ "forbidden_symbols": [],
238
+ "expected_symbols": [
239
+ "evens = [x for x in nums"
240
+ ]
241
+ },
242
+ {
243
+ "id": "cat1_ast_diff_19_diff_dict_comprehension",
244
+ "category": "1_surgical_diff_ast_precision",
245
+ "difficulty": "Medium",
246
+ "file": "mapper.py",
247
+ "original_code": "lookup = {}\nfor k, v in items:\n lookup[k] = v.upper()\n",
248
+ "task": "Refactor into dict comprehension lookup = {k: v.upper() for k, v in items}.",
249
+ "test_assertion": "assert 'lookup = {k: v.upper() for k, v in items}' in patched",
250
+ "forbidden_symbols": [],
251
+ "expected_symbols": [
252
+ "lookup = {k:"
253
+ ]
254
+ },
255
+ {
256
+ "id": "cat1_ast_diff_20_diff_generator_expression",
257
+ "category": "1_surgical_diff_ast_precision",
258
+ "difficulty": "Medium",
259
+ "file": "aggregator.py",
260
+ "original_code": "total = sum([item.price for item in cart])\n",
261
+ "task": "Replace list comprehension inside sum() with generator expression (remove brackets).",
262
+ "test_assertion": "assert 'sum(item.price for item in cart)' in patched",
263
+ "forbidden_symbols": [],
264
+ "expected_symbols": [
265
+ "sum(item.price"
266
+ ]
267
+ },
268
+ {
269
+ "id": "cat1_ast_diff_21_diff_pydantic_v2_field",
270
+ "category": "1_surgical_diff_ast_precision",
271
+ "difficulty": "Hard",
272
+ "file": "user_dto.py",
273
+ "original_code": "class UserDTO(BaseModel):\n tax_id: str\n name: str\n",
274
+ "task": "Add min_length=11, max_length=14 constraints to tax_id using Field(...).",
275
+ "test_assertion": "assert 'Field(' in patched and 'min_length=11' in patched",
276
+ "forbidden_symbols": [],
277
+ "expected_symbols": [
278
+ "Field",
279
+ "min_length",
280
+ "max_length"
281
+ ]
282
+ },
283
+ {
284
+ "id": "cat1_ast_diff_22_diff_fastapi_deprecate_route",
285
+ "category": "1_surgical_diff_ast_precision",
286
+ "difficulty": "Hard",
287
+ "file": "router.py",
288
+ "original_code": "@app.get('/v1/users')\ndef list_users():\n return []\n",
289
+ "task": "Mark /v1/users as deprecated=True in route decorator.",
290
+ "test_assertion": "assert 'deprecated=True' in patched",
291
+ "forbidden_symbols": [],
292
+ "expected_symbols": [
293
+ "deprecated"
294
+ ]
295
+ },
296
+ {
297
+ "id": "cat1_ast_diff_23_diff_dataclass_frozen",
298
+ "category": "1_surgical_diff_ast_precision",
299
+ "difficulty": "Hard",
300
+ "file": "config.py",
301
+ "original_code": "@dataclass\nclass AppConfig:\n port: int = 8080\n",
302
+ "task": "Make the AppConfig dataclass frozen=True.",
303
+ "test_assertion": "assert '@dataclass(frozen=True)' in patched",
304
+ "forbidden_symbols": [],
305
+ "expected_symbols": [
306
+ "frozen=True"
307
+ ]
308
+ },
309
+ {
310
+ "id": "cat1_ast_diff_24_diff_async_def_signature",
311
+ "category": "1_surgical_diff_ast_precision",
312
+ "difficulty": "Hard",
313
+ "file": "crawler.py",
314
+ "original_code": "def fetch_page(url: str) -> str:\n return http_get(url)\n",
315
+ "task": "Convert fetch_page into an async function and await http_get(url).",
316
+ "test_assertion": "assert 'async def fetch_page' in patched and 'await http_get' in patched",
317
+ "forbidden_symbols": [],
318
+ "expected_symbols": [
319
+ "async def",
320
+ "await"
321
+ ]
322
+ },
323
+ {
324
+ "id": "cat1_ast_diff_25_diff_logger_lazy_formatting",
325
+ "category": "1_surgical_diff_ast_precision",
326
+ "difficulty": "Hard",
327
+ "file": "worker.py",
328
+ "original_code": "logger.info(f'Processing job {job_id} for user {user_id}')\n",
329
+ "task": "Replace f-string in logger call with lazy arguments logger.info('Processing job %s for user %s', job_id, user_id).",
330
+ "test_assertion": "assert 'logger.info(' in patched and '%s' in patched and not 'f\"' in patched",
331
+ "forbidden_symbols": [],
332
+ "expected_symbols": [
333
+ "%s"
334
+ ]
335
+ },
336
+ {
337
+ "id": "cat1_ast_diff_26_diff_optional_type_union",
338
+ "category": "1_surgical_diff_ast_precision",
339
+ "difficulty": "Hard",
340
+ "file": "types.py",
341
+ "original_code": "from typing import Optional\ndef find_by_id(item_id: int) -> Optional[str]:\n return None\n",
342
+ "task": "Modernize return type to Python 3.10+ union syntax str | None.",
343
+ "test_assertion": "assert '-> str | None:' in patched",
344
+ "forbidden_symbols": [],
345
+ "expected_symbols": [
346
+ "str | None"
347
+ ]
348
+ },
349
+ {
350
+ "id": "cat1_ast_diff_27_diff_try_except_clause",
351
+ "category": "1_surgical_diff_ast_precision",
352
+ "difficulty": "Hard",
353
+ "file": "storage.py",
354
+ "original_code": "def read_file(path: str) -> str:\n return open(path).read()\n",
355
+ "task": "Wrap in try/except FileNotFoundError returning empty string on failure.",
356
+ "test_assertion": "assert 'try:' in patched and 'except FileNotFoundError:' in patched",
357
+ "forbidden_symbols": [],
358
+ "expected_symbols": [
359
+ "FileNotFoundError"
360
+ ]
361
+ },
362
+ {
363
+ "id": "cat1_ast_diff_28_diff_list_comprehension_filter",
364
+ "category": "1_surgical_diff_ast_precision",
365
+ "difficulty": "Hard",
366
+ "file": "filter.py",
367
+ "original_code": "evens = []\nfor x in nums:\n if x % 2 == 0:\n evens.append(x)\n",
368
+ "task": "Refactor into a single list comprehension [x for x in nums if x % 2 == 0].",
369
+ "test_assertion": "assert 'evens = [x for x in nums if x % 2 == 0]' in patched",
370
+ "forbidden_symbols": [],
371
+ "expected_symbols": [
372
+ "evens = [x for x in nums"
373
+ ]
374
+ },
375
+ {
376
+ "id": "cat1_ast_diff_29_diff_dict_comprehension",
377
+ "category": "1_surgical_diff_ast_precision",
378
+ "difficulty": "Hard",
379
+ "file": "mapper.py",
380
+ "original_code": "lookup = {}\nfor k, v in items:\n lookup[k] = v.upper()\n",
381
+ "task": "Refactor into dict comprehension lookup = {k: v.upper() for k, v in items}.",
382
+ "test_assertion": "assert 'lookup = {k: v.upper() for k, v in items}' in patched",
383
+ "forbidden_symbols": [],
384
+ "expected_symbols": [
385
+ "lookup = {k:"
386
+ ]
387
+ },
388
+ {
389
+ "id": "cat1_ast_diff_30_diff_generator_expression",
390
+ "category": "1_surgical_diff_ast_precision",
391
+ "difficulty": "Hard",
392
+ "file": "aggregator.py",
393
+ "original_code": "total = sum([item.price for item in cart])\n",
394
+ "task": "Replace list comprehension inside sum() with generator expression (remove brackets).",
395
+ "test_assertion": "assert 'sum(item.price for item in cart)' in patched",
396
+ "forbidden_symbols": [],
397
+ "expected_symbols": [
398
+ "sum(item.price"
399
+ ]
400
+ },
401
+ {
402
+ "id": "cat2_edge_functional_01_edge_zero_division",
403
+ "category": "2_functional_correctness_edge_cases",
404
+ "difficulty": "Easy",
405
+ "file": "math_utils.py",
406
+ "original_code": "def safe_divide(a: float, b: float) -> float:\n return a / b\n",
407
+ "task": "Handle b == 0.0 returning 0.0 to prevent ZeroDivisionError.",
408
+ "test_assertion": "assert safe_divide(10.0, 0.0) == 0.0 and safe_divide(10.0, 2.0) == 5.0",
409
+ "forbidden_symbols": [],
410
+ "expected_symbols": [
411
+ "0.0"
412
+ ]
413
+ },
414
+ {
415
+ "id": "cat2_edge_functional_02_edge_none_or_empty_string",
416
+ "category": "2_functional_correctness_edge_cases",
417
+ "difficulty": "Easy",
418
+ "file": "string_utils.py",
419
+ "original_code": "def format_title(title: str) -> str:\n return title.strip().title()\n",
420
+ "task": "Safely handle title being None or empty returning empty string.",
421
+ "test_assertion": "assert format_title(None) == '' and format_title(' ') == '' and format_title('hello') == 'Hello'",
422
+ "forbidden_symbols": [],
423
+ "expected_symbols": [
424
+ "if not title"
425
+ ]
426
+ },
427
+ {
428
+ "id": "cat2_edge_functional_03_edge_dict_missing_key",
429
+ "category": "2_functional_correctness_edge_cases",
430
+ "difficulty": "Easy",
431
+ "file": "jwt_decoder.py",
432
+ "original_code": "def get_user_role(claims: dict) -> str:\n return claims['user']['role']\n",
433
+ "task": "Safely extract role returning 'anonymous' if 'user' or 'role' is missing.",
434
+ "test_assertion": "assert get_user_role({}) == 'anonymous' and get_user_role({'user': {'role': 'admin'}}) == 'admin'",
435
+ "forbidden_symbols": [],
436
+ "expected_symbols": [
437
+ ".get("
438
+ ]
439
+ },
440
+ {
441
+ "id": "cat2_edge_functional_04_edge_list_index_out_of_bounds",
442
+ "category": "2_functional_correctness_edge_cases",
443
+ "difficulty": "Easy",
444
+ "file": "queue_manager.py",
445
+ "original_code": "def peek_first(items: list) -> any:\n return items[0]\n",
446
+ "task": "Return None if items is empty without raising IndexError.",
447
+ "test_assertion": "assert peek_first([]) is None and peek_first([42]) == 42",
448
+ "forbidden_symbols": [],
449
+ "expected_symbols": [
450
+ "if not items"
451
+ ]
452
+ },
453
+ {
454
+ "id": "cat2_edge_functional_05_edge_resource_leak_context_mgr",
455
+ "category": "2_functional_correctness_edge_cases",
456
+ "difficulty": "Easy",
457
+ "file": "file_logger.py",
458
+ "original_code": "def log_message(filename: str, msg: str):\n f = open(filename, 'a')\n f.write(msg + '\\n')\n",
459
+ "task": "Refactor to with open(filename, 'a') as f: ensuring descriptor is always closed.",
460
+ "test_assertion": "assert 'with open(' in patched and 'close' not in patched",
461
+ "forbidden_symbols": [],
462
+ "expected_symbols": [
463
+ "with open"
464
+ ]
465
+ },
466
+ {
467
+ "id": "cat2_edge_functional_06_edge_mutable_default_argument",
468
+ "category": "2_functional_correctness_edge_cases",
469
+ "difficulty": "Easy",
470
+ "file": "accumulator.py",
471
+ "original_code": "def collect_data(item: int, container: list = []):\n container.append(item)\n return container\n",
472
+ "task": "Eliminate mutable default argument bug using container: list | None = None.",
473
+ "test_assertion": "c1 = collect_data(1); c2 = collect_data(2); assert c1 == [1] and c2 == [2]",
474
+ "forbidden_symbols": [],
475
+ "expected_symbols": [
476
+ "None"
477
+ ]
478
+ },
479
+ {
480
+ "id": "cat2_edge_functional_07_edge_shallow_vs_deep_copy",
481
+ "category": "2_functional_correctness_edge_cases",
482
+ "difficulty": "Easy",
483
+ "file": "state_cloner.py",
484
+ "original_code": "def copy_state(state: dict) -> dict:\n return state.copy()\n",
485
+ "task": "Use copy.deepcopy(state) to prevent mutation of nested dictionaries.",
486
+ "test_assertion": "import copy; s = {'nested': [1]}; c = copy_state(s); c['nested'].append(2); assert len(s['nested']) == 1",
487
+ "forbidden_symbols": [],
488
+ "expected_symbols": [
489
+ "deepcopy"
490
+ ]
491
+ },
492
+ {
493
+ "id": "cat2_edge_functional_08_edge_regex_trailing_newline",
494
+ "category": "2_functional_correctness_edge_cases",
495
+ "difficulty": "Easy",
496
+ "file": "slug_validator.py",
497
+ "original_code": "import re\ndef is_valid_slug(slug: str) -> bool:\n return bool(re.match(r'^[a-z0-9-]+$', slug))\n",
498
+ "task": "Fix regex to use \\Z instead of $ to avoid matching strings with trailing newlines.",
499
+ "test_assertion": "assert not is_valid_slug('valid-slug\\n') and is_valid_slug('valid-slug')",
500
+ "forbidden_symbols": [],
501
+ "expected_symbols": [
502
+ "\\Z"
503
+ ]
504
+ },
505
+ {
506
+ "id": "cat2_edge_functional_09_edge_numeric_float_precision",
507
+ "category": "2_functional_correctness_edge_cases",
508
+ "difficulty": "Easy",
509
+ "file": "currency.py",
510
+ "original_code": "def add_cents(a: float, b: float) -> float:\n return a + b\n",
511
+ "task": "Use decimal.Decimal to eliminate floating point rounding error (0.1 + 0.2 != 0.3).",
512
+ "test_assertion": "from decimal import Decimal; assert add_cents(0.1, 0.2) == 0.3 or 'Decimal' in patched",
513
+ "forbidden_symbols": [],
514
+ "expected_symbols": [
515
+ "Decimal"
516
+ ]
517
+ },
518
+ {
519
+ "id": "cat2_edge_functional_10_edge_thread_safety_lock",
520
+ "category": "2_functional_correctness_edge_cases",
521
+ "difficulty": "Easy",
522
+ "file": "counter.py",
523
+ "original_code": "class Counter:\n def __init__(self):\n self.val = 0\n def inc(self):\n self.val += 1\n",
524
+ "task": "Add threading.Lock to inc() making it thread-safe.",
525
+ "test_assertion": "assert 'threading.Lock' in patched and 'with self._lock:' in patched or 'with self.lock:' in patched",
526
+ "forbidden_symbols": [],
527
+ "expected_symbols": [
528
+ "Lock",
529
+ "with "
530
+ ]
531
+ },
532
+ {
533
+ "id": "cat2_edge_functional_11_edge_zero_division",
534
+ "category": "2_functional_correctness_edge_cases",
535
+ "difficulty": "Medium",
536
+ "file": "math_utils.py",
537
+ "original_code": "def safe_divide(a: float, b: float) -> float:\n return a / b\n",
538
+ "task": "Handle b == 0.0 returning 0.0 to prevent ZeroDivisionError.",
539
+ "test_assertion": "assert safe_divide(10.0, 0.0) == 0.0 and safe_divide(10.0, 2.0) == 5.0",
540
+ "forbidden_symbols": [],
541
+ "expected_symbols": [
542
+ "0.0"
543
+ ]
544
+ },
545
+ {
546
+ "id": "cat2_edge_functional_12_edge_none_or_empty_string",
547
+ "category": "2_functional_correctness_edge_cases",
548
+ "difficulty": "Medium",
549
+ "file": "string_utils.py",
550
+ "original_code": "def format_title(title: str) -> str:\n return title.strip().title()\n",
551
+ "task": "Safely handle title being None or empty returning empty string.",
552
+ "test_assertion": "assert format_title(None) == '' and format_title(' ') == '' and format_title('hello') == 'Hello'",
553
+ "forbidden_symbols": [],
554
+ "expected_symbols": [
555
+ "if not title"
556
+ ]
557
+ },
558
+ {
559
+ "id": "cat2_edge_functional_13_edge_dict_missing_key",
560
+ "category": "2_functional_correctness_edge_cases",
561
+ "difficulty": "Medium",
562
+ "file": "jwt_decoder.py",
563
+ "original_code": "def get_user_role(claims: dict) -> str:\n return claims['user']['role']\n",
564
+ "task": "Safely extract role returning 'anonymous' if 'user' or 'role' is missing.",
565
+ "test_assertion": "assert get_user_role({}) == 'anonymous' and get_user_role({'user': {'role': 'admin'}}) == 'admin'",
566
+ "forbidden_symbols": [],
567
+ "expected_symbols": [
568
+ ".get("
569
+ ]
570
+ },
571
+ {
572
+ "id": "cat2_edge_functional_14_edge_list_index_out_of_bounds",
573
+ "category": "2_functional_correctness_edge_cases",
574
+ "difficulty": "Medium",
575
+ "file": "queue_manager.py",
576
+ "original_code": "def peek_first(items: list) -> any:\n return items[0]\n",
577
+ "task": "Return None if items is empty without raising IndexError.",
578
+ "test_assertion": "assert peek_first([]) is None and peek_first([42]) == 42",
579
+ "forbidden_symbols": [],
580
+ "expected_symbols": [
581
+ "if not items"
582
+ ]
583
+ },
584
+ {
585
+ "id": "cat2_edge_functional_15_edge_resource_leak_context_mgr",
586
+ "category": "2_functional_correctness_edge_cases",
587
+ "difficulty": "Medium",
588
+ "file": "file_logger.py",
589
+ "original_code": "def log_message(filename: str, msg: str):\n f = open(filename, 'a')\n f.write(msg + '\\n')\n",
590
+ "task": "Refactor to with open(filename, 'a') as f: ensuring descriptor is always closed.",
591
+ "test_assertion": "assert 'with open(' in patched and 'close' not in patched",
592
+ "forbidden_symbols": [],
593
+ "expected_symbols": [
594
+ "with open"
595
+ ]
596
+ },
597
+ {
598
+ "id": "cat2_edge_functional_16_edge_mutable_default_argument",
599
+ "category": "2_functional_correctness_edge_cases",
600
+ "difficulty": "Medium",
601
+ "file": "accumulator.py",
602
+ "original_code": "def collect_data(item: int, container: list = []):\n container.append(item)\n return container\n",
603
+ "task": "Eliminate mutable default argument bug using container: list | None = None.",
604
+ "test_assertion": "c1 = collect_data(1); c2 = collect_data(2); assert c1 == [1] and c2 == [2]",
605
+ "forbidden_symbols": [],
606
+ "expected_symbols": [
607
+ "None"
608
+ ]
609
+ },
610
+ {
611
+ "id": "cat2_edge_functional_17_edge_shallow_vs_deep_copy",
612
+ "category": "2_functional_correctness_edge_cases",
613
+ "difficulty": "Medium",
614
+ "file": "state_cloner.py",
615
+ "original_code": "def copy_state(state: dict) -> dict:\n return state.copy()\n",
616
+ "task": "Use copy.deepcopy(state) to prevent mutation of nested dictionaries.",
617
+ "test_assertion": "import copy; s = {'nested': [1]}; c = copy_state(s); c['nested'].append(2); assert len(s['nested']) == 1",
618
+ "forbidden_symbols": [],
619
+ "expected_symbols": [
620
+ "deepcopy"
621
+ ]
622
+ },
623
+ {
624
+ "id": "cat2_edge_functional_18_edge_regex_trailing_newline",
625
+ "category": "2_functional_correctness_edge_cases",
626
+ "difficulty": "Medium",
627
+ "file": "slug_validator.py",
628
+ "original_code": "import re\ndef is_valid_slug(slug: str) -> bool:\n return bool(re.match(r'^[a-z0-9-]+$', slug))\n",
629
+ "task": "Fix regex to use \\Z instead of $ to avoid matching strings with trailing newlines.",
630
+ "test_assertion": "assert not is_valid_slug('valid-slug\\n') and is_valid_slug('valid-slug')",
631
+ "forbidden_symbols": [],
632
+ "expected_symbols": [
633
+ "\\Z"
634
+ ]
635
+ },
636
+ {
637
+ "id": "cat2_edge_functional_19_edge_numeric_float_precision",
638
+ "category": "2_functional_correctness_edge_cases",
639
+ "difficulty": "Medium",
640
+ "file": "currency.py",
641
+ "original_code": "def add_cents(a: float, b: float) -> float:\n return a + b\n",
642
+ "task": "Use decimal.Decimal to eliminate floating point rounding error (0.1 + 0.2 != 0.3).",
643
+ "test_assertion": "from decimal import Decimal; assert add_cents(0.1, 0.2) == 0.3 or 'Decimal' in patched",
644
+ "forbidden_symbols": [],
645
+ "expected_symbols": [
646
+ "Decimal"
647
+ ]
648
+ },
649
+ {
650
+ "id": "cat2_edge_functional_20_edge_thread_safety_lock",
651
+ "category": "2_functional_correctness_edge_cases",
652
+ "difficulty": "Medium",
653
+ "file": "counter.py",
654
+ "original_code": "class Counter:\n def __init__(self):\n self.val = 0\n def inc(self):\n self.val += 1\n",
655
+ "task": "Add threading.Lock to inc() making it thread-safe.",
656
+ "test_assertion": "assert 'threading.Lock' in patched and 'with self._lock:' in patched or 'with self.lock:' in patched",
657
+ "forbidden_symbols": [],
658
+ "expected_symbols": [
659
+ "Lock",
660
+ "with "
661
+ ]
662
+ },
663
+ {
664
+ "id": "cat2_edge_functional_21_edge_zero_division",
665
+ "category": "2_functional_correctness_edge_cases",
666
+ "difficulty": "Hard",
667
+ "file": "math_utils.py",
668
+ "original_code": "def safe_divide(a: float, b: float) -> float:\n return a / b\n",
669
+ "task": "Handle b == 0.0 returning 0.0 to prevent ZeroDivisionError.",
670
+ "test_assertion": "assert safe_divide(10.0, 0.0) == 0.0 and safe_divide(10.0, 2.0) == 5.0",
671
+ "forbidden_symbols": [],
672
+ "expected_symbols": [
673
+ "0.0"
674
+ ]
675
+ },
676
+ {
677
+ "id": "cat2_edge_functional_22_edge_none_or_empty_string",
678
+ "category": "2_functional_correctness_edge_cases",
679
+ "difficulty": "Hard",
680
+ "file": "string_utils.py",
681
+ "original_code": "def format_title(title: str) -> str:\n return title.strip().title()\n",
682
+ "task": "Safely handle title being None or empty returning empty string.",
683
+ "test_assertion": "assert format_title(None) == '' and format_title(' ') == '' and format_title('hello') == 'Hello'",
684
+ "forbidden_symbols": [],
685
+ "expected_symbols": [
686
+ "if not title"
687
+ ]
688
+ },
689
+ {
690
+ "id": "cat2_edge_functional_23_edge_dict_missing_key",
691
+ "category": "2_functional_correctness_edge_cases",
692
+ "difficulty": "Hard",
693
+ "file": "jwt_decoder.py",
694
+ "original_code": "def get_user_role(claims: dict) -> str:\n return claims['user']['role']\n",
695
+ "task": "Safely extract role returning 'anonymous' if 'user' or 'role' is missing.",
696
+ "test_assertion": "assert get_user_role({}) == 'anonymous' and get_user_role({'user': {'role': 'admin'}}) == 'admin'",
697
+ "forbidden_symbols": [],
698
+ "expected_symbols": [
699
+ ".get("
700
+ ]
701
+ },
702
+ {
703
+ "id": "cat2_edge_functional_24_edge_list_index_out_of_bounds",
704
+ "category": "2_functional_correctness_edge_cases",
705
+ "difficulty": "Hard",
706
+ "file": "queue_manager.py",
707
+ "original_code": "def peek_first(items: list) -> any:\n return items[0]\n",
708
+ "task": "Return None if items is empty without raising IndexError.",
709
+ "test_assertion": "assert peek_first([]) is None and peek_first([42]) == 42",
710
+ "forbidden_symbols": [],
711
+ "expected_symbols": [
712
+ "if not items"
713
+ ]
714
+ },
715
+ {
716
+ "id": "cat2_edge_functional_25_edge_resource_leak_context_mgr",
717
+ "category": "2_functional_correctness_edge_cases",
718
+ "difficulty": "Hard",
719
+ "file": "file_logger.py",
720
+ "original_code": "def log_message(filename: str, msg: str):\n f = open(filename, 'a')\n f.write(msg + '\\n')\n",
721
+ "task": "Refactor to with open(filename, 'a') as f: ensuring descriptor is always closed.",
722
+ "test_assertion": "assert 'with open(' in patched and 'close' not in patched",
723
+ "forbidden_symbols": [],
724
+ "expected_symbols": [
725
+ "with open"
726
+ ]
727
+ },
728
+ {
729
+ "id": "cat2_edge_functional_26_edge_mutable_default_argument",
730
+ "category": "2_functional_correctness_edge_cases",
731
+ "difficulty": "Hard",
732
+ "file": "accumulator.py",
733
+ "original_code": "def collect_data(item: int, container: list = []):\n container.append(item)\n return container\n",
734
+ "task": "Eliminate mutable default argument bug using container: list | None = None.",
735
+ "test_assertion": "c1 = collect_data(1); c2 = collect_data(2); assert c1 == [1] and c2 == [2]",
736
+ "forbidden_symbols": [],
737
+ "expected_symbols": [
738
+ "None"
739
+ ]
740
+ },
741
+ {
742
+ "id": "cat2_edge_functional_27_edge_shallow_vs_deep_copy",
743
+ "category": "2_functional_correctness_edge_cases",
744
+ "difficulty": "Hard",
745
+ "file": "state_cloner.py",
746
+ "original_code": "def copy_state(state: dict) -> dict:\n return state.copy()\n",
747
+ "task": "Use copy.deepcopy(state) to prevent mutation of nested dictionaries.",
748
+ "test_assertion": "import copy; s = {'nested': [1]}; c = copy_state(s); c['nested'].append(2); assert len(s['nested']) == 1",
749
+ "forbidden_symbols": [],
750
+ "expected_symbols": [
751
+ "deepcopy"
752
+ ]
753
+ },
754
+ {
755
+ "id": "cat2_edge_functional_28_edge_regex_trailing_newline",
756
+ "category": "2_functional_correctness_edge_cases",
757
+ "difficulty": "Hard",
758
+ "file": "slug_validator.py",
759
+ "original_code": "import re\ndef is_valid_slug(slug: str) -> bool:\n return bool(re.match(r'^[a-z0-9-]+$', slug))\n",
760
+ "task": "Fix regex to use \\Z instead of $ to avoid matching strings with trailing newlines.",
761
+ "test_assertion": "assert not is_valid_slug('valid-slug\\n') and is_valid_slug('valid-slug')",
762
+ "forbidden_symbols": [],
763
+ "expected_symbols": [
764
+ "\\Z"
765
+ ]
766
+ },
767
+ {
768
+ "id": "cat2_edge_functional_29_edge_numeric_float_precision",
769
+ "category": "2_functional_correctness_edge_cases",
770
+ "difficulty": "Hard",
771
+ "file": "currency.py",
772
+ "original_code": "def add_cents(a: float, b: float) -> float:\n return a + b\n",
773
+ "task": "Use decimal.Decimal to eliminate floating point rounding error (0.1 + 0.2 != 0.3).",
774
+ "test_assertion": "from decimal import Decimal; assert add_cents(0.1, 0.2) == 0.3 or 'Decimal' in patched",
775
+ "forbidden_symbols": [],
776
+ "expected_symbols": [
777
+ "Decimal"
778
+ ]
779
+ },
780
+ {
781
+ "id": "cat2_edge_functional_30_edge_thread_safety_lock",
782
+ "category": "2_functional_correctness_edge_cases",
783
+ "difficulty": "Hard",
784
+ "file": "counter.py",
785
+ "original_code": "class Counter:\n def __init__(self):\n self.val = 0\n def inc(self):\n self.val += 1\n",
786
+ "task": "Add threading.Lock to inc() making it thread-safe.",
787
+ "test_assertion": "assert 'threading.Lock' in patched and 'with self._lock:' in patched or 'with self.lock:' in patched",
788
+ "forbidden_symbols": [],
789
+ "expected_symbols": [
790
+ "Lock",
791
+ "with "
792
+ ]
793
+ },
794
+ {
795
+ "id": "cat3_ghost_api_trap_01_trap_pydantic_v1_validator",
796
+ "category": "3_ghost_api_and_deprecated_traps",
797
+ "difficulty": "Medium",
798
+ "file": "schemas.py",
799
+ "original_code": "# Target: Pydantic v2.6+\nfrom pydantic import BaseModel\nclass User(BaseModel):\n name: str\n",
800
+ "task": "Add validator for name uppercase. TRAP: DO NOT use Pydantic v1 @validator; use Pydantic v2 @field_validator.",
801
+ "test_assertion": "assert '@field_validator' in patched and '@validator' not in patched",
802
+ "forbidden_symbols": [
803
+ "@validator",
804
+ "validator("
805
+ ],
806
+ "expected_symbols": [
807
+ "@field_validator"
808
+ ]
809
+ },
810
+ {
811
+ "id": "cat3_ghost_api_trap_02_trap_pandas_append_deprecated",
812
+ "category": "3_ghost_api_and_deprecated_traps",
813
+ "difficulty": "Medium",
814
+ "file": "analytics.py",
815
+ "original_code": "# Target: Pandas 2.0+\nimport pandas as pd\ndef add_row(df: pd.DataFrame, row: dict) -> pd.DataFrame:\n pass\n",
816
+ "task": "Append row to DataFrame. TRAP: df.append was removed in Pandas 2.0. Use pd.concat.",
817
+ "test_assertion": "assert 'pd.concat' in patched and '.append(' not in patched",
818
+ "forbidden_symbols": [
819
+ ".append("
820
+ ],
821
+ "expected_symbols": [
822
+ "pd.concat"
823
+ ]
824
+ },
825
+ {
826
+ "id": "cat3_ghost_api_trap_03_trap_sqlalchemy_v2_execute",
827
+ "category": "3_ghost_api_and_deprecated_traps",
828
+ "difficulty": "Medium",
829
+ "file": "db.py",
830
+ "original_code": "# Target: SQLAlchemy 2.0+\nfrom sqlalchemy.orm import Session\ndef get_users(session: Session):\n pass\n",
831
+ "task": "Query users. TRAP: session.query() is legacy in 2.0. Use session.scalars(select(User)).",
832
+ "test_assertion": "assert 'select(' in patched and 'session.query' not in patched",
833
+ "forbidden_symbols": [
834
+ "session.query"
835
+ ],
836
+ "expected_symbols": [
837
+ "select("
838
+ ]
839
+ },
840
+ {
841
+ "id": "cat3_ghost_api_trap_04_trap_list_flatten_hallucination",
842
+ "category": "3_ghost_api_and_deprecated_traps",
843
+ "difficulty": "Medium",
844
+ "file": "arrays.py",
845
+ "original_code": "def flatten(nested: list) -> list:\n pass\n",
846
+ "task": "Flatten a nested list of lists. TRAP: Python lists DO NOT have a list.flatten() method.",
847
+ "test_assertion": "assert 'flatten()' not in patched and ('sum(' in patched or 'for sub in nested' in patched or 'chain' in patched)",
848
+ "forbidden_symbols": [
849
+ "nested.flatten",
850
+ ".flatten()"
851
+ ],
852
+ "expected_symbols": []
853
+ },
854
+ {
855
+ "id": "cat3_ghost_api_trap_05_trap_json_loads_file_descriptor",
856
+ "category": "3_ghost_api_and_deprecated_traps",
857
+ "difficulty": "Medium",
858
+ "file": "parser.py",
859
+ "original_code": "import json\ndef parse_file(filepath: str):\n with open(filepath) as f:\n pass\n",
860
+ "task": "Read JSON from file. TRAP: json.loads takes a string; json.load takes a file. DO NOT call json.loads(f).",
861
+ "test_assertion": "assert 'json.load(f)' in patched and 'json.loads(f)' not in patched",
862
+ "forbidden_symbols": [
863
+ "json.loads(f)"
864
+ ],
865
+ "expected_symbols": [
866
+ "json.load(f)"
867
+ ]
868
+ },
869
+ {
870
+ "id": "cat3_ghost_api_trap_06_trap_datetime_utcnow_deprecation",
871
+ "category": "3_ghost_api_and_deprecated_traps",
872
+ "difficulty": "Medium",
873
+ "file": "clock.py",
874
+ "original_code": "from datetime import datetime\ndef current_time():\n pass\n",
875
+ "task": "Get current UTC time. TRAP: datetime.utcnow() is deprecated in Python 3.12+. Use datetime.now(timezone.utc).",
876
+ "test_assertion": "assert 'timezone.utc' in patched and 'utcnow()' not in patched",
877
+ "forbidden_symbols": [
878
+ "datetime.utcnow",
879
+ "utcnow()"
880
+ ],
881
+ "expected_symbols": [
882
+ "timezone.utc"
883
+ ]
884
+ },
885
+ {
886
+ "id": "cat3_ghost_api_trap_07_trap_asyncio_get_event_loop_deprecation",
887
+ "category": "3_ghost_api_and_deprecated_traps",
888
+ "difficulty": "Medium",
889
+ "file": "async_boot.py",
890
+ "original_code": "import asyncio\ndef run_task(coro):\n pass\n",
891
+ "task": "Run coroutine. TRAP: asyncio.get_event_loop().run_until_complete() is deprecated in modern Python. Use asyncio.run(coro).",
892
+ "test_assertion": "assert 'asyncio.run(' in patched and 'get_event_loop' not in patched",
893
+ "forbidden_symbols": [
894
+ "get_event_loop"
895
+ ],
896
+ "expected_symbols": [
897
+ "asyncio.run"
898
+ ]
899
+ },
900
+ {
901
+ "id": "cat3_ghost_api_trap_08_trap_dict_has_key_ancient_method",
902
+ "category": "3_ghost_api_and_deprecated_traps",
903
+ "difficulty": "Medium",
904
+ "file": "legacy.py",
905
+ "original_code": "def check_key(d: dict, k: str) -> bool:\n pass\n",
906
+ "task": "Check if dictionary contains key. TRAP: d.has_key() was removed in Python 3. Use 'k in d'.",
907
+ "test_assertion": "assert 'has_key' not in patched and 'k in d' in patched",
908
+ "forbidden_symbols": [
909
+ ".has_key("
910
+ ],
911
+ "expected_symbols": [
912
+ "in d"
913
+ ]
914
+ },
915
+ {
916
+ "id": "cat3_ghost_api_trap_09_trap_str_is_numeric_vs_isnumeric",
917
+ "category": "3_ghost_api_and_deprecated_traps",
918
+ "difficulty": "Medium",
919
+ "file": "cleaner.py",
920
+ "original_code": "def is_all_digits(s: str) -> bool:\n pass\n",
921
+ "task": "Check if string contains only digits. TRAP: Python strings have .isdigit() or .isnumeric(), NOT .is_digit() or .is_numeric().",
922
+ "test_assertion": "assert 'is_numeric' not in patched and 'is_digit' not in patched and ('.isdigit()' in patched or '.isnumeric()' in patched)",
923
+ "forbidden_symbols": [
924
+ ".is_numeric(",
925
+ ".is_digit("
926
+ ],
927
+ "expected_symbols": [
928
+ ".isdigit()",
929
+ ".isnumeric()"
930
+ ]
931
+ },
932
+ {
933
+ "id": "cat3_ghost_api_trap_10_trap_math_round_hallucination",
934
+ "category": "3_ghost_api_and_deprecated_traps",
935
+ "difficulty": "Medium",
936
+ "file": "rounder.py",
937
+ "original_code": "def round_val(x: float) -> int:\n pass\n",
938
+ "task": "Round float to nearest int. TRAP: math.round() does not exist in standard library math module. Use built-in round(x).",
939
+ "test_assertion": "assert 'math.round' not in patched and 'round(' in patched",
940
+ "forbidden_symbols": [
941
+ "math.round("
942
+ ],
943
+ "expected_symbols": [
944
+ "round("
945
+ ]
946
+ },
947
+ {
948
+ "id": "cat3_ghost_api_trap_11_trap_pydantic_v1_validator",
949
+ "category": "3_ghost_api_and_deprecated_traps",
950
+ "difficulty": "Medium",
951
+ "file": "schemas.py",
952
+ "original_code": "# Target: Pydantic v2.6+\nfrom pydantic import BaseModel\nclass User(BaseModel):\n name: str\n",
953
+ "task": "Add validator for name uppercase. TRAP: DO NOT use Pydantic v1 @validator; use Pydantic v2 @field_validator.",
954
+ "test_assertion": "assert '@field_validator' in patched and '@validator' not in patched",
955
+ "forbidden_symbols": [
956
+ "@validator",
957
+ "validator("
958
+ ],
959
+ "expected_symbols": [
960
+ "@field_validator"
961
+ ]
962
+ },
963
+ {
964
+ "id": "cat3_ghost_api_trap_12_trap_pandas_append_deprecated",
965
+ "category": "3_ghost_api_and_deprecated_traps",
966
+ "difficulty": "Medium",
967
+ "file": "analytics.py",
968
+ "original_code": "# Target: Pandas 2.0+\nimport pandas as pd\ndef add_row(df: pd.DataFrame, row: dict) -> pd.DataFrame:\n pass\n",
969
+ "task": "Append row to DataFrame. TRAP: df.append was removed in Pandas 2.0. Use pd.concat.",
970
+ "test_assertion": "assert 'pd.concat' in patched and '.append(' not in patched",
971
+ "forbidden_symbols": [
972
+ ".append("
973
+ ],
974
+ "expected_symbols": [
975
+ "pd.concat"
976
+ ]
977
+ },
978
+ {
979
+ "id": "cat3_ghost_api_trap_13_trap_sqlalchemy_v2_execute",
980
+ "category": "3_ghost_api_and_deprecated_traps",
981
+ "difficulty": "Medium",
982
+ "file": "db.py",
983
+ "original_code": "# Target: SQLAlchemy 2.0+\nfrom sqlalchemy.orm import Session\ndef get_users(session: Session):\n pass\n",
984
+ "task": "Query users. TRAP: session.query() is legacy in 2.0. Use session.scalars(select(User)).",
985
+ "test_assertion": "assert 'select(' in patched and 'session.query' not in patched",
986
+ "forbidden_symbols": [
987
+ "session.query"
988
+ ],
989
+ "expected_symbols": [
990
+ "select("
991
+ ]
992
+ },
993
+ {
994
+ "id": "cat3_ghost_api_trap_14_trap_list_flatten_hallucination",
995
+ "category": "3_ghost_api_and_deprecated_traps",
996
+ "difficulty": "Medium",
997
+ "file": "arrays.py",
998
+ "original_code": "def flatten(nested: list) -> list:\n pass\n",
999
+ "task": "Flatten a nested list of lists. TRAP: Python lists DO NOT have a list.flatten() method.",
1000
+ "test_assertion": "assert 'flatten()' not in patched and ('sum(' in patched or 'for sub in nested' in patched or 'chain' in patched)",
1001
+ "forbidden_symbols": [
1002
+ "nested.flatten",
1003
+ ".flatten()"
1004
+ ],
1005
+ "expected_symbols": []
1006
+ },
1007
+ {
1008
+ "id": "cat3_ghost_api_trap_15_trap_json_loads_file_descriptor",
1009
+ "category": "3_ghost_api_and_deprecated_traps",
1010
+ "difficulty": "Medium",
1011
+ "file": "parser.py",
1012
+ "original_code": "import json\ndef parse_file(filepath: str):\n with open(filepath) as f:\n pass\n",
1013
+ "task": "Read JSON from file. TRAP: json.loads takes a string; json.load takes a file. DO NOT call json.loads(f).",
1014
+ "test_assertion": "assert 'json.load(f)' in patched and 'json.loads(f)' not in patched",
1015
+ "forbidden_symbols": [
1016
+ "json.loads(f)"
1017
+ ],
1018
+ "expected_symbols": [
1019
+ "json.load(f)"
1020
+ ]
1021
+ },
1022
+ {
1023
+ "id": "cat3_ghost_api_trap_16_trap_datetime_utcnow_deprecation",
1024
+ "category": "3_ghost_api_and_deprecated_traps",
1025
+ "difficulty": "Hard",
1026
+ "file": "clock.py",
1027
+ "original_code": "from datetime import datetime\ndef current_time():\n pass\n",
1028
+ "task": "Get current UTC time. TRAP: datetime.utcnow() is deprecated in Python 3.12+. Use datetime.now(timezone.utc).",
1029
+ "test_assertion": "assert 'timezone.utc' in patched and 'utcnow()' not in patched",
1030
+ "forbidden_symbols": [
1031
+ "datetime.utcnow",
1032
+ "utcnow()"
1033
+ ],
1034
+ "expected_symbols": [
1035
+ "timezone.utc"
1036
+ ]
1037
+ },
1038
+ {
1039
+ "id": "cat3_ghost_api_trap_17_trap_asyncio_get_event_loop_deprecation",
1040
+ "category": "3_ghost_api_and_deprecated_traps",
1041
+ "difficulty": "Hard",
1042
+ "file": "async_boot.py",
1043
+ "original_code": "import asyncio\ndef run_task(coro):\n pass\n",
1044
+ "task": "Run coroutine. TRAP: asyncio.get_event_loop().run_until_complete() is deprecated in modern Python. Use asyncio.run(coro).",
1045
+ "test_assertion": "assert 'asyncio.run(' in patched and 'get_event_loop' not in patched",
1046
+ "forbidden_symbols": [
1047
+ "get_event_loop"
1048
+ ],
1049
+ "expected_symbols": [
1050
+ "asyncio.run"
1051
+ ]
1052
+ },
1053
+ {
1054
+ "id": "cat3_ghost_api_trap_18_trap_dict_has_key_ancient_method",
1055
+ "category": "3_ghost_api_and_deprecated_traps",
1056
+ "difficulty": "Hard",
1057
+ "file": "legacy.py",
1058
+ "original_code": "def check_key(d: dict, k: str) -> bool:\n pass\n",
1059
+ "task": "Check if dictionary contains key. TRAP: d.has_key() was removed in Python 3. Use 'k in d'.",
1060
+ "test_assertion": "assert 'has_key' not in patched and 'k in d' in patched",
1061
+ "forbidden_symbols": [
1062
+ ".has_key("
1063
+ ],
1064
+ "expected_symbols": [
1065
+ "in d"
1066
+ ]
1067
+ },
1068
+ {
1069
+ "id": "cat3_ghost_api_trap_19_trap_str_is_numeric_vs_isnumeric",
1070
+ "category": "3_ghost_api_and_deprecated_traps",
1071
+ "difficulty": "Hard",
1072
+ "file": "cleaner.py",
1073
+ "original_code": "def is_all_digits(s: str) -> bool:\n pass\n",
1074
+ "task": "Check if string contains only digits. TRAP: Python strings have .isdigit() or .isnumeric(), NOT .is_digit() or .is_numeric().",
1075
+ "test_assertion": "assert 'is_numeric' not in patched and 'is_digit' not in patched and ('.isdigit()' in patched or '.isnumeric()' in patched)",
1076
+ "forbidden_symbols": [
1077
+ ".is_numeric(",
1078
+ ".is_digit("
1079
+ ],
1080
+ "expected_symbols": [
1081
+ ".isdigit()",
1082
+ ".isnumeric()"
1083
+ ]
1084
+ },
1085
+ {
1086
+ "id": "cat3_ghost_api_trap_20_trap_math_round_hallucination",
1087
+ "category": "3_ghost_api_and_deprecated_traps",
1088
+ "difficulty": "Hard",
1089
+ "file": "rounder.py",
1090
+ "original_code": "def round_val(x: float) -> int:\n pass\n",
1091
+ "task": "Round float to nearest int. TRAP: math.round() does not exist in standard library math module. Use built-in round(x).",
1092
+ "test_assertion": "assert 'math.round' not in patched and 'round(' in patched",
1093
+ "forbidden_symbols": [
1094
+ "math.round("
1095
+ ],
1096
+ "expected_symbols": [
1097
+ "round("
1098
+ ]
1099
+ },
1100
+ {
1101
+ "id": "cat3_ghost_api_trap_21_trap_pydantic_v1_validator",
1102
+ "category": "3_ghost_api_and_deprecated_traps",
1103
+ "difficulty": "Hard",
1104
+ "file": "schemas.py",
1105
+ "original_code": "# Target: Pydantic v2.6+\nfrom pydantic import BaseModel\nclass User(BaseModel):\n name: str\n",
1106
+ "task": "Add validator for name uppercase. TRAP: DO NOT use Pydantic v1 @validator; use Pydantic v2 @field_validator.",
1107
+ "test_assertion": "assert '@field_validator' in patched and '@validator' not in patched",
1108
+ "forbidden_symbols": [
1109
+ "@validator",
1110
+ "validator("
1111
+ ],
1112
+ "expected_symbols": [
1113
+ "@field_validator"
1114
+ ]
1115
+ },
1116
+ {
1117
+ "id": "cat3_ghost_api_trap_22_trap_pandas_append_deprecated",
1118
+ "category": "3_ghost_api_and_deprecated_traps",
1119
+ "difficulty": "Hard",
1120
+ "file": "analytics.py",
1121
+ "original_code": "# Target: Pandas 2.0+\nimport pandas as pd\ndef add_row(df: pd.DataFrame, row: dict) -> pd.DataFrame:\n pass\n",
1122
+ "task": "Append row to DataFrame. TRAP: df.append was removed in Pandas 2.0. Use pd.concat.",
1123
+ "test_assertion": "assert 'pd.concat' in patched and '.append(' not in patched",
1124
+ "forbidden_symbols": [
1125
+ ".append("
1126
+ ],
1127
+ "expected_symbols": [
1128
+ "pd.concat"
1129
+ ]
1130
+ },
1131
+ {
1132
+ "id": "cat3_ghost_api_trap_23_trap_sqlalchemy_v2_execute",
1133
+ "category": "3_ghost_api_and_deprecated_traps",
1134
+ "difficulty": "Hard",
1135
+ "file": "db.py",
1136
+ "original_code": "# Target: SQLAlchemy 2.0+\nfrom sqlalchemy.orm import Session\ndef get_users(session: Session):\n pass\n",
1137
+ "task": "Query users. TRAP: session.query() is legacy in 2.0. Use session.scalars(select(User)).",
1138
+ "test_assertion": "assert 'select(' in patched and 'session.query' not in patched",
1139
+ "forbidden_symbols": [
1140
+ "session.query"
1141
+ ],
1142
+ "expected_symbols": [
1143
+ "select("
1144
+ ]
1145
+ },
1146
+ {
1147
+ "id": "cat3_ghost_api_trap_24_trap_list_flatten_hallucination",
1148
+ "category": "3_ghost_api_and_deprecated_traps",
1149
+ "difficulty": "Hard",
1150
+ "file": "arrays.py",
1151
+ "original_code": "def flatten(nested: list) -> list:\n pass\n",
1152
+ "task": "Flatten a nested list of lists. TRAP: Python lists DO NOT have a list.flatten() method.",
1153
+ "test_assertion": "assert 'flatten()' not in patched and ('sum(' in patched or 'for sub in nested' in patched or 'chain' in patched)",
1154
+ "forbidden_symbols": [
1155
+ "nested.flatten",
1156
+ ".flatten()"
1157
+ ],
1158
+ "expected_symbols": []
1159
+ },
1160
+ {
1161
+ "id": "cat3_ghost_api_trap_25_trap_json_loads_file_descriptor",
1162
+ "category": "3_ghost_api_and_deprecated_traps",
1163
+ "difficulty": "Hard",
1164
+ "file": "parser.py",
1165
+ "original_code": "import json\ndef parse_file(filepath: str):\n with open(filepath) as f:\n pass\n",
1166
+ "task": "Read JSON from file. TRAP: json.loads takes a string; json.load takes a file. DO NOT call json.loads(f).",
1167
+ "test_assertion": "assert 'json.load(f)' in patched and 'json.loads(f)' not in patched",
1168
+ "forbidden_symbols": [
1169
+ "json.loads(f)"
1170
+ ],
1171
+ "expected_symbols": [
1172
+ "json.load(f)"
1173
+ ]
1174
+ },
1175
+ {
1176
+ "id": "cat3_ghost_api_trap_26_trap_datetime_utcnow_deprecation",
1177
+ "category": "3_ghost_api_and_deprecated_traps",
1178
+ "difficulty": "Hard",
1179
+ "file": "clock.py",
1180
+ "original_code": "from datetime import datetime\ndef current_time():\n pass\n",
1181
+ "task": "Get current UTC time. TRAP: datetime.utcnow() is deprecated in Python 3.12+. Use datetime.now(timezone.utc).",
1182
+ "test_assertion": "assert 'timezone.utc' in patched and 'utcnow()' not in patched",
1183
+ "forbidden_symbols": [
1184
+ "datetime.utcnow",
1185
+ "utcnow()"
1186
+ ],
1187
+ "expected_symbols": [
1188
+ "timezone.utc"
1189
+ ]
1190
+ },
1191
+ {
1192
+ "id": "cat3_ghost_api_trap_27_trap_asyncio_get_event_loop_deprecation",
1193
+ "category": "3_ghost_api_and_deprecated_traps",
1194
+ "difficulty": "Hard",
1195
+ "file": "async_boot.py",
1196
+ "original_code": "import asyncio\ndef run_task(coro):\n pass\n",
1197
+ "task": "Run coroutine. TRAP: asyncio.get_event_loop().run_until_complete() is deprecated in modern Python. Use asyncio.run(coro).",
1198
+ "test_assertion": "assert 'asyncio.run(' in patched and 'get_event_loop' not in patched",
1199
+ "forbidden_symbols": [
1200
+ "get_event_loop"
1201
+ ],
1202
+ "expected_symbols": [
1203
+ "asyncio.run"
1204
+ ]
1205
+ },
1206
+ {
1207
+ "id": "cat3_ghost_api_trap_28_trap_dict_has_key_ancient_method",
1208
+ "category": "3_ghost_api_and_deprecated_traps",
1209
+ "difficulty": "Hard",
1210
+ "file": "legacy.py",
1211
+ "original_code": "def check_key(d: dict, k: str) -> bool:\n pass\n",
1212
+ "task": "Check if dictionary contains key. TRAP: d.has_key() was removed in Python 3. Use 'k in d'.",
1213
+ "test_assertion": "assert 'has_key' not in patched and 'k in d' in patched",
1214
+ "forbidden_symbols": [
1215
+ ".has_key("
1216
+ ],
1217
+ "expected_symbols": [
1218
+ "in d"
1219
+ ]
1220
+ },
1221
+ {
1222
+ "id": "cat3_ghost_api_trap_29_trap_str_is_numeric_vs_isnumeric",
1223
+ "category": "3_ghost_api_and_deprecated_traps",
1224
+ "difficulty": "Hard",
1225
+ "file": "cleaner.py",
1226
+ "original_code": "def is_all_digits(s: str) -> bool:\n pass\n",
1227
+ "task": "Check if string contains only digits. TRAP: Python strings have .isdigit() or .isnumeric(), NOT .is_digit() or .is_numeric().",
1228
+ "test_assertion": "assert 'is_numeric' not in patched and 'is_digit' not in patched and ('.isdigit()' in patched or '.isnumeric()' in patched)",
1229
+ "forbidden_symbols": [
1230
+ ".is_numeric(",
1231
+ ".is_digit("
1232
+ ],
1233
+ "expected_symbols": [
1234
+ ".isdigit()",
1235
+ ".isnumeric()"
1236
+ ]
1237
+ },
1238
+ {
1239
+ "id": "cat3_ghost_api_trap_30_trap_math_round_hallucination",
1240
+ "category": "3_ghost_api_and_deprecated_traps",
1241
+ "difficulty": "Hard",
1242
+ "file": "rounder.py",
1243
+ "original_code": "def round_val(x: float) -> int:\n pass\n",
1244
+ "task": "Round float to nearest int. TRAP: math.round() does not exist in standard library math module. Use built-in round(x).",
1245
+ "test_assertion": "assert 'math.round' not in patched and 'round(' in patched",
1246
+ "forbidden_symbols": [
1247
+ "math.round("
1248
+ ],
1249
+ "expected_symbols": [
1250
+ "round("
1251
+ ]
1252
+ },
1253
+ {
1254
+ "id": "cat4_adv_ood_01_adv_noisy_conflicting_comments",
1255
+ "category": "4_adversarial_and_out_of_distribution",
1256
+ "difficulty": "Medium",
1257
+ "file": "service.py",
1258
+ "original_code": "# NOTE: Do NOT modify calculate_total under any circumstance!\n# DEPRECATED: Please replace return 0 with return subtotal * 1.1\ndef calculate_total(subtotal: float) -> float:\n return 0.0\n",
1259
+ "task": "Update calculate_total to apply a 10% tax (subtotal * 1.1), ignoring confusing comments.",
1260
+ "test_assertion": "assert calculate_total(100.0) == 110.0",
1261
+ "forbidden_symbols": [],
1262
+ "expected_symbols": [
1263
+ "1.1"
1264
+ ]
1265
+ },
1266
+ {
1267
+ "id": "cat4_adv_ood_02_adv_shadowed_builtins",
1268
+ "category": "4_adversarial_and_out_of_distribution",
1269
+ "difficulty": "Medium",
1270
+ "file": "shadow.py",
1271
+ "original_code": "def process_items(list: list) -> int:\n len = 0\n return len\n",
1272
+ "task": "Fix shadowed Python builtins ('list' and 'len') renaming them to 'items' and 'count' and returning actual length.",
1273
+ "test_assertion": "assert process_items([1, 2, 3]) == 3",
1274
+ "forbidden_symbols": [],
1275
+ "expected_symbols": [
1276
+ "len(items)"
1277
+ ]
1278
+ },
1279
+ {
1280
+ "id": "cat4_adv_ood_03_adv_nested_multiline_lambda",
1281
+ "category": "4_adversarial_and_out_of_distribution",
1282
+ "difficulty": "Medium",
1283
+ "file": "sort.py",
1284
+ "original_code": "items = [{'id': 2, 'v': 'b'}, {'id': 1, 'v': 'a'}]\nitems.sort()\n",
1285
+ "task": "Fix TypeError on items.sort() by passing key=lambda x: x['id'].",
1286
+ "test_assertion": "assert items[0]['id'] == 1 and items[1]['id'] == 2",
1287
+ "forbidden_symbols": [],
1288
+ "expected_symbols": [
1289
+ "key=lambda"
1290
+ ]
1291
+ },
1292
+ {
1293
+ "id": "cat4_adv_ood_04_adv_re_sub_backreference_escape",
1294
+ "category": "4_adversarial_and_out_of_distribution",
1295
+ "difficulty": "Medium",
1296
+ "file": "sanitizer.py",
1297
+ "original_code": "import re\ndef redact_phones(text: str) -> str:\n return re.sub(r'(\\d{3})-(\\d{4})', '[REDACTED]', text)\n",
1298
+ "task": "Keep area code prefix, redacting only the last 4 digits: e.g. 555-1234 -> 555-XXXX.",
1299
+ "test_assertion": "assert redact_phones('Call 555-1234') == 'Call 555-XXXX'",
1300
+ "forbidden_symbols": [],
1301
+ "expected_symbols": [
1302
+ "XXXX"
1303
+ ]
1304
+ },
1305
+ {
1306
+ "id": "cat4_adv_ood_05_adv_unicode_casefolding",
1307
+ "category": "4_adversarial_and_out_of_distribution",
1308
+ "difficulty": "Medium",
1309
+ "file": "auth_user.py",
1310
+ "original_code": "def compare_usernames(a: str, b: str) -> bool:\n return a.lower() == b.lower()\n",
1311
+ "task": "Use casefold() instead of lower() for robust internationalized Unicode string comparison (e.g. German 'ß' == 'ss').",
1312
+ "test_assertion": "assert compare_usernames('straße', 'STRASSE') is True or 'casefold' in patched",
1313
+ "forbidden_symbols": [],
1314
+ "expected_symbols": [
1315
+ "casefold"
1316
+ ]
1317
+ },
1318
+ {
1319
+ "id": "cat4_adv_ood_06_adv_env_variable_cast_trap",
1320
+ "category": "4_adversarial_and_out_of_distribution",
1321
+ "difficulty": "Medium",
1322
+ "file": "settings.py",
1323
+ "original_code": "import os\nDEBUG = os.getenv('DEBUG', False)\n",
1324
+ "task": "Fix os.getenv() always returning string bug: cast 'true', '1', 'yes' to boolean True.",
1325
+ "test_assertion": "assert 'lower() in' in patched or 'bool(' in patched",
1326
+ "forbidden_symbols": [],
1327
+ "expected_symbols": [
1328
+ "lower()"
1329
+ ]
1330
+ },
1331
+ {
1332
+ "id": "cat4_adv_ood_07_adv_generator_double_consumption",
1333
+ "category": "4_adversarial_and_out_of_distribution",
1334
+ "difficulty": "Medium",
1335
+ "file": "stream.py",
1336
+ "original_code": "def analyze_stream(gen):\n c = len(list(gen))\n s = sum(list(gen))\n return c, s\n",
1337
+ "task": "Fix generator exhaustion bug: cache stream into items = list(gen) once before computing count and sum.",
1338
+ "test_assertion": "def g(): yield 10; yield 20\nc, s = analyze_stream(g()); assert c == 2 and s == 30",
1339
+ "forbidden_symbols": [],
1340
+ "expected_symbols": [
1341
+ "items = list(gen)"
1342
+ ]
1343
+ },
1344
+ {
1345
+ "id": "cat4_adv_ood_08_adv_tuple_single_element_comma",
1346
+ "category": "4_adversarial_and_out_of_distribution",
1347
+ "difficulty": "Medium",
1348
+ "file": "params.py",
1349
+ "original_code": "singleton_param = ('only_item')\n",
1350
+ "task": "Fix syntax bug where singleton_param is parsed as a str rather than a single-element tuple.",
1351
+ "test_assertion": "assert isinstance(singleton_param, tuple) and len(singleton_param) == 1",
1352
+ "forbidden_symbols": [],
1353
+ "expected_symbols": [
1354
+ "('only_item',",
1355
+ "('only_item',)"
1356
+ ]
1357
+ },
1358
+ {
1359
+ "id": "cat4_adv_ood_09_adv_walrus_operator_leak",
1360
+ "category": "4_adversarial_and_out_of_distribution",
1361
+ "difficulty": "Medium",
1362
+ "file": "finder.py",
1363
+ "original_code": "def find_match(pattern, text):\n match = re.search(pattern, text)\n if match:\n return match.group(0)\n return None\n",
1364
+ "task": "Refactor using Python 3.8+ walrus operator := inside the if condition.",
1365
+ "test_assertion": "assert 'if match := re.search(' in patched or 'if (match :=' in patched",
1366
+ "forbidden_symbols": [],
1367
+ "expected_symbols": [
1368
+ ":="
1369
+ ]
1370
+ },
1371
+ {
1372
+ "id": "cat4_adv_ood_10_adv_context_manager_suppress",
1373
+ "category": "4_adversarial_and_out_of_distribution",
1374
+ "difficulty": "Medium",
1375
+ "file": "clean_remove.py",
1376
+ "original_code": "import os\ndef try_remove(path: str):\n try:\n os.remove(path)\n except FileNotFoundError:\n pass\n",
1377
+ "task": "Refactor into contextlib.suppress(FileNotFoundError) for cleaner, idiomatic code.",
1378
+ "test_assertion": "assert 'suppress(FileNotFoundError)' in patched",
1379
+ "forbidden_symbols": [],
1380
+ "expected_symbols": [
1381
+ "contextlib.suppress",
1382
+ "suppress(FileNotFoundError)"
1383
+ ]
1384
+ },
1385
+ {
1386
+ "id": "cat4_adv_ood_11_adv_noisy_conflicting_comments",
1387
+ "category": "4_adversarial_and_out_of_distribution",
1388
+ "difficulty": "Medium",
1389
+ "file": "service.py",
1390
+ "original_code": "# NOTE: Do NOT modify calculate_total under any circumstance!\n# DEPRECATED: Please replace return 0 with return subtotal * 1.1\ndef calculate_total(subtotal: float) -> float:\n return 0.0\n",
1391
+ "task": "Update calculate_total to apply a 10% tax (subtotal * 1.1), ignoring confusing comments.",
1392
+ "test_assertion": "assert calculate_total(100.0) == 110.0",
1393
+ "forbidden_symbols": [],
1394
+ "expected_symbols": [
1395
+ "1.1"
1396
+ ]
1397
+ },
1398
+ {
1399
+ "id": "cat4_adv_ood_12_adv_shadowed_builtins",
1400
+ "category": "4_adversarial_and_out_of_distribution",
1401
+ "difficulty": "Medium",
1402
+ "file": "shadow.py",
1403
+ "original_code": "def process_items(list: list) -> int:\n len = 0\n return len\n",
1404
+ "task": "Fix shadowed Python builtins ('list' and 'len') renaming them to 'items' and 'count' and returning actual length.",
1405
+ "test_assertion": "assert process_items([1, 2, 3]) == 3",
1406
+ "forbidden_symbols": [],
1407
+ "expected_symbols": [
1408
+ "len(items)"
1409
+ ]
1410
+ },
1411
+ {
1412
+ "id": "cat4_adv_ood_13_adv_nested_multiline_lambda",
1413
+ "category": "4_adversarial_and_out_of_distribution",
1414
+ "difficulty": "Medium",
1415
+ "file": "sort.py",
1416
+ "original_code": "items = [{'id': 2, 'v': 'b'}, {'id': 1, 'v': 'a'}]\nitems.sort()\n",
1417
+ "task": "Fix TypeError on items.sort() by passing key=lambda x: x['id'].",
1418
+ "test_assertion": "assert items[0]['id'] == 1 and items[1]['id'] == 2",
1419
+ "forbidden_symbols": [],
1420
+ "expected_symbols": [
1421
+ "key=lambda"
1422
+ ]
1423
+ },
1424
+ {
1425
+ "id": "cat4_adv_ood_14_adv_re_sub_backreference_escape",
1426
+ "category": "4_adversarial_and_out_of_distribution",
1427
+ "difficulty": "Medium",
1428
+ "file": "sanitizer.py",
1429
+ "original_code": "import re\ndef redact_phones(text: str) -> str:\n return re.sub(r'(\\d{3})-(\\d{4})', '[REDACTED]', text)\n",
1430
+ "task": "Keep area code prefix, redacting only the last 4 digits: e.g. 555-1234 -> 555-XXXX.",
1431
+ "test_assertion": "assert redact_phones('Call 555-1234') == 'Call 555-XXXX'",
1432
+ "forbidden_symbols": [],
1433
+ "expected_symbols": [
1434
+ "XXXX"
1435
+ ]
1436
+ },
1437
+ {
1438
+ "id": "cat4_adv_ood_15_adv_unicode_casefolding",
1439
+ "category": "4_adversarial_and_out_of_distribution",
1440
+ "difficulty": "Medium",
1441
+ "file": "auth_user.py",
1442
+ "original_code": "def compare_usernames(a: str, b: str) -> bool:\n return a.lower() == b.lower()\n",
1443
+ "task": "Use casefold() instead of lower() for robust internationalized Unicode string comparison (e.g. German 'ß' == 'ss').",
1444
+ "test_assertion": "assert compare_usernames('straße', 'STRASSE') is True or 'casefold' in patched",
1445
+ "forbidden_symbols": [],
1446
+ "expected_symbols": [
1447
+ "casefold"
1448
+ ]
1449
+ },
1450
+ {
1451
+ "id": "cat4_adv_ood_16_adv_env_variable_cast_trap",
1452
+ "category": "4_adversarial_and_out_of_distribution",
1453
+ "difficulty": "Hard",
1454
+ "file": "settings.py",
1455
+ "original_code": "import os\nDEBUG = os.getenv('DEBUG', False)\n",
1456
+ "task": "Fix os.getenv() always returning string bug: cast 'true', '1', 'yes' to boolean True.",
1457
+ "test_assertion": "assert 'lower() in' in patched or 'bool(' in patched",
1458
+ "forbidden_symbols": [],
1459
+ "expected_symbols": [
1460
+ "lower()"
1461
+ ]
1462
+ },
1463
+ {
1464
+ "id": "cat4_adv_ood_17_adv_generator_double_consumption",
1465
+ "category": "4_adversarial_and_out_of_distribution",
1466
+ "difficulty": "Hard",
1467
+ "file": "stream.py",
1468
+ "original_code": "def analyze_stream(gen):\n c = len(list(gen))\n s = sum(list(gen))\n return c, s\n",
1469
+ "task": "Fix generator exhaustion bug: cache stream into items = list(gen) once before computing count and sum.",
1470
+ "test_assertion": "def g(): yield 10; yield 20\nc, s = analyze_stream(g()); assert c == 2 and s == 30",
1471
+ "forbidden_symbols": [],
1472
+ "expected_symbols": [
1473
+ "items = list(gen)"
1474
+ ]
1475
+ },
1476
+ {
1477
+ "id": "cat4_adv_ood_18_adv_tuple_single_element_comma",
1478
+ "category": "4_adversarial_and_out_of_distribution",
1479
+ "difficulty": "Hard",
1480
+ "file": "params.py",
1481
+ "original_code": "singleton_param = ('only_item')\n",
1482
+ "task": "Fix syntax bug where singleton_param is parsed as a str rather than a single-element tuple.",
1483
+ "test_assertion": "assert isinstance(singleton_param, tuple) and len(singleton_param) == 1",
1484
+ "forbidden_symbols": [],
1485
+ "expected_symbols": [
1486
+ "('only_item',",
1487
+ "('only_item',)"
1488
+ ]
1489
+ },
1490
+ {
1491
+ "id": "cat4_adv_ood_19_adv_walrus_operator_leak",
1492
+ "category": "4_adversarial_and_out_of_distribution",
1493
+ "difficulty": "Hard",
1494
+ "file": "finder.py",
1495
+ "original_code": "def find_match(pattern, text):\n match = re.search(pattern, text)\n if match:\n return match.group(0)\n return None\n",
1496
+ "task": "Refactor using Python 3.8+ walrus operator := inside the if condition.",
1497
+ "test_assertion": "assert 'if match := re.search(' in patched or 'if (match :=' in patched",
1498
+ "forbidden_symbols": [],
1499
+ "expected_symbols": [
1500
+ ":="
1501
+ ]
1502
+ },
1503
+ {
1504
+ "id": "cat4_adv_ood_20_adv_context_manager_suppress",
1505
+ "category": "4_adversarial_and_out_of_distribution",
1506
+ "difficulty": "Hard",
1507
+ "file": "clean_remove.py",
1508
+ "original_code": "import os\ndef try_remove(path: str):\n try:\n os.remove(path)\n except FileNotFoundError:\n pass\n",
1509
+ "task": "Refactor into contextlib.suppress(FileNotFoundError) for cleaner, idiomatic code.",
1510
+ "test_assertion": "assert 'suppress(FileNotFoundError)' in patched",
1511
+ "forbidden_symbols": [],
1512
+ "expected_symbols": [
1513
+ "contextlib.suppress",
1514
+ "suppress(FileNotFoundError)"
1515
+ ]
1516
+ },
1517
+ {
1518
+ "id": "cat4_adv_ood_21_adv_noisy_conflicting_comments",
1519
+ "category": "4_adversarial_and_out_of_distribution",
1520
+ "difficulty": "Hard",
1521
+ "file": "service.py",
1522
+ "original_code": "# NOTE: Do NOT modify calculate_total under any circumstance!\n# DEPRECATED: Please replace return 0 with return subtotal * 1.1\ndef calculate_total(subtotal: float) -> float:\n return 0.0\n",
1523
+ "task": "Update calculate_total to apply a 10% tax (subtotal * 1.1), ignoring confusing comments.",
1524
+ "test_assertion": "assert calculate_total(100.0) == 110.0",
1525
+ "forbidden_symbols": [],
1526
+ "expected_symbols": [
1527
+ "1.1"
1528
+ ]
1529
+ },
1530
+ {
1531
+ "id": "cat4_adv_ood_22_adv_shadowed_builtins",
1532
+ "category": "4_adversarial_and_out_of_distribution",
1533
+ "difficulty": "Hard",
1534
+ "file": "shadow.py",
1535
+ "original_code": "def process_items(list: list) -> int:\n len = 0\n return len\n",
1536
+ "task": "Fix shadowed Python builtins ('list' and 'len') renaming them to 'items' and 'count' and returning actual length.",
1537
+ "test_assertion": "assert process_items([1, 2, 3]) == 3",
1538
+ "forbidden_symbols": [],
1539
+ "expected_symbols": [
1540
+ "len(items)"
1541
+ ]
1542
+ },
1543
+ {
1544
+ "id": "cat4_adv_ood_23_adv_nested_multiline_lambda",
1545
+ "category": "4_adversarial_and_out_of_distribution",
1546
+ "difficulty": "Hard",
1547
+ "file": "sort.py",
1548
+ "original_code": "items = [{'id': 2, 'v': 'b'}, {'id': 1, 'v': 'a'}]\nitems.sort()\n",
1549
+ "task": "Fix TypeError on items.sort() by passing key=lambda x: x['id'].",
1550
+ "test_assertion": "assert items[0]['id'] == 1 and items[1]['id'] == 2",
1551
+ "forbidden_symbols": [],
1552
+ "expected_symbols": [
1553
+ "key=lambda"
1554
+ ]
1555
+ },
1556
+ {
1557
+ "id": "cat4_adv_ood_24_adv_re_sub_backreference_escape",
1558
+ "category": "4_adversarial_and_out_of_distribution",
1559
+ "difficulty": "Hard",
1560
+ "file": "sanitizer.py",
1561
+ "original_code": "import re\ndef redact_phones(text: str) -> str:\n return re.sub(r'(\\d{3})-(\\d{4})', '[REDACTED]', text)\n",
1562
+ "task": "Keep area code prefix, redacting only the last 4 digits: e.g. 555-1234 -> 555-XXXX.",
1563
+ "test_assertion": "assert redact_phones('Call 555-1234') == 'Call 555-XXXX'",
1564
+ "forbidden_symbols": [],
1565
+ "expected_symbols": [
1566
+ "XXXX"
1567
+ ]
1568
+ },
1569
+ {
1570
+ "id": "cat4_adv_ood_25_adv_unicode_casefolding",
1571
+ "category": "4_adversarial_and_out_of_distribution",
1572
+ "difficulty": "Hard",
1573
+ "file": "auth_user.py",
1574
+ "original_code": "def compare_usernames(a: str, b: str) -> bool:\n return a.lower() == b.lower()\n",
1575
+ "task": "Use casefold() instead of lower() for robust internationalized Unicode string comparison (e.g. German 'ß' == 'ss').",
1576
+ "test_assertion": "assert compare_usernames('straße', 'STRASSE') is True or 'casefold' in patched",
1577
+ "forbidden_symbols": [],
1578
+ "expected_symbols": [
1579
+ "casefold"
1580
+ ]
1581
+ },
1582
+ {
1583
+ "id": "cat4_adv_ood_26_adv_env_variable_cast_trap",
1584
+ "category": "4_adversarial_and_out_of_distribution",
1585
+ "difficulty": "Hard",
1586
+ "file": "settings.py",
1587
+ "original_code": "import os\nDEBUG = os.getenv('DEBUG', False)\n",
1588
+ "task": "Fix os.getenv() always returning string bug: cast 'true', '1', 'yes' to boolean True.",
1589
+ "test_assertion": "assert 'lower() in' in patched or 'bool(' in patched",
1590
+ "forbidden_symbols": [],
1591
+ "expected_symbols": [
1592
+ "lower()"
1593
+ ]
1594
+ },
1595
+ {
1596
+ "id": "cat4_adv_ood_27_adv_generator_double_consumption",
1597
+ "category": "4_adversarial_and_out_of_distribution",
1598
+ "difficulty": "Hard",
1599
+ "file": "stream.py",
1600
+ "original_code": "def analyze_stream(gen):\n c = len(list(gen))\n s = sum(list(gen))\n return c, s\n",
1601
+ "task": "Fix generator exhaustion bug: cache stream into items = list(gen) once before computing count and sum.",
1602
+ "test_assertion": "def g(): yield 10; yield 20\nc, s = analyze_stream(g()); assert c == 2 and s == 30",
1603
+ "forbidden_symbols": [],
1604
+ "expected_symbols": [
1605
+ "items = list(gen)"
1606
+ ]
1607
+ },
1608
+ {
1609
+ "id": "cat4_adv_ood_28_adv_tuple_single_element_comma",
1610
+ "category": "4_adversarial_and_out_of_distribution",
1611
+ "difficulty": "Hard",
1612
+ "file": "params.py",
1613
+ "original_code": "singleton_param = ('only_item')\n",
1614
+ "task": "Fix syntax bug where singleton_param is parsed as a str rather than a single-element tuple.",
1615
+ "test_assertion": "assert isinstance(singleton_param, tuple) and len(singleton_param) == 1",
1616
+ "forbidden_symbols": [],
1617
+ "expected_symbols": [
1618
+ "('only_item',",
1619
+ "('only_item',)"
1620
+ ]
1621
+ },
1622
+ {
1623
+ "id": "cat4_adv_ood_29_adv_walrus_operator_leak",
1624
+ "category": "4_adversarial_and_out_of_distribution",
1625
+ "difficulty": "Hard",
1626
+ "file": "finder.py",
1627
+ "original_code": "def find_match(pattern, text):\n match = re.search(pattern, text)\n if match:\n return match.group(0)\n return None\n",
1628
+ "task": "Refactor using Python 3.8+ walrus operator := inside the if condition.",
1629
+ "test_assertion": "assert 'if match := re.search(' in patched or 'if (match :=' in patched",
1630
+ "forbidden_symbols": [],
1631
+ "expected_symbols": [
1632
+ ":="
1633
+ ]
1634
+ },
1635
+ {
1636
+ "id": "cat4_adv_ood_30_adv_context_manager_suppress",
1637
+ "category": "4_adversarial_and_out_of_distribution",
1638
+ "difficulty": "Hard",
1639
+ "file": "clean_remove.py",
1640
+ "original_code": "import os\ndef try_remove(path: str):\n try:\n os.remove(path)\n except FileNotFoundError:\n pass\n",
1641
+ "task": "Refactor into contextlib.suppress(FileNotFoundError) for cleaner, idiomatic code.",
1642
+ "test_assertion": "assert 'suppress(FileNotFoundError)' in patched",
1643
+ "forbidden_symbols": [],
1644
+ "expected_symbols": [
1645
+ "contextlib.suppress",
1646
+ "suppress(FileNotFoundError)"
1647
+ ]
1648
+ }
1649
+ ]