Skip to content

Implement parsing of default command configuration from pyproject.toml#1290

Open
max-moser wants to merge 1 commit into
python-babel:masterfrom
max-moser:mm/pyproject-config
Open

Implement parsing of default command configuration from pyproject.toml#1290
max-moser wants to merge 1 commit into
python-babel:masterfrom
max-moser:mm/pyproject-config

Conversation

@max-moser

Copy link
Copy Markdown

I believe this should close #777

This PR adds support of pyproject.toml as a source for default configuration values for the various CLI commands (compile, extract, init, update).
The configuration will be read from pyproject.toml, under the [tool.babel.<command_name>] table, where <command_name> is one of compile_catalog, extract_messages, init_catalog, update_catalog (taken from frontend_setuptools).

The motivation for this PR here is that I've recently migrated most of the inveniosoftware packages from setuptools to hatchling and we included the old configuration from setup.cfg in pyproject.toml, only to find that pybabel doesn't actually read any command config from pyproject.toml 😅
(Luckily for us that was only a minor issue in one package that we fixed otherwise)


The mechanism for finding pyproject.toml is similar to that used in other tools, like isort.
I could also imagine adding a global CLI flag for disabling reading pyproject.toml altogether, or for letting users specify another TOML config file instead.

The parsed values are inserted as default values for the optparse parser, so user-provided CLI flags should still take precedence.

Please let me know if this goes in an acceptable direction, then I can polish up the implementation a bit 🙂

@max-moser max-moser force-pushed the mm/pyproject-config branch from 65a5cdb to ceb1f4b Compare July 7, 2026 14:34
@akx akx self-assigned this Jul 7, 2026
@akx akx added the feature label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parse settings from pyproject.toml

2 participants