Skip to content

Commit

Permalink
Use the "ruff clean" command to clear all ruff cache dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
tleonhardt committed Nov 2, 2024
1 parent 4dca320 commit a00b6cc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
30 changes: 0 additions & 30 deletions plugins/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
- setuptools >= 39.1.0
"""

import os
import pathlib
import shutil

import invoke

Expand Down Expand Up @@ -40,23 +38,6 @@
TASK_ROOT_STR = str(TASK_ROOT)


# shared function
def rmrf(items, verbose=True):
"""Silently remove a list of directories or files"""
if isinstance(items, str):
items = [items]

for item in items:
if verbose:
print("Removing {}".format(item))
shutil.rmtree(item, ignore_errors=True)
# rmtree doesn't remove bare files
try:
os.remove(item)
except FileNotFoundError:
pass


@invoke.task(pre=[ext_test_tasks.pytest])
@invoke.task()
def pytest(_):
Expand Down Expand Up @@ -173,14 +154,3 @@ def format(context):


namespace.add_task(format)


@invoke.task()
def ruff_clean(context):
"""Remove .ruff_cache directory"""
with context.cd(TASK_ROOT_STR):
dirs = ['.ruff_cache']
rmrf(dirs)


namespace_clean.add_task(ruff_clean, 'ruff')
3 changes: 1 addition & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ def format(context):
def ruff_clean(context):
"""Remove .ruff_cache directory"""
with context.cd(TASK_ROOT_STR):
dirs = ['.ruff_cache']
rmrf(dirs)
context.run("ruff clean")


namespace_clean.add_task(ruff_clean, 'ruff')

0 comments on commit a00b6cc

Please sign in to comment.