Skip to content

Clean

invoke_tasklib.clean

Cleanup tasks (clean.*).

The tasks remove generated files: build outputs, caches, coverage reports, the built documentation and the __pycache__ directories. A task stays inside the project, keeps what git tracks, and has a --dry- run option that lists what it would remove.

invoke_tasklib.clean.NAMESPACE module-attribute

NAMESPACE = 'clean'

The name of the namespace of the tasks of this module.

invoke_tasklib.clean.all_

all_(c: Context, *, dry_run: bool = False) -> None

Remove build artifacts and caches.

The removed paths are dist, build, __pycache__, .pytest_cache, .coverage, etc., and the HTML coverage report and the coverage files, from where they are written: the argument of tasklib.test.cov_reports (html:cov_html, xml:cov.xml), else the options of [tool.coverage.*] in pyproject.toml, else htmlcov and coverage.xml. The site directory is only removed if the project has a MkDocs config file, because that is what produces it: the site_dir of paths.docs_config (relative to the config file, docs/site by default), or site if the config is not valid. The *.egg-info directories are removed at the root and in src.

A directory outside the project, for example an absolute site_dir, is never removed.

A top-level directory (build, dist, site, ...) that contains files tracked by git is kept, and the task says so. So is a coverage file (.coverage, coverage.xml, ...) that git tracks.

Parameters:

Name Type Description Default
c Context

The invoke context.

required
dry_run bool

If True, print the paths that would be removed and remove nothing.

False

invoke_tasklib.clean.pycache

pycache(c: Context, *, dry_run: bool = False) -> None

Remove all pycache directories.

Parameters:

Name Type Description Default
c Context

The invoke context.

required
dry_run bool

If True, print the paths that would be removed and remove nothing.

False