codereader 0.7.1__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codereader
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: Local code readability grader using LLMs
5
5
  License: GPLv3
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codereader"
3
- version = "0.7.1"
3
+ version = "0.7.2"
4
4
  description = "Local code readability grader using LLMs"
5
5
  authors = [
6
6
  {name = "Jason Liu",email = "Liujason2003@gmail.com"}
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import asyncio
4
4
  import json
5
5
  import re
6
+ import os
6
7
 
7
8
  from dataclasses import dataclass
8
9
  from typing import Any, Dict, List, Optional, Protocol
@@ -89,13 +90,15 @@ async def run_subprocess(
89
90
  loop = asyncio.get_running_loop()
90
91
  start = loop.time()
91
92
 
93
+ clean_env = {**os.environ, "TERM": "dumb", "NO_COLOR": "1", **(env or {})}
94
+
92
95
  try:
93
96
  proc = await asyncio.create_subprocess_exec(
94
97
  *cmd,
95
98
  stdin=asyncio.subprocess.PIPE if stdin_text is not None else None,
96
99
  stdout=asyncio.subprocess.PIPE,
97
100
  stderr=asyncio.subprocess.PIPE,
98
- env=env,
101
+ env=clean_env,
99
102
  )
100
103
  except FileNotFoundError as e:
101
104
  dur = loop.time() - start
@@ -184,6 +187,16 @@ def _try_parse_from(text: str, start: int) -> Optional[Dict[str, Any]]:
184
187
  return None
185
188
 
186
189
 
190
+ def clean_output(text: str):
191
+ text = re.sub(r"\x1b\[[0-9;]*[A-Za-z]", "", text)
192
+
193
+ text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL)
194
+
195
+ text = re.sub(r"Thinking\.\.\..*?\.\.\.done thinking\.", "", text, flags=re.DOTALL)
196
+
197
+ return text
198
+
199
+
187
200
  def extract_json_object(text: str) -> Optional[Dict[str, Any]]:
188
201
  """
189
202
  Robustly extract the first valid JSON object from model output.
@@ -199,9 +212,7 @@ def extract_json_object(text: str) -> Optional[Dict[str, Any]]:
199
212
  - Nested objects: {"subscores": {"a": 1}}
200
213
  """
201
214
 
202
- text = re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL)
203
-
204
- text = re.sub(r"Thinking\.\.\..*?\.\.\.done thinking\.", "", text, flags=re.DOTALL)
215
+ text = clean_output(text)
205
216
 
206
217
  fenced = re.search(r"```(?:json)?\s*(\{.*?\})\s*```", text, re.DOTALL)
207
218
  if fenced:
File without changes
File without changes