Registry / devops / codeowners

codeowners

JSON →
library0.9.0pypypi✓ verified 10d ago

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.

pip install codeowners
INSTALL
IMPORT
SIG · CODEOWNERS
C
codeowners
devopspythonv0.9.0
Install
1.6s avg
Import
13ms
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.9.0 · 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.014s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.010s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

CodeOwners
from codeowners import CodeOwners
from codeowners import Codeowners

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.

from codeowners import Codeowners # Create a dummy CODEOWNERS file for demonstration with open('.github/CODEOWNERS', 'w') as f: f.write("*.py @python-devs\n/src/docs/* @docs-team\n/src/app/core/ @core-maintainers") # Initialize the parser with the path to the CODEOWNERS file # Note: The library searches default paths if not explicitly given, # but providing the path is best practice. co = Codeowners('.github/CODEOWNERS') # Get owners for a specific file path owners_py = co.of('src/app/utils.py') print(f"Owners for src/app/utils.py: {owners_py}") owners_doc = co.of('src/docs/guide.md') print(f"Owners for src/docs/guide.md: {owners_doc}") owners_core = co.of('src/app/core/models.py') print(f"Owners for src/app/core/models.py: {owners_core}") # Clean up the dummy file import os os.remove('.github/CODEOWNERS')
codeowners --version
Debug
Known issues
breakingVersion 0.2.0 introduced a significant API-breaking change. The main `Codeowners` class was removed and is no longer importable. The library shifted its focus to providing lower-level parsing functions.
fix
Applications importing `Codeowners` will encounter an `ImportError`. To migrate, use the new parsing functions available under `codeowners.parser`. If the high-level `Codeowners` object is required, pin the library version to `<0.2.0`.
affects: >=0.2.0
gotchaThe `Codeowners` constructor searches for CODEOWNERS files in specific default locations (`.github/CODEOWNERS`, `CODEOWNERS` in root, `docs/CODEOWNERS`) if no explicit path is provided.
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')`.
affects: All versions
gotchaThe library strictly follows the CODEOWNERS specification's rule that the last matching pattern in the file takes precedence.
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.
affects: All versions
breakingThe main class provided by the `codeowners` library is `CodeOwners` (with an uppercase 'O'), not `Codeowners` (lowercase 'o'). Attempting to import `Codeowners` will result in an `ImportError`.
fix
Ensure you use the correct capitalization when importing the main class: `from codeowners import CodeOwners`.
affects: All versions
Upgrade
Version history
0.9.0latest on PyPI · released Jun 28, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Amazon
1
Resources
codeowners — pip install codeowners · libregistry