9785d24172a8cc558e90dd266e37ef5ffa29aa80

Author
Michael <michael-k@users.noreply.github.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

python: fix and extend pyclean (#7762)

Deleting `.mypy_cache` did not work, because the directories were not
empty.  They contain JSON files instead of compiled byte-code.

This extends the cleanup by also getting rid of `.pytest_cache`
directories.

Diff

 1diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh
 2index 950b0e01aea4b5c31e065a4718f1f484d9863d1d..f39cd80b7a86e5e257821582b4289e456682d7bc 100644
 3--- a/plugins/python/python.plugin.zsh
 4+++ b/plugins/python/python.plugin.zsh
 5@@ -1,13 +1,14 @@
 6 # Find python file
 7 alias pyfind='find . -name "*.py"'
 8 
 9-# Remove python compiled byte-code and mypy cache in either current directory or in a
10-# list of specified directories
11+# Remove python compiled byte-code and mypy/pytest cache in either the current
12+# directory or in a list of specified directories (including sub directories).
13 function pyclean() {
14     ZSH_PYCLEAN_PLACES=${*:-'.'}
15     find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
16     find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
17-    find ${ZSH_PYCLEAN_PLACES} -type d -name ".mypy_cache" -delete
18+    find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".mypy_cache" -exec rm -r "{}" +
19+    find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
20 }
21 
22 # Grep among .py files