Mark ambiguous run summary recommendations#1926
Conversation
|
I pushed a small snapshot-spacing follow-up after CI. The test matrix was failing in Local checks after the follow-up:
|
|
CI update after the snapshot-spacing follow-up:
This looks unrelated to this PR's CLI recommendation text/snapshot change. I tried to rerun the failed job, but GitHub requires repository admin rights for reruns on this workflow. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Thanks, applied the wording suggestion in Changes:
Verified locally:
Note: |
| def _format_package_list(package_names: list[str]) -> str: | ||
| quoted_names = [f'`{name}`' for name in package_names] | ||
| if len(quoted_names) == 1: | ||
| return quoted_names[0] | ||
| return f'{", ".join(quoted_names[:-1])}, and {quoted_names[-1]}' |
There was a problem hiding this comment.
🟡 _format_package_list produces incorrect grammar for 2-item lists
For a 2-item list like ['requests', 'sqlite3'], _format_package_list returns `requests`, and `sqlite3` (with a spurious comma before "and"). English grammar for 2-item lists is "X and Y" (no comma); the Oxford comma style "X, and Y" is only correct for 3+ items. This is reachable when exactly 2 of the 3 AMBIGUOUS_RECOMMENDATION_PACKAGES appear in recommendations (e.g. the user already has opentelemetry-instrumentation-urllib installed, so only requests and sqlite3 are flagged).
| def _format_package_list(package_names: list[str]) -> str: | |
| quoted_names = [f'`{name}`' for name in package_names] | |
| if len(quoted_names) == 1: | |
| return quoted_names[0] | |
| return f'{", ".join(quoted_names[:-1])}, and {quoted_names[-1]}' | |
| def _format_package_list(package_names: list[str]) -> str: | |
| quoted_names = [f'`{name}`' for name in package_names] | |
| if len(quoted_names) == 1: | |
| return quoted_names[0] | |
| if len(quoted_names) == 2: | |
| return f'{quoted_names[0]} and {quoted_names[1]}' | |
| return f'{', '.join(quoted_names[:-1])}, and {quoted_names[-1]}' |
Was this helpful? React with 👍 or 👎 to provide feedback.
Fixes #1296
Summary
logfire runrecommendations (requests,sqlite3,urllib) with*.Tests
uv run pytest tests/test_cli.py::test_get_recommendation_texts tests/test_cli.py::test_get_recommendation_texts_marks_ambiguous_packages -quv run ruff check logfire/_internal/cli/run.py tests/test_cli.pyuv run ruff format --check logfire/_internal/cli/run.py tests/test_cli.pyNotes