repomatic.init.tool_config module¶
Merge the bundled [tool.*] templates into a pyproject.toml.
Each ToolConfigComponent ships its section in
the native format of its tool, under repomatic/data/. A missing section is
installed from the template. An existing one is left alone, or re-derived from
the template on every sync while the local additions are grafted back on,
depending on its SyncMode.
- repomatic.init.tool_config.PYPROJECT_FMT_INDENT = 2¶
Spaces
pyproject-fmtputs before each row of a multi-line array, its default._graft_local_additionslays out a rebuilt multi-line array at this indent. tomlrt’s own fallback is four spaces, which theformat-pyprojectjob rewrites in a pull request of its own.
- repomatic.init.tool_config.TOOL_CONFIG_COMPONENTS: dict[str, ToolConfigComponent] = {'bumpversion': ToolConfigComponent(name='bumpversion', description='bump-my-version configuration', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='bumpversion.toml', tool_section='tool.bumpversion', sync_mode=<SyncMode.ONGOING: 2>, customizable_entries=(), legacy_table='', preserved_keys=('current_version',), graft_identity_keys=('filename', 'glob', 'key_path', 'replace'), overlay=False), 'coverage': ToolConfigComponent(name='coverage', description='Coverage.py measurement and reporting configuration', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='coverage.toml', tool_section='tool.coverage', sync_mode=<SyncMode.BOOTSTRAP: 1>, customizable_entries=(), legacy_table='', preserved_keys=(), graft_identity_keys=(), overlay=False), 'lychee': ToolConfigComponent(name='lychee', description='Lychee link checker configuration', init_default=<InitDefault.INCLUDE: 1>, scope=<RepoScope.AWESOME_ONLY: 2>, files=(), config_key='', ephemeral=False, location_field='', source_file='lychee.toml', tool_section='tool.lychee', sync_mode=<SyncMode.ONGOING: 2>, customizable_entries=(), legacy_table='', preserved_keys=(), graft_identity_keys=(), overlay=False), 'mdformat': ToolConfigComponent(name='mdformat', description='mdformat Markdown formatter configuration', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='mdformat.toml', tool_section='tool.mdformat', sync_mode=<SyncMode.BOOTSTRAP: 1>, customizable_entries=(), legacy_table='', preserved_keys=(), graft_identity_keys=(), overlay=False), 'mypy': ToolConfigComponent(name='mypy', description='Mypy type checking configuration', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='mypy.toml', tool_section='tool.mypy', sync_mode=<SyncMode.BOOTSTRAP: 1>, customizable_entries=(), legacy_table='', preserved_keys=(), graft_identity_keys=(), overlay=False), 'pytest': ToolConfigComponent(name='pytest', description='Pytest test configuration', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='pytest.toml', tool_section='tool.pytest', sync_mode=<SyncMode.BOOTSTRAP: 1>, customizable_entries=(('addopts', '--cov=.'),), legacy_table='ini_options', preserved_keys=(), graft_identity_keys=(), overlay=False), 'ruff': ToolConfigComponent(name='ruff', description='Ruff linter/formatter configuration', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='ruff.toml', tool_section='tool.ruff', sync_mode=<SyncMode.BOOTSTRAP: 1>, customizable_entries=(), legacy_table='', preserved_keys=(), graft_identity_keys=(), overlay=False), 'typos': ToolConfigComponent(name='typos', description='Typos spell checker configuration', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='typos.toml', tool_section='tool.typos', sync_mode=<SyncMode.ONGOING: 2>, customizable_entries=(), legacy_table='', preserved_keys=(), graft_identity_keys=(), overlay=False), 'uv': ToolConfigComponent(name='uv', description='uv resolver pin and dependency cooldown policy', init_default=<InitDefault.EXPLICIT: 3>, scope=<RepoScope.ALL: 1>, files=(), config_key='', ephemeral=False, location_field='', source_file='uv.toml', tool_section='tool.uv', sync_mode=<SyncMode.ONGOING: 2>, customizable_entries=(), legacy_table='', preserved_keys=(), graft_identity_keys=(), overlay=True)}¶
The tool config components, by name: what
init_config()accepts.
- repomatic.init.tool_config.merge_tool_config(content, comp)[source]¶
Merge the template of comp into the
pyproject.tomltext content.A missing section is installed from the template. An existing one is left alone in
BOOTSTRAPmode. InONGOINGmode it is re-derived from the template, or, for a partial template (overlay), only the keys the template owns are updated in place.- Parameters:
content (
str) – The currentpyproject.tomlcontent.comp (
ToolConfigComponent) – The component whose section is merged.
- Return type:
- Returns:
The new content, or
Nonewhen the section needs no change.
- repomatic.init.tool_config.init_config(config_type, pyproject_path=None)[source]¶
Merge the template of one tool config into a
pyproject.tomlfile.Reads the file and hands it to
merge_tool_config(). The file itself is left alone: the caller writes the returned content.- Parameters:
- Return type:
- Returns:
The modified
pyproject.tomlcontent, orNonewhen no change is needed or the file does not exist.- Raises:
ValueError – If no tool config component carries that name.
- repomatic.init.tool_config.adopted_ongoing_configs(output_dir)[source]¶
Return the ongoing tool configs whose section
pyproject.tomlalready carries.EXPLICITgoverns adoption, not upkeep: it keeps a bareinitfrom pushing[tool.typos]onto a repository that never asked for one. Once the section is there the repository has asked, so anONGOINGcomponent rejoins the bare-init set and resumes tracking the bundled template.Without this the two flags cancel out. The only sync that ever runs unattended is the bare
initthesync-repomaticjob calls, so an ONGOING section is otherwise re-derived only when a human types its component name, and a[tool.typos]written by hand sits indefinitely beside a bundled template it never adopts a single rule from.BOOTSTRAPcomponents stay out: their template is a starting point the repository owns outright after the first write, and re-selecting one would revert deliberate local edits.