Skip to content

Lint

📖 This page describes the invoke_tasklib.lint module.

Overview

Task Behavior
lint.check-python Checks code linting with ruff (read-only)
lint.fix-python Fixes auto-fixable linting issues in place with ruff
lint.check-spelling Checks the spelling with codespell (read-only)
lint.pre-commit Runs all the pre-commit hooks on all the files

Usage

invoke lint.check-python

This runs ruff check .. In GitHub Actions (GITHUB_ACTIONS=true) it adds --output-format=github, so ruff annotates violations directly on the diff; locally the readable default output is used. Pass --output-format to choose the format explicitly:

invoke lint.check-python --output-format=concise
invoke lint.fix-python

This runs ruff check --fix ., which rewrites files in place for every auto-fixable violation. Not every lint rule is auto-fixable, so lint.check-python may still report violations afterwards that need a manual fix.

Warning

lint.fix-python modifies files in place. Commit your work before running it.

Spelling and Pre-commit Hooks

invoke lint.check-spelling

This runs codespell . (the configuration is read from pyproject.toml). --args and --paths work as for the other tasks.

invoke lint.pre-commit

This runs pre-commit run --all-files. Pass --args to select a hook, e.g. --args ruff-format. The hooks may modify files.

See Also