mbudisic commited on
Commit
14bfdc4
Β·
1 Parent(s): 34948cf

code: switch TODO.md extraction to ruff, update script and output

Browse files
Files changed (3) hide show
  1. TODO.md +5 -1
  2. app.py +2 -0
  3. generate_todo_md.py +68 -0
TODO.md CHANGED
@@ -1,3 +1,7 @@
1
  # πŸ“ TODOs in Codebase
2
 
3
- No TODOs found! πŸŽ‰
 
 
 
 
 
1
  # πŸ“ TODOs in Codebase
2
 
3
+ - `app.py:251`: TD001 Invalid TODO tag: `FIXME`
4
+ - `app.py:251`: TD002 Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...`
5
+ - `app.py:251`: TD003 Missing issue link for this TODO
6
+ - `app.py:254`: TD002 Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...`
7
+ - `app.py:254`: TD003 Missing issue link for this TODO
app.py CHANGED
@@ -248,6 +248,8 @@ class ChainlitCallbackHandler(BaseCallbackHandler):
248
 
249
  import time
250
 
 
 
251
 
252
  @cl.on_message
253
  async def main(input_message: cl.Message):
 
248
 
249
  import time
250
 
251
+ # FIXME Clean up imports.
252
+
253
 
254
  @cl.on_message
255
  async def main(input_message: cl.Message):
generate_todo_md.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Script to generate TODO.md by parsing all TODO-style comments using ruff.
4
+ Run with: uv run python generate_todo_md.py
5
+ """
6
+ import subprocess
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ REPO_ROOT = Path(__file__).parent.resolve()
11
+ TODO_MD_PATH = REPO_ROOT / "TODO.md"
12
+
13
+
14
+ def run_ruff_todos():
15
+ """Run ruff to find TODO/FIXME comments in all .py files."""
16
+ try:
17
+ result = subprocess.run(
18
+ [
19
+ sys.executable,
20
+ "-m",
21
+ "ruff",
22
+ "check",
23
+ "--select=TD",
24
+ str(REPO_ROOT),
25
+ ],
26
+ capture_output=True,
27
+ text=True,
28
+ check=False,
29
+ )
30
+ return result.stdout.strip()
31
+ except Exception as e:
32
+ print(f"Error running ruff: {e}")
33
+ sys.exit(1)
34
+
35
+
36
+ def parse_ruff_output(output):
37
+ """Parse ruff output into a list of TODOs."""
38
+ todos = []
39
+ for line in output.splitlines():
40
+ # Example: app.py:251:1: TD001 TODO: ...
41
+ parts = line.split(":", 3)
42
+ if len(parts) == 4:
43
+ file_path, line_no, col_no, rest = parts
44
+ rest = rest.strip()
45
+ if rest.startswith("TD"): # e.g. TD001 TODO: ...
46
+ todos.append((file_path.strip(), line_no.strip(), rest))
47
+ return todos
48
+
49
+
50
+ def write_todo_md(todos):
51
+ with open(TODO_MD_PATH, "w", encoding="utf-8") as f:
52
+ f.write("# πŸ“ TODOs in Codebase\n\n")
53
+ if not todos:
54
+ f.write("No TODOs found! πŸŽ‰\n")
55
+ return
56
+ for file_path, line_no, rest in todos:
57
+ f.write(f"- `{file_path}:{line_no}`: {rest}\n")
58
+
59
+
60
+ def main():
61
+ output = run_ruff_todos()
62
+ todos = parse_ruff_output(output)
63
+ write_todo_md(todos)
64
+ print(f"Wrote {len(todos)} TODOs to {TODO_MD_PATH}")
65
+
66
+
67
+ if __name__ == "__main__":
68
+ main()