Tutorial¶
Set up a project¶
If the directory has a pyproject.toml, init adds a [tool.konform] section to it
(after the last [tool.ruff…] block if you have one, otherwise at the end, with blank lines around it); otherwise it creates a konform.toml. It also creates a starter
konform_patterns.toml for custom pattern rules. Nothing is changed if
[tool.konform] is already configured.
$ konform init --diff # preview what would be created, write nothing
$ konform init --no-patterns
$ konform init --force # create konform.toml even if pyproject.toml exists
See Configuration for what to put in the generated file.
Lint a project¶
check is the default subcommand, so konform src/ works too.
Fix violations¶
$ konform check --fix src/ # safe fixes
$ konform check --fix --unsafe-fixes src/ # also unsafe fixes (e.g. KIS002)
$ konform check --diff src/ # preview as a unified diff
See Fixes for the safe/unsafe distinction.
Choose rules¶
$ konform check --select KIS src/ # only KIS* rules
$ konform check --extend-select KPT src/ # add KPT* rules on top of config
$ konform check --ignore KIS002 src/
Codes are prefix-matched: KIS selects every KIS* rule.
Explore rules¶
Machine-readable output¶
Verbosity¶
Next steps¶
- Configure konform in
pyproject.toml. - Add custom pattern rules.
- Run it in your editor.