Run Ruff to get lint feedback for the python project. If async_run is True, run Ruff in the background and return the handler. Otherwise, run Ruff synchronously and return the output as string.
(project_path: str, async_run: bool = False)
| 184 | |
| 185 | |
| 186 | def get_python_feedback(project_path: str, async_run: bool = False): |
| 187 | """Run Ruff to get lint feedback for the python project. |
| 188 | If async_run is True, run Ruff in the background and return the handler. |
| 189 | Otherwise, run Ruff synchronously and return the output as string. |
| 190 | """ |
| 191 | # Disable the current python virtual environment |
| 192 | clean_env = os.environ.copy() |
| 193 | clean_env.pop("VIRTUAL_ENV", None) |
| 194 | clean_env["UV_CACHE_DIR"] = "/tmp/uv_cache" |
| 195 | # sed "s|$(pwd)/||" is used to replace the absolute path with a relative one |
| 196 | if async_run: |
| 197 | handler = subprocess.Popen( |
| 198 | 'uv run pyright . | sed "s|$(pwd)/||"', |
| 199 | text=True, |
| 200 | stdout=subprocess.PIPE, |
| 201 | stderr=subprocess.STDOUT, |
| 202 | cwd=project_path, |
| 203 | shell=True, |
| 204 | env=clean_env, |
| 205 | ) |
| 206 | return handler |
| 207 | else: |
| 208 | lint_output = subprocess.run( |
| 209 | 'uv run pyright . | sed "s|$(pwd)/||"', |
| 210 | check=True, |
| 211 | text=True, |
| 212 | capture_output=True, |
| 213 | cwd=project_path, |
| 214 | shell=True, |
| 215 | env=clean_env, |
| 216 | ).stdout |
| 217 | return lint_output |
no outgoing calls
no test coverage detected