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 99 - setuptools >= 39.1.0
1010"""
1111
12+ import os
1213import pathlib
14+ import shutil
1315
1416import invoke
1517
3840TASK_ROOT_STR = str (TASK_ROOT )
3941
4042
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+
4160@invoke .task (pre = [ext_test_tasks .pytest ])
4261@invoke .task ()
4362def pytest (_ ):
@@ -154,3 +173,14 @@ def format(context):
154173
155174
156175namespace .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