{ "tasks": [ { "id": "train_str_normalize_strip_bug", "split": "train", "title": "String normalization: missing strip", "instruction": "The normalize_string function does not remove leading and trailing whitespace. It should return a lowercase, whitespace-trimmed string.", "files": { "utils/string_utils.py": "def normalize_string(s):\n return s.lower()", "tests/test_string_utils.py": "from utils.string_utils import normalize_string\n\ndef test_normalize_string():\n assert normalize_string(' Test ') == 'test'\n assert normalize_string('\\tTabbed\\n') == 'tabbed'\n" }, "checks": [ { "type": "contains", "path": "utils/string_utils.py", "text": ".strip()" }, { "type": "regex", "path": "utils/string_utils.py", "pattern": "return\\s+s\\.lower\\(\\)\\.strip\\(\\)" } ], "failure_messages": [ "normalize_string did not remove whitespace", "normalize_string does not use both lower and strip" ], "canonical_solution": "Call strip() after lower() in normalize_string." }, { "id": "train_slugify_spaces_to_hyphen", "split": "train", "title": "Slugify: spaces not replaced with hyphens", "instruction": "The slugify function does not replace spaces with hyphens. It should return a lowercase, hyphen-separated string with no spaces.", "files": { "core/slug.py": "def slugify(text):\n return text.lower()", "tests/test_slug.py": "from core.slug import slugify\n\ndef test_slugify():\n assert slugify('Hello World') == 'hello-world'\n assert slugify('Python Slug') == 'python-slug'\n" }, "checks": [ { "type": "contains", "path": "core/slug.py", "text": ".replace(' ', '-')" }, { "type": "regex", "path": "core/slug.py", "pattern": "return\\s+text\\.lower\\(\\)\\.replace\\(' ', '- '\\)" } ], "failure_messages": [ "slugify did not convert spaces to hyphens", "slugify does not replace spaces using .replace" ], "canonical_solution": "Add .replace(' ', '-') after lower() in slugify." }, { "id": "train_label_parse_extra_whitespace", "split": "train", "title": "Label parser: extra whitespace not handled", "instruction": "The parse_labels function splits labels by comma but does not strip whitespace from each label. It should return a list of trimmed labels.", "files": { "label_parser.py": "def parse_labels(s):\n return s.split(',')", "tests/test_label_parser.py": "from label_parser import parse_labels\n\ndef test_parse_labels():\n assert parse_labels('a, b, c') == ['a', 'b', 'c']\n assert parse_labels('foo,bar') == ['foo', 'bar']\n" }, "checks": [ { "type": "contains", "path": "label_parser.py", "text": "label.strip()" }, { "type": "regex", "path": "label_parser.py", "pattern": "\\[label\\.strip\\(\\)\\s*for\\s*label\\s*in\\s*s\\.split\\(" } ], "failure_messages": [ "parse_labels returned labels with spaces", "parse_labels does not strip whitespace from labels" ], "canonical_solution": "Use a list comprehension to strip whitespace from each split label." }, { "id": "train_logging_missing_logger_name", "split": "train", "title": "Logging: missing logger name", "instruction": "The get_logger function creates a logger but does not set its name as the argument. Returned loggers have the default root logger name instead of the module name.", "files": { "logging_utils.py": "import logging\n\ndef get_logger(name):\n logger = logging.getLogger()\n return logger", "tests/test_logging_utils.py": "from logging_utils import get_logger\n\ndef test_get_logger():\n logger = get_logger('my_mod')\n assert logger.name == 'my_mod'\n" }, "checks": [ { "type": "contains", "path": "logging_utils.py", "text": "logging.getLogger(name)" }, { "type": "not_contains", "path": "logging_utils.py", "text": "logging.getLogger()" } ], "failure_messages": [ "get_logger did not set the logger name", "get_logger should not use getLogger() without arguments" ], "canonical_solution": "Pass the name to logging.getLogger in get_logger." }, { "id": "train_metric_name_dot_instead_of_underscore", "split": "train", "title": "Metric name: uses dot instead of underscore", "instruction": "The format_metric_name function joins metric parts with a dot. It should join them with an underscore instead.", "files": { "metrics/naming.py": "def format_metric_name(*args):\n return '.'.join(args)", "tests/test_naming.py": "from metrics.naming import format_metric_name\n\ndef test_metric_name():\n assert format_metric_name('accuracy', 'top1') == 'accuracy_top1'\n assert format_metric_name('loss', 'test') == 'loss_test'\n" }, "checks": [ { "type": "contains", "path": "metrics/naming.py", "text": "'_'" }, { "type": "regex", "path": "metrics/naming.py", "pattern": "return\\s*'_'.join\\(" } ], "failure_messages": [ "format_metric_name did not use underscore", "format_metric_name does not join with '_'" ], "canonical_solution": "Change the join separator from '.' to '_' in format_metric_name." }, { "id": "train_score_parser_non_int_bug", "split": "train", "title": "Score parser: does not handle non-integer input", "instruction": "The parse_score function crashes when the input is not a valid integer string. It should return None if parsing fails.", "files": { "core/score_parser.py": "def parse_score(s):\n return int(s)", "tests/test_score_parser.py": "from core.score_parser import parse_score\n\ndef test_parse_score():\n assert parse_score('3') == 3\n assert parse_score('abc') is None\n" }, "checks": [ { "type": "contains", "path": "core/score_parser.py", "text": "try:" }, { "type": "contains", "path": "core/score_parser.py", "text": "except" }, { "type": "regex", "path": "core/score_parser.py", "pattern": "return\\s+None" } ], "failure_messages": [ "parse_score crashed for non-integer input", "parse_score does not handle ValueError", "parse_score did not return None for bad input" ], "canonical_solution": "Wrap int(s) in try/except and return None if ValueError is raised." }, { "id": "eval_pathlib_write_missing_parents", "split": "eval", "title": "Pathlib file write: parent directories not created", "instruction": "The write_to_file function writes a file using Path, but fails if the parent directory does not exist. It should create missing directories before writing.", "files": { "fs/write.py": "from pathlib import Path\n\ndef write_to_file(path, data):\n p = Path(path)\n p.write_text(data)", "tests/test_write.py": "from fs.write import write_to_file\nimport tempfile\nimport os\n\ndef test_write_to_file():\n with tempfile.TemporaryDirectory() as d:\n f = os.path.join(d, 'a/b/c.txt')\n write_to_file(f, 'hello')\n assert open(f).read() == 'hello'\n" }, "checks": [ { "type": "contains", "path": "fs/write.py", "text": "p.parent.mkdir" }, { "type": "contains", "path": "fs/write.py", "text": "exist_ok=True" }, { "type": "contains", "path": "fs/write.py", "text": "parents=True" } ], "failure_messages": [ "write_to_file did not create parent directories", "write_to_file did not use exist_ok=True", "write_to_file did not set parents=True" ], "canonical_solution": "Call p.parent.mkdir(parents=True, exist_ok=True) before writing the file." }, { "id": "train_js_package_script_node_typo", "split": "train", "title": "JS package script: node command typo", "instruction": "The run.js script is referenced in package.json scripts with a typo 'nod' instead of 'node'. It should use 'node'.", "files": { "package.json": "{\n \"scripts\": {\n \"start\": \"nod run.js\"\n }\n}", "run.js": "console.log('Hello');", "tests/test_script.py": "import json\n\npkg = json.load(open('package.json'))\nassert pkg['scripts']['start'].startswith('node ')" }, "checks": [ { "type": "contains", "path": "package.json", "text": "\"start\": \"node" }, { "type": "not_contains", "path": "package.json", "text": "nod " } ], "failure_messages": [ "Start script does not use 'node'", "Start script should not contain 'nod '" ], "canonical_solution": "Fix the script from 'nod run.js' to 'node run.js' in package.json." } ] }