Skip to content

Functionalize system hook config method #1605

Description

@nathanjmcdougall

We have a pattern which occurs a lot on the codebase, which I noticed in #1601

PreCommitConfig.from_single_repo(
                pre_commit_schema.LocalRepo(
                    repo="local",
                    hooks=[
                        pre_commit_schema.HookDefinition(
                            id="import-linter",
                            name="import-linter",
                            pass_filenames=False,
                            entry=f"uv run {tool_name}",
                            language=get_system_language(),
                            require_serial=True,
                            always_run=True,
                        )
                    ],
                ),
                requires_venv=True,
                inform_how_to_use_on_migrate=False,
            )

For some tool_name, and using a backend-dependent logic to choose the entry= string. We should probably search for this pattern in the codebase, and introduce a new method on PreCommitConfig for generating this pattern from the tool name. This should make things more concise by reducing the cases of if-else branches
checking on the backend in the src/usethis/_tool/impl/spec layer and elsewhere

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or requestinternalChanges to the internals without changing interfaces

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions