{"id":1469,"library":"editorconfig","title":"EditorConfig Core Python","description":"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.","status":"active","version":"0.17.1","language":"en","source_language":"en","source_url":"https://github.com/editorconfig/editorconfig-core-py","tags":["configuration","editor","linting","style"],"install":[{"cmd":"pip install editorconfig","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"get_properties","correct":"import editorconfig\nproperties = editorconfig.get_properties(filepath)"}],"quickstart":{"code":"import os\nimport editorconfig\n\n# Create a dummy .editorconfig file and a test file for demonstration\ntemp_dir = \"temp_editorconfig_test\"\nos.makedirs(temp_dir, exist_ok=True)\n\neditorconfig_path = os.path.join(temp_dir, \".editorconfig\")\nwith open(editorconfig_path, \"w\") as f:\n    f.write(\"[*.py]\\nindent_style = space\\nindent_size = 4\\nend_of_line = lf\\n\\n[*.md]\\ntrim_trailing_whitespace = true\\n\")\n\ntest_file_path_py = os.path.join(temp_dir, \"my_module.py\")\nwith open(test_file_path_py, \"w\") as f:\n    f.write(\"# Dummy Python file content\")\n\ntest_file_path_md = os.path.join(temp_dir, \"README.md\")\nwith open(test_file_path_md, \"w\") as f:\n    f.write(\"# Dummy Markdown content\")\n\ntry:\n    properties_py = editorconfig.get_properties(test_file_path_py)\n    print(f\"EditorConfig properties for {test_file_path_py}:\")\n    for key, value in properties_py.items():\n        print(f\"  {key}: {value}\")\n\n    print(\"\\n---\\n\")\n\n    properties_md = editorconfig.get_properties(test_file_path_md)\n    print(f\"EditorConfig properties for {test_file_path_md}:\")\n    for key, value in properties_md.items():\n        print(f\"  {key}: {value}\")\n\nfinally:\n    # Clean up dummy files and directory\n    os.remove(editorconfig_path)\n    os.remove(test_file_path_py)\n    os.remove(test_file_path_md)\n    os.rmdir(temp_dir)","lang":"python","description":"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."},"warnings":[{"fix":"Ensure your project runs on Python 3.9+ and install `editorconfig` version 0.15.0 or higher.","message":"Python 2 support was dropped in version 0.15.0. This library now requires Python 3.9 or newer.","severity":"breaking","affected_versions":"<0.15.0"},{"fix":"Explicitly cast property values to the desired type (e.g., `int(properties['indent_size'])` or `properties['trim_trailing_whitespace'] == 'true'`) when consuming them.","message":"All 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`).","severity":"gotcha","affected_versions":"all"},{"fix":"Familiarize yourself with the official EditorConfig specification, especially regarding file resolution, inheritance, and the `root = true` property, to correctly predict configurations.","message":"The 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}