Registry / devops / editorconfig

editorconfig

JSON →
library0.17.1pypypi✓ verified 26d ago

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 editorconfig
INSTALL
IMPORT
SIG · EDITORCONFIG
E
editorconfig
devopspythonv0.17.1
Install
1.6s avg
Import
22ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.17.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.024s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.020s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_properties
from editorconfig import get_properties
import editorconfig

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.

import os import editorconfig # Create a dummy .editorconfig file and a test file for demonstration temp_dir = "temp_editorconfig_test" os.makedirs(temp_dir, exist_ok=True) editorconfig_path = os.path.join(temp_dir, ".editorconfig") with open(editorconfig_path, "w") as f: f.write("[*.py]\nindent_style = space\nindent_size = 4\nend_of_line = lf\n\n[*.md]\ntrim_trailing_whitespace = true\n") test_file_path_py = os.path.join(temp_dir, "my_module.py") with open(test_file_path_py, "w") as f: f.write("# Dummy Python file content") test_file_path_md = os.path.join(temp_dir, "README.md") with open(test_file_path_md, "w") as f: f.write("# Dummy Markdown content") try: properties_py = editorconfig.get_properties(test_file_path_py) print(f"EditorConfig properties for {test_file_path_py}:") for key, value in properties_py.items(): print(f" {key}: {value}") print("\n---\n") properties_md = editorconfig.get_properties(test_file_path_md) print(f"EditorConfig properties for {test_file_path_md}:") for key, value in properties_md.items(): print(f" {key}: {value}") finally: # Clean up dummy files and directory os.remove(editorconfig_path) os.remove(test_file_path_py) os.remove(test_file_path_md) os.rmdir(temp_dir)
editorconfig --version
Debug
Known issues
breakingPython 2 support was dropped in version 0.15.0. This library now requires Python 3.9 or newer.
fix
Ensure your project runs on Python 3.9+ and install `editorconfig` version 0.15.0 or higher.
affects: <0.15.0
gotchaAll property values returned by `get_properties` are strings, even for properties that represent numbers (e.g., `indent_size`) or booleans (e.g., `trim_trailing_whitespace`).
fix
Explicitly cast property values to the desired type (e.g., `int(properties['indent_size'])` or `properties['trim_trailing_whitespace'] == 'true'`) when consuming them.
affects: all
gotchaThe library correctly implements the EditorConfig specification for resolving properties, which means properties are determined by the closest `.editorconfig` file to the target path. Misunderstanding how file resolution works (e.g., the effect of `root = true` stopping the search) can lead to unexpected configurations.
fix
Familiarize yourself with the official EditorConfig specification, especially regarding file resolution, inheritance, and the `root = true` property, to correctly predict configurations.
affects: all
gotchaThe `get_properties()` function requires an absolute file path as input. Providing a relative path will result in an `editorconfig.exceptions.PathError`.
fix
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.
affects: all
gotchaThe `editorconfig.get_properties` function requires the input path to be an absolute path name. Providing a relative path will raise a `PathError`.
fix
Ensure the path provided to `editorconfig.get_properties` is an absolute path (e.g., by using `os.path.abspath()` or `pathlib.Path.resolve()`).
affects: all
Upgrade
Version history
0.17.1latest on PyPI · released Jun 9, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
Resources