Add support for pyproject.toml - #83
Merged
jaltmayerpizzorno merged 4 commits intoJul 30, 2026
Merged
Conversation
Contributor
Author
|
@jaltmayerpizzorno hey, Id appreciate a review on it, please :) I feel this is a pretty important feature for this project and a lot of people will appreciate it too instead of relying on cli arguments only. |
Contributor
Author
|
@emeryberger would appreciate if this PR could be reviewed. I have been using this in several projects now. |
read_config()/apply_config() raising on malformed TOML or a bad-typed value is correct (matches black/ruff/mypy/pytest convention -- a config error is real signal, not something to silently swallow), but main() let those exceptions propagate as raw, unhandled tracebacks. Catch them at the CLI boundary instead and print a clean one-line error (TOMLDecodeError is a ValueError subclass, so this also covers malformed TOML). Also fixes a real correctness bug: TOML's idiomatic way to express multiple source/omit values is an array, but apply_config() just called str() on the list, producing literal garbage like "['src', 'lib']" instead of the comma-separated form --source/--omit expect. Now joined properly. Fixed two tautological tests (assert x or True, which can never fail) and added 7 new tests covering the above plus an end-to-end sanity check that pyproject.toml config is actually applied through a real subprocess invocation -- nothing previously exercised that path. README: corrected the "every flag has a matching key" claim (--merge, -m/module, the script argument, --version, and --help aren't configurable this way), documented array support for source/omit, and added the two example keys (xml, immediate) that were missing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
test_find_pyproject_stops_at_home used monkeypatch.setenv("HOME", ...)
to fake the home directory boundary, but Path.home() on Windows
resolves via USERPROFILE, not HOME -- so the env var had no effect
there, the fake home was never recognized, and the walk continued
past it to a real pyproject.toml a few levels up, failing every
windows-latest job in CI. Patch Path.home() directly instead, which is
platform-independent.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Those flags aren't part of the stable, user-facing config surface. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #82
This PR adds support for finding a pyproject.toml on the directory tree and reads [tool.slipcover] from it, configuring slipcover accordingly. CLI arguments will always win over this configuration, and will always take precedence.
Example:
This opens the possibility to support .rc files too.
In addition to the tests added, I tested this branch in other project.
Disclaimer, this PR was made with the assistance of AI.