efficient, readable code Manual project review is time-consuming and error-prone Many courses face these challenges: Data structures Algorithm analysis Software engineering Existing tools focus on style, not semantic structure Regex is brittle, and AST tools are hard to prototype Project Goal: Chasten enables scalable and structure-aware feedback that effectively supports both instructors and students PyCon Education Summit 2025
acceptable 1 seen = set() 2 for item in items: 3 if item in seen: 4 return True 5 seen.add(item) 6 # O(n²) is not okay 1 for i in range(len(items)): 2 for j in range(len(items)): 3 if i != j 4 and items[i] == items[j]: 5 return True 6 Goal: Automatically scan the source code that students submit to confirm that there are no inefficient looping constructs Challenge: Linters like Ruff and Pylint don’t have rules to detect nested control structures that either are or are not acceptable Build: An extensible tool allowing instructors to scan for arbitrary code patterns without detailed AST knowledge PyCon Education Summit 2025
Rules written in simple YAML Structure-first, not just style Outputs to JSON, CSV, or SQLite Result: Instructors define checks once and use Chasten to easily apply them at scale across all student submissions - name: "nested-loops" 1 code: "PERF001" 2 pattern: "//For[descendant::For]" 3 description: "Detects doubly nested for-loops (e.g., O(n²))" 4 PyCon Education Summit 2025
Name File Matches PERF001 nested-loops analyze.py 1 PERF001 nested-loops display.py 7 PERF001 nested-loops main.py 0 Check ID → A unique short rule code (e.g., PERF001) Check Name → The rule name that matched (e.g., nested-loops) File → The Python file that the tool scanned (e.g., analyze.py) Matches → Number of times the pattern was detected in that file (e.g., 1 match) PyCon Education Summit 2025
handle style, formatting, or type inference Not optimized for fast use in continuous integration Pattern matches through use of XPath on Python’s AST Empirical Study of Chasten Frequency of false positives or false negatives? How do students respond to the tool’s feedback? Differences in scores with varied feedback types? PyCon Education Summit 2025
on bespoke code structure patterns in Python Automated grading aligned with learning outcomes Generate data-rich insights into student code patterns Try out Chasten and contribute to its development! GitHub: PyPI: https://github.com/AstuteSource/chasten https://pypi.org/project/chasten/ PyCon Education Summit 2025