The editorconfig-core-py library provides a Python implementation for locating and interpreting `.editorconfig` files. It allows applications to retrieve editor configuration properties (like indentation style, tab width, and line endings) for a given file path, ensuring consistent coding styles across different editors and IDEs. The current version is 0.17.1, with releases typically tied to core EditorConfig specification updates or Python compatibility.
pip install editorconfigVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `editorconfig.get_properties()` to retrieve configuration for different file types. It creates a temporary `.editorconfig` file and two test files, then prints the resolved properties. Remember to clean up temporary files in production code or use temporary file utilities.
Ensure your project runs on Python 3.9+ and install `editorconfig` version 0.15.0 or higher.
Explicitly cast property values to the desired type (e.g., `int(properties['indent_size'])` or `properties['trim_trailing_whitespace'] == 'true'`) when consuming them.
Familiarize yourself with the official EditorConfig specification, especially regarding file resolution, inheritance, and the `root = true` property, to correctly predict configurations.
Always provide `editorconfig.get_properties()` with an absolute path to the target file. You can use `os.path.abspath()` or `pathlib.Path.resolve()` to ensure the path is absolute.
Ensure the path provided to `editorconfig.get_properties` is an absolute path (e.g., by using `os.path.abspath()` or `pathlib.Path.resolve()`).
No dependency data recorded yet.