From bd34c7db32e97bfdc4080bb30edf5e2062aa1033 Mon Sep 17 00:00:00 2001 From: ulises-jeremias Date: Fri, 17 Jul 2026 13:42:36 -0300 Subject: [PATCH 1/2] fix: drop unsupported pointer kwarg from template autocomplete questionary.autocomplete forwards unknown kwargs to PromptSession, which rejects pointer and crashes interactive template picking on uvx. Co-authored-by: Cursor --- .../src/create_awesome_python_app/cli.py | 1 - .../tests/test_interactive.py | 62 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py b/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py index da6728f..1bc6e12 100644 --- a/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py +++ b/packages/create-awesome-python-app/src/create_awesome_python_app/cli.py @@ -247,7 +247,6 @@ def scaffold( choices=list(choice_by_title), match_middle=True, qmark="?", - pointer=">", ).ask() selected_template = choice_by_title.get(str(selected_title), selected_title) if selected_template == CUSTOM_TEMPLATE_SENTINEL: diff --git a/packages/create-awesome-python-app/tests/test_interactive.py b/packages/create-awesome-python-app/tests/test_interactive.py index d6628a7..d47f6ad 100644 --- a/packages/create-awesome-python-app/tests/test_interactive.py +++ b/packages/create-awesome-python-app/tests/test_interactive.py @@ -28,6 +28,68 @@ def test_in_ci_env(monkeypatch) -> None: os.environ.pop("CI", None) +def test_interactive_template_autocomplete_omits_pointer( + tmp_path: Path, monkeypatch +) -> None: + """questionary.autocomplete rejects ``pointer`` (PromptSession TypeError).""" + template_dir = tmp_path / "fastapi" + template_dir.mkdir() + (template_dir / "cpa.config.json").write_text( + json.dumps({"name": "fastapi-starter"}), + encoding="utf-8", + ) + catalog = { + "categories": [{"slug": "backend-applications", "name": "Backend"}], + "templates": [ + { + "slug": "fastapi-starter", + "name": "FastAPI Starter", + "url": f"file://{template_dir}", + "type": "fastapi-backend", + "category": "backend-applications", + } + ], + "extensions": [], + } + catalog_file = tmp_path / "templates.json" + catalog_file.write_text(json.dumps(catalog), encoding="utf-8") + monkeypatch.setenv("CPA_CATALOG_URL", f"file://{catalog_file}") + monkeypatch.setenv("CPA_NO_CATALOG_CACHE", "1") + monkeypatch.delenv("CI", raising=False) + + captured_kwargs: dict[str, object] = {} + + def fake_autocomplete(*_args, **kwargs): + captured_kwargs.update(kwargs) + return FakePrompt("Backend FastAPI Starter (fastapi-starter)") + + def fake_checkbox(*_args, **_kwargs): + return FakePrompt([]) + + captured: dict[str, object] = {} + + async def fake_create_python_app(project_directory, options, *_args, **_kwargs): + captured["project_directory"] = project_directory + captured["options"] = options + + monkeypatch.setattr("questionary.autocomplete", fake_autocomplete) + monkeypatch.setattr("questionary.checkbox", fake_checkbox) + monkeypatch.setattr( + "create_awesome_python_app.cli.create_python_app", + fake_create_python_app, + ) + monkeypatch.setattr( + "create_awesome_python_app.cli.check_for_latest_version", + fake_check_for_latest_version, + ) + + result = runner.invoke(app, ["--interactive", "--no-install", "api"]) + + assert result.exit_code == 0, result.stdout + result.stderr + assert "pointer" not in captured_kwargs + assert captured["project_directory"] == "api" + + def test_interactive_extension_selection_passes_addon_urls( tmp_path: Path, monkeypatch ) -> None: From c17f522977516cdda756d02461561092e1615655 Mon Sep 17 00:00:00 2001 From: ulises-jeremias Date: Fri, 17 Jul 2026 13:44:30 -0300 Subject: [PATCH 2/2] test: pick autocomplete choice title from kwargs for ANSI-safe lookup Colored category badges make hard-coded titles fail under CI color settings. Co-authored-by: Cursor --- .../create-awesome-python-app/tests/test_interactive.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/create-awesome-python-app/tests/test_interactive.py b/packages/create-awesome-python-app/tests/test_interactive.py index d47f6ad..7b10fd9 100644 --- a/packages/create-awesome-python-app/tests/test_interactive.py +++ b/packages/create-awesome-python-app/tests/test_interactive.py @@ -38,13 +38,14 @@ def test_interactive_template_autocomplete_omits_pointer( json.dumps({"name": "fastapi-starter"}), encoding="utf-8", ) + template_url = f"file://{template_dir}" catalog = { "categories": [{"slug": "backend-applications", "name": "Backend"}], "templates": [ { "slug": "fastapi-starter", "name": "FastAPI Starter", - "url": f"file://{template_dir}", + "url": template_url, "type": "fastapi-backend", "category": "backend-applications", } @@ -61,7 +62,9 @@ def test_interactive_template_autocomplete_omits_pointer( def fake_autocomplete(*_args, **kwargs): captured_kwargs.update(kwargs) - return FakePrompt("Backend FastAPI Starter (fastapi-starter)") + choices = kwargs.get("choices") or [] + # Return a mapped title so choice_by_title resolves to the template URL. + return FakePrompt(choices[0] if choices else template_url) def fake_checkbox(*_args, **_kwargs): return FakePrompt([])