Skip to content

feat(config): support configuration via pyproject.toml - #761

Merged
TheKevJames merged 1 commit into
masterfrom
kjames/pyproject-toml-config
Jul 22, 2026
Merged

feat(config): support configuration via pyproject.toml#761
TheKevJames merged 1 commit into
masterfrom
kjames/pyproject-toml-config

Conversation

@TheKevJames

Copy link
Copy Markdown
Owner

Summary

Adds support for configuring coveralls-python via a [tool.coveralls] table in pyproject.toml, alongside the existing sources (CI env, COVERALLS_* env vars, .coveralls.yml, CLI flags).

TOML parsing is always available (stdlib tomllib on 3.11+, tomli on 3.10 — now an explicit dependency), so unlike the legacy YAML support it needs no extra install.

Behaviour

  • New file source slots into the existing resolve() precedence stack: CI env → COVERALLS_* env → config file → CLI/kwarg overrides.
  • Config files are never merged: the first file with settings wins, and the legacy .coveralls.yml takes precedence over pyproject.toml (matching the community norm used by coverage.py, mypy, pytest, and ruff, and preserving existing behaviour). A warning is emitted when both provide settings.
  • [tool.coveralls] runs through the same alias/deprecation/unknown-key pipeline as .coveralls.yml.
  • Malformed TOML surfaces as TOMLDecodeError; a non-table tool.coveralls raises TypeError; a missing table is silently ignored.

Refactor

coveralls/configuration.py grew past the 500-line limit, so it is split into a package with a strict one-directional import layering (repo → __init__ → {ci, environment, files} → helpers):

  • helpers.pyConfig, defaults, key canonicalization/filtering
  • ci.py — CI service detection
  • environment.pyCOVERALLS_* env loading
  • files.py — YAML/TOML file readers + first-found-wins selection
  • __init__.pyresolve() entrypoint, re-exports Config

Each module owns its own logger (coveralls.configuration.<module>).

Docs

docs/usage/configuration.rst now presents pyproject.toml as the recommended approach and documents .coveralls.yml as legacy (still fully supported).

Tests

All 178 tests pass; pre-commit run -a is clean. New TOML coverage lives in tests/api/toml_config_test.py.

@TheKevJames
TheKevJames force-pushed the kjames/pyproject-toml-config branch 2 times, most recently from 1ebd798 to 86d6629 Compare July 22, 2026 16:38
Refactors coveralls/configuration.py into a package (ci, environment,
files, helpers) with __init__ as the entrypoint.

changelog:
coveralls-python now reads configuration from a ``[tool.coveralls]`` table
in ``pyproject.toml`` (no extra dependency required). The legacy
``.coveralls.yml`` is still supported and takes precedence when both exist.
@TheKevJames
TheKevJames force-pushed the kjames/pyproject-toml-config branch from 86d6629 to 1d0071b Compare July 22, 2026 16:43
@TheKevJames
TheKevJames merged commit 00c1ce3 into master Jul 22, 2026
16 checks passed
@TheKevJames
TheKevJames deleted the kjames/pyproject-toml-config branch July 22, 2026 16:46
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.

1 participant