Skip to content

Add support for pyproject.toml - #83

Merged
jaltmayerpizzorno merged 4 commits into
plasma-umass:mainfrom
ronaldorcampos:feature/support-pyproject
Jul 30, 2026
Merged

Add support for pyproject.toml#83
jaltmayerpizzorno merged 4 commits into
plasma-umass:mainfrom
ronaldorcampos:feature/support-pyproject

Conversation

@ronaldorcampos

Copy link
Copy Markdown
Contributor

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:

[tool.slipcover]
branch = true
source = "src"
omit = "tests/*"
fail-under = 80.0
json = true
out = "coverage.json"
skip-covered = true

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.

@ronaldorcampos

Copy link
Copy Markdown
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.

@ronaldorcampos

Copy link
Copy Markdown
Contributor Author

@emeryberger would appreciate if this PR could be reviewed. I have been using this in several projects now.

jaltmayerpizzorno and others added 3 commits July 30, 2026 14:40
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>
@jaltmayerpizzorno
jaltmayerpizzorno merged commit 85939fc into plasma-umass:main Jul 30, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pyproject integration

2 participants