Delete build artifacts and cache files. ```bash make clean ``` This command simply deletes build artifacts and cache files and folders such as `build/`, `.cache/`, etc.. The virtual environments (`.venv` and `.venvs/*`) are not removed by this command.
()
| 239 | |
| 240 | @_command("clean") |
| 241 | def clean() -> None: |
| 242 | """Delete build artifacts and cache files. |
| 243 | |
| 244 | ```bash |
| 245 | make clean |
| 246 | ``` |
| 247 | |
| 248 | This command simply deletes build artifacts and cache files and folders |
| 249 | such as `build/`, `.cache/`, etc.. The virtual environments (`.venv` and `.venvs/*`) |
| 250 | are not removed by this command. |
| 251 | """ |
| 252 | paths_to_clean = ["build", "dist", "htmlcov", "site", ".coverage*", ".pdm-build"] |
| 253 | for path in paths_to_clean: |
| 254 | _shell(f"rm -rf {path}") |
| 255 | |
| 256 | cache_dirs = {".cache", ".pytest_cache", ".ruff_cache", "__pycache__"} |
| 257 | for dirpath in Path().rglob("*/"): |
| 258 | if dirpath.parts[0] not in (".venv", ".venvs") and dirpath.name in cache_dirs: |
| 259 | shutil.rmtree(dirpath, ignore_errors=True) |
| 260 | |
| 261 | |
| 262 | @_command("vscode") |