Skip to content

Commit bd34c7d

Browse files
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 <cursoragent@cursor.com>
1 parent 9e0e7e9 commit bd34c7d

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

packages/create-awesome-python-app/src/create_awesome_python_app/cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ def scaffold(
247247
choices=list(choice_by_title),
248248
match_middle=True,
249249
qmark="?",
250-
pointer=">",
251250
).ask()
252251
selected_template = choice_by_title.get(str(selected_title), selected_title)
253252
if selected_template == CUSTOM_TEMPLATE_SENTINEL:

packages/create-awesome-python-app/tests/test_interactive.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,68 @@ def test_in_ci_env(monkeypatch) -> None:
2828
os.environ.pop("CI", None)
2929

3030

31+
def test_interactive_template_autocomplete_omits_pointer(
32+
tmp_path: Path, monkeypatch
33+
) -> None:
34+
"""questionary.autocomplete rejects ``pointer`` (PromptSession TypeError)."""
35+
template_dir = tmp_path / "fastapi"
36+
template_dir.mkdir()
37+
(template_dir / "cpa.config.json").write_text(
38+
json.dumps({"name": "fastapi-starter"}),
39+
encoding="utf-8",
40+
)
41+
catalog = {
42+
"categories": [{"slug": "backend-applications", "name": "Backend"}],
43+
"templates": [
44+
{
45+
"slug": "fastapi-starter",
46+
"name": "FastAPI Starter",
47+
"url": f"file://{template_dir}",
48+
"type": "fastapi-backend",
49+
"category": "backend-applications",
50+
}
51+
],
52+
"extensions": [],
53+
}
54+
catalog_file = tmp_path / "templates.json"
55+
catalog_file.write_text(json.dumps(catalog), encoding="utf-8")
56+
monkeypatch.setenv("CPA_CATALOG_URL", f"file://{catalog_file}")
57+
monkeypatch.setenv("CPA_NO_CATALOG_CACHE", "1")
58+
monkeypatch.delenv("CI", raising=False)
59+
60+
captured_kwargs: dict[str, object] = {}
61+
62+
def fake_autocomplete(*_args, **kwargs):
63+
captured_kwargs.update(kwargs)
64+
return FakePrompt("Backend FastAPI Starter (fastapi-starter)")
65+
66+
def fake_checkbox(*_args, **_kwargs):
67+
return FakePrompt([])
68+
69+
captured: dict[str, object] = {}
70+
71+
async def fake_create_python_app(project_directory, options, *_args, **_kwargs):
72+
captured["project_directory"] = project_directory
73+
captured["options"] = options
74+
75+
monkeypatch.setattr("questionary.autocomplete", fake_autocomplete)
76+
monkeypatch.setattr("questionary.checkbox", fake_checkbox)
77+
monkeypatch.setattr(
78+
"create_awesome_python_app.cli.create_python_app",
79+
fake_create_python_app,
80+
)
81+
monkeypatch.setattr(
82+
"create_awesome_python_app.cli.check_for_latest_version",
83+
fake_check_for_latest_version,
84+
)
85+
86+
result = runner.invoke(app, ["--interactive", "--no-install", "api"])
87+
88+
assert result.exit_code == 0, result.stdout + result.stderr
89+
assert "pointer" not in captured_kwargs
90+
assert captured["project_directory"] == "api"
91+
92+
3193
def test_interactive_extension_selection_passes_addon_urls(
3294
tmp_path: Path, monkeypatch
3395
) -> None:

0 commit comments

Comments
 (0)