Skip to content

Commit 15e8f6b

Browse files
committed
fix: copy over signature from generate-demo-project.py to match-generated-precommit.py
1 parent 3398892 commit 15e8f6b

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

scripts/generate-demo-project.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
from typing import Annotated
66

77
import typer
8-
from typer.models import OptionInfo
98

9+
from util import FolderOption
1010
from util import generate_demo_project
1111

1212

13-
FolderOption: partial[OptionInfo] = partial(
14-
typer.Option, dir_okay=True, file_okay=False, resolve_path=True, path_type=Path
15-
)
16-
1713
cli: typer.Typer = typer.Typer()
1814

1915

scripts/match-generated-precommit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import sys
22
from pathlib import Path
3+
from typing import Annotated
34
from typing import Any
45

56
import pre_commit.main
67
import typer
78
from retrocookie.core import retrocookie
89

10+
from scripts.util import FolderOption
911
from util import in_new_demo
1012

1113

@@ -14,20 +16,18 @@
1416

1517
@cli.callback(invoke_without_command=True)
1618
def match_generated_precommit(
17-
repo_folder: Path,
18-
demos_cache_folder: Path,
19-
demo_name: str,
20-
no_cache: bool,
21-
**kwargs: Any
19+
repo_folder: Annotated[Path, FolderOption("--repo-folder", "-r")],
20+
demos_cache_folder: Annotated[Path, FolderOption("--demos-cache-folder", "-c")],
21+
demo_name: Annotated[str, typer.Option("--demo-name", "-d")],
22+
no_cache: Annotated[bool, typer.Option("--no-cache", "-n")] = False,
2223
) -> None:
2324
"""Runs precommit in a generated project and matches the template to the results."""
2425
try:
2526
with in_new_demo(
2627
repo_folder=repo_folder,
2728
demos_cache_folder=demos_cache_folder,
2829
demo_name=demo_name,
29-
no_cache=no_cache,
30-
**kwargs
30+
no_cache=no_cache
3131
) as demo_path:
3232
pre_commit.main.main(["run", "--all-files", "--hook-stage=manual", "--show-diff-on-failure"])
3333
retrocookie(instance_path=demo_path, commits=["HEAD"])

scripts/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
from cookiecutter.main import cookiecutter
1616
from cookiecutter.utils import work_in
1717
from pygments.lexers import q
18+
from typer.models import OptionInfo
19+
20+
21+
FolderOption: partial[OptionInfo] = partial(
22+
typer.Option, dir_okay=True, file_okay=False, resolve_path=True, path_type=Path
23+
)
1824

1925

2026
def remove_readonly(func: Callable[[str], Any], path: str, _: Any) -> None:

0 commit comments

Comments
 (0)