File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 9
9
- setuptools >= 39.1.0
10
10
"""
11
11
12
+ import os
12
13
import pathlib
14
+ import shutil
13
15
14
16
import invoke
15
17
38
40
TASK_ROOT_STR = str (TASK_ROOT )
39
41
40
42
43
+ # shared function
44
+ def rmrf (items , verbose = True ):
45
+ """Silently remove a list of directories or files"""
46
+ if isinstance (items , str ):
47
+ items = [items ]
48
+
49
+ for item in items :
50
+ if verbose :
51
+ print ("Removing {}" .format (item ))
52
+ shutil .rmtree (item , ignore_errors = True )
53
+ # rmtree doesn't remove bare files
54
+ try :
55
+ os .remove (item )
56
+ except FileNotFoundError :
57
+ pass
58
+
59
+
41
60
@invoke .task (pre = [ext_test_tasks .pytest ])
42
61
@invoke .task ()
43
62
def pytest (_ ):
@@ -154,3 +173,14 @@ def format(context):
154
173
155
174
156
175
namespace .add_task (format )
176
+
177
+
178
+ @invoke .task ()
179
+ def ruff_clean (context ):
180
+ """Remove .ruff_cache directory"""
181
+ with context .cd (TASK_ROOT_STR ):
182
+ dirs = ['.ruff_cache' ]
183
+ rmrf (dirs )
184
+
185
+
186
+ namespace_clean .add_task (ruff_clean , 'ruff' )
You can’t perform that action at this time.
0 commit comments