Simple formatter for Kconfig files
Project description
kconfigstyle
A simple linter for Kconfig files, with support for Zephyr and ESP-IDF coding styles.
The "Kconfig language" is defined here:
There's several extensions used in practice by Zephyr + ESP-IDF; both projects maintain their own forks of the original kconfiglib library:
- https://github.com/zephyrproject-rtos/Kconfiglib (actively maintained fork used by Zephyr, original library here)
Espressif has an excellent documentation page here about their fork of Kconfiglib:
Which includes a parser here, however, that is intended to be used on a complete Kconfig setup, not on a per-file basis (i.e. it wants to be able to load in sourced files etc). For the purposes of basic formatting, we only need to parse individual files, so we've implemented our own parser.
Espressif also provides a tool called
kconfcheck
to check Kconfig formatting, but it is not very configurable and does not
support auto-formatting. kconfigstyle aims to provide a more flexible and
user-friendly alternative.
Finally, see here for references on Zephyr and ESP-IDF Kconfig styles:
- https://docs.zephyrproject.org/latest/contribute/style/kconfig.html
- https://docs.espressif.com/projects/esp-idf-kconfig/en/latest/kconfcheck/index.html#kconfig-format-rules
Installation
Run without installing with uv:
uvx kconfigstyle [options] <kconfig_files>
Or install and run:
pip install kconfigstyle
kconfigstyle [options] <kconfig_files>
Command Line Options
See kconfigstyle --help for a full list of options. Some notable options
include:
-
--preset {zephyr,espidf}Use a style preset (individual options override preset values) -
--write, -wWrite formatted output back to files (format mode) -
--use-spacesUse spaces instead of tabs for indentation -
--primary-indent PRIMARY_INDENTNumber of spaces for primary indentation (default: 4) -
--help-indent HELP_INDENTNumber of extra spaces for help text indentation (default: 2) -
--max-line-length MAX_LINE_LENGTHMaximum line length (default: 100 for Zephyr, 120 for ESP-IDF) -
--max-option-length MAX_OPTION_LENGTHMaximum config option name length (default: 50) -
--uppercase-configsRequire config names to be uppercase -
--min-prefix-length MIN_PREFIX_LENGTHMinimum prefix length for config names (default: 3 for ESP-IDF) -
--indent-sub-itemsUse hierarchical indentation for sub-items (ESP-IDF style) -
--consolidate-empty-linesConsolidate multiple consecutive empty lines into one -
--reflow-helpReflow help text to fit within max line length
License
See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kconfigstyle-0.6.1.tar.gz.
File metadata
- Download URL: kconfigstyle-0.6.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15e786119add469a023dc79d59963f7cbe3f7f3f4975ca69a84bea201bd4db34
|
|
| MD5 |
84e915b5845957db6d0b4404524d2ef0
|
|
| BLAKE2b-256 |
858445a825598a767dbba0b65cf94ba524027df3dd71110569acd632ccfbdbf0
|
File details
Details for the file kconfigstyle-0.6.1-py3-none-any.whl.
File metadata
- Download URL: kconfigstyle-0.6.1-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d41b49e9f5c1744d0907e8b01cb87c18a1535897b646cd11fbb01104a3e7037
|
|
| MD5 |
fe7a7c685ce636e6b2f3abe870603eae
|
|
| BLAKE2b-256 |
cac64dba27faedce5073102fb413434212b5396a3c5e690765084856576bea49
|