Skip to main content

✨ kconfigstyle

A simple style linter + formatter for Kconfig files, with support for Zephyr and ESP-IDF style conventions.

Example:

❯ uvx kconfigstyle --write --reflow-help --consolidate-empty-lines --max-line-length 80 Kconfig

Before:

# incorrect and inconsistent indentation, spare newline, and unwrapped help text
config MY_OPTION
  bool "Enable my option" if ANOTHER_OPTION


    help
      Extra long bit of help text that should be reflowed to fit within the maximum line length specified by the style guide.

      This is the second line of the help text.

After:

# properly indented, consolidated newlines, and wrapped help text
config MY_OPTION
	bool "Enable my option" if ANOTHER_OPTION

	help
	  Extra long bit of help text that should be reflowed to fit within the
	  maximum line length specified by the style guide.

	  This is the second line of the help text.

Background

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:

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, it's only necessary to parse individual files, so I've implemented a standalone parser for this use case.

Espressif also provides a tool called kconfcheck to check Kconfig syntax/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:

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, -w Write formatted output back to files (format mode)

  • --use-spaces Use spaces instead of tabs for indentation

  • --primary-indent PRIMARY_INDENT Number of spaces for primary indentation (default: 4), only applies when --use-spaces is set

  • --help-indent HELP_INDENT Number of extra spaces for help text indentation (default: 2)

  • --max-line-length MAX_LINE_LENGTH Maximum line length (default: 100 for Zephyr, 120 for ESP-IDF)

  • --max-option-length MAX_OPTION_LENGTH Maximum config option name length (default: 50)

  • --uppercase-configs Require config names to be uppercase

  • --min-prefix-length MIN_PREFIX_LENGTH Minimum prefix length for config names (default: 3 for ESP-IDF)

  • --indent-sub-items Use hierarchical indentation for sub-items (ESP-IDF style)

  • --consolidate-empty-lines Consolidate multiple consecutive empty lines into one

  • --reflow-help Reflow help text to fit within max line length

License

See LICENSE file for details.

Metadata

Release files for kconfigstyle 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kconfigstyle 0.6.3
File Size Uploaded
kconfigstyle-0.6.3.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kconfigstyle 0.6.3
File Interpreter ABI Platform
kconfigstyle-0.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 31.5 kB

Release files / kconfigstyle-0.6.3.tar.gz

Download URL kconfigstyle-0.6.3.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
61fb4131713955156ea5fbfc89e59817aa9c4256ebe117c80fe071af55ca9851
BLAKE2b-256 checksum
How to use checksums
66c439252c9131b01fc5bbab19e1599d1de5b9e2cf9129ff52fe22cf6fdba2ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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}

Release files / kconfigstyle-0.6.3-py3-none-any.whl

Download URL kconfigstyle-0.6.3-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d2951069544eaa3dc46ed31ef849fff2104226e890c09a7998bb91fdc8d3678
BLAKE2b-256 checksum
How to use checksums
44d164f1e0524859094c2da9d2c5c6a02a39b0917d769da9ea875487a07f8767
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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}

Release history Release notifications | RSS feed

This release

0.6.3 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page