File size: 762 Bytes
a5c9fd4
 
 
 
50a0917
 
 
 
a5c9fd4
 
b56681c
 
a5c9fd4
b56681c
a5c9fd4
b56681c
4a63c86
a5c9fd4
 
 
 
 
 
50a0917
 
a5c9fd4
 
 
50a0917
a5c9fd4
50a0917
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from typing import Dict
import ast


MIN_TASK_SCORE = 0.01
MAX_TASK_SCORE = 0.99


def get_task() -> Dict:
    return {
        "id": "easy",
        "difficulty": "easy",
        "name": "lint_fix",
        "objective": "Fix syntax errors so the candidate code parses successfully.",
        "description": "Fix syntax errors in the given Python code.",
        "grader_name": "grade",
        "score_range": [MIN_TASK_SCORE, MAX_TASK_SCORE],
    }


def grade(candidate_code: str) -> float:
    """
    Deterministic grader:
    - Returns a strict in-range score for valid parse/syntax error
    - Output is always in (0, 1)
    """
    try:
        ast.parse(candidate_code)
        return MAX_TASK_SCORE
    except SyntaxError:
        return MIN_TASK_SCORE