migrate

migrate#

policy migrate — upgrade a repository’s .pre-commit-config.yaml.

The flags that used to be repeated under args: in .pre-commit-config.yaml can be declared once in a [tool.compwa.policy] table instead (see the _settings module). This command reads the args of the check-dev-files hook, validates them against the current parser, writes them into the hierarchical [tool.compwa.policy] table of pyproject.toml, and removes the now-redundant args from the hook.

It also relocates any notebook formatting hooks that are still served from the ComPWA/policy repo entry to a ComPWA/nbhooks repo entry, since those hooks were extracted into a separate repository.

GROUP_FLAGS: dict[str, tuple[str, ...]] = {'env': ('--environment-variables', '--keep-contributing-md', '--package-manager'), 'format': ('--no-cspell-update',), 'github': ('--allow-deprecated-workflows', '--allow-labels', '--ci-skipped-tests', '--doc-apt-packages', '--github-pages', '--keep-pr-linting', '--keep-workflow', '--macos-python-version', '--no-cd', '--no-github-actions', '--no-milestones', '--no-pypi', '--no-version-branches', '--upgrade-frequency'), 'nb': ('--allowed-cell-metadata', '--no-binder'), 'python': ('--allow-vscode-coverage-gutters', '--excluded-python-versions', '--imports-on-top', '--keep-local-precommit', '--no-ruff', '--pytest-single-threaded', '--type-checker'), 'repo': ('--gitpod', '--keep-issue-templates')}#

Which subcommand group now owns each check-dev-files flag.

migrate(config_file: Path, <typer.models.ArgumentInfo object at 0x7f91d2d6fa10>]=PosixPath('.pre-commit-config.yaml'), dry_run: Annotated[bool, <typer.models.OptionInfo object at 0x7f91d0df20d0>]=False) None[source]#

Migrate hook args into a pyproject.toml policy table and relocate nb hooks.