{"id":1426,"library":"codeowners","title":"Codeowners Parser","description":"A Python library for parsing and working with CODEOWNERS files, typically used in Git repositories to define ownership for different parts of the codebase. It provides methods to identify the owners of specific file paths based on the rules defined in a CODEOWNERS file. The current version is 0.8.0. Releases are infrequent, usually for minor bug fixes or small feature additions.","status":"active","version":"0.8.0","language":"en","source_language":"en","source_url":"https://github.com/sbdchd/codeowners","tags":["codeowners","parser","git","ownership"],"install":[{"cmd":"pip install codeowners","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Codeowners","correct":"from codeowners import Codeowners"},{"symbol":"CodeownersError","correct":"from codeowners.exceptions import CodeownersError"}],"quickstart":{"code":"from codeowners import Codeowners\n\n# Create a dummy CODEOWNERS file for demonstration\nwith open('.github/CODEOWNERS', 'w') as f:\n    f.write(\"*.py @python-devs\\n/src/docs/* @docs-team\\n/src/app/core/ @core-maintainers\")\n\n# Initialize the parser with the path to the CODEOWNERS file\n# Note: The library searches default paths if not explicitly given, \n# but providing the path is best practice.\nco = Codeowners('.github/CODEOWNERS')\n\n# Get owners for a specific file path\nowners_py = co.of('src/app/utils.py')\nprint(f\"Owners for src/app/utils.py: {owners_py}\")\n\nowners_doc = co.of('src/docs/guide.md')\nprint(f\"Owners for src/docs/guide.md: {owners_doc}\")\n\nowners_core = co.of('src/app/core/models.py')\nprint(f\"Owners for src/app/core/models.py: {owners_core}\")\n\n# Clean up the dummy file\nimport os\nos.remove('.github/CODEOWNERS')\n","lang":"python","description":"This quickstart demonstrates how to initialize the `Codeowners` parser and retrieve the owners for specific file paths. It creates a temporary CODEOWNERS file to illustrate usage."},"warnings":[{"fix":"While not an API-breaking change, this could affect performance characteristics or memory usage for some applications. Users sensitive to parsing speed should benchmark or consider pinning to `<0.2.0` if the pure Python implementation proves too slow for their specific use case.","message":"Version 0.2.0 significantly changed the library's implementation by removing the underlying Rust bindings and switching to a pure Python parser.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"To avoid ambiguity and ensure the correct file is parsed, always explicitly provide the path to your CODEOWNERS file, e.g., `Codeowners('path/to/your/CODEOWNERS')`.","message":"The `Codeowners` constructor searches for CODEOWNERS files in specific default locations (`.github/CODEOWNERS`, `CODEOWNERS` in root, `docs/CODEOWNERS`) if no explicit path is provided.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your CODEOWNERS file is ordered correctly according to your desired ownership hierarchy. If results are unexpected, verify the precedence rules defined in the CODEOWNERS specification.","message":"The library strictly follows the CODEOWNERS specification's rule that the last matching pattern in the file takes precedence.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}