Rename CLI entry point to direct#8
Conversation
|
@claude review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 1m 2s —— View job Code Review: Rename CLI entry point to
|
There was a problem hiding this comment.
Pull request overview
This PR renames the installed console entry point for the Direct CLI to direct and updates user-facing help/docs to reflect the new command name.
Changes:
- Rename the PyPI console script from
direct-clitodirect. - Force Click’s top-level command name to
directso help/usage output matches. - Update README examples and CLI help assertions to use
direct.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pyproject.toml |
Renames the installed console script to direct. |
direct_cli/cli.py |
Sets the Click group name to direct to align help/usage output. |
README.md |
Updates all command examples to use direct instead of direct-cli. |
tests/test_cli.py |
Updates help output assertions to match direct usage strings. |
|
|
||
| [project.scripts] | ||
| direct-cli = "direct_cli.cli:cli" | ||
| direct = "direct_cli.cli:cli" |
There was a problem hiding this comment.
Removing the legacy console script name (direct-cli) is a breaking change for any existing automation/docs. Consider keeping direct-cli as an additional script entry (alias) for at least one release, or otherwise bump the version appropriately and call out the breaking change prominently in release notes.
| direct = "direct_cli.cli:cli" | |
| direct = "direct_cli.cli:cli" | |
| direct-cli = "direct_cli.cli:cli" |
|
|
||
|
|
||
| @click.group() | ||
| @click.group(name="direct") |
There was a problem hiding this comment.
Hardcoding the Click group name to "direct" forces help/error messages to always show direct, even if the command is invoked under a different executable name (e.g., if you decide to keep a direct-cli alias for backwards compatibility). If you want help to reflect the actual argv[0], consider leaving the group name unset and, for tests, passing prog_name="direct" to CliRunner.invoke(...) instead.
| @click.group(name="direct") | |
| @click.group() |
There was a problem hiding this comment.
Re: Hardcoded name="direct"
Skipping — hardcoding the name is intentional. It ensures clean, predictable help output (Usage: direct) regardless of how the tool is invoked. Leaving it unset would show python -m direct_cli.cli during development or full paths in some environments. The current approach is consistent and the tests assert the expected output.
| [project.scripts] | ||
| direct-cli = "direct_cli.cli:cli" | ||
| direct = "direct_cli.cli:cli" | ||
|
|
There was a problem hiding this comment.
The PR description mentions "Pin Click usage/help" (suggesting a Click version pin), but this change set only renames the entry point / usage strings and does not adjust the Click dependency constraint. Either update the dependency spec accordingly or clarify the PR description to match what was changed.
There was a problem hiding this comment.
Re: PR description mentions "Pin Click usage/help"
This appears to be a misreading of the PR description. "Pin" here is used in the colloquial sense of "set/fix the Click group name to direct" (the name="direct" parameter on @click.group()), not "pin a dependency version." No change to the Click dependency constraint (click>=8.0.0) is needed — the current constraint is correct and unrelated to this rename.
|
Re: Name collision risk ( Skipping — this is a product/naming preference, not a code defect. The name |
Add backward-compatible `direct-cli` console script alias alongside the new `direct` entry point. Bump version from 0.1.2 to 0.2.0 to reflect the breaking change in the CLI entry point name. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
@claude review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 1m 4s —— View job Code Review: Rename CLI entry point to
|
* fix(auth): stop --help and unit tests from hanging on client-login network call A regression from #480 made get_credentials() resolve the bare Client-Login via a network clients.get on every CLI invocation when an OAuth profile with an email login lacked the login_migration_checked flag — including plain `<group> --help`. That call had no timeout (neither the vendored client nor tapi2 set one), so a slow link or a Yandex SmartCaptcha gateway could hang the CLI indefinitely. Under CliRunner this also hung the unit suite (it stalled on test_registered_mapped_groups_show_docs_url, which fires ~30 `--help` calls). Three independent guards: - auth.py: cap the best-effort resolver with LOGIN_RESOLVE_TIMEOUT_SECONDS=8 and disable retries, so it can never wait forever. - cli.py: skip the resolver entirely on --help/--version/-h passes (allow_login_resolve=False) — no command runs, so no login is needed. - tests/conftest.py: autouse fixture neutralizes the network resolver for the whole unit suite; the module-level test-credential probe no longer triggers it. Adds regression tests asserting a --help pass makes zero resolver calls and that allow_login_resolve=False suppresses the migration. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: resolve 13 confirmed bugs from the #483 bug hunt Verified each finding against the live API, the WSDL cache, and the official Yandex Direct docs before fixing. Bugs 10 and 14 were false positives (no UsageError source inside the try — style only) and are intentionally skipped. Functional fixes: - bids/keywordbids get: reject empty SelectionCriteria with a UsageError before the request (live API error 4001) (#1, #2). - bids get: re-raise UsageError so the new guard surfaces with exit code 2 (#8). - bids set-auto: require exactly one of CampaignId/AdGroupId/KeywordId via add_single_id_selector (docs: the three are mutually exclusive) (#4). - vendored to_columns: pad short report rows instead of IndexError (#3). - vendored error handler: error_data.get("error_detail") to avoid KeyError (#11). - reports build_report_request: reject empty FieldNames (live API error 8000) (#12). Swallowed-validation fixes (add `except click.UsageError/ClickException: raise` before the bare `except Exception`): balance (#6), strategies get (#7), campaigns get (#9), ads get (#13), negativekeywordsharedsets update (#5). Type annotation: parse_priority_goals_spec items -> List[Dict[str, Any]] (#15). build_api_coverage_report: supply --campaign-ids for bids/keywordbids get wire-capture so the empty-criteria guard does not break schema parity. Closes #483 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: broaden #483 coverage and add CHANGELOG (cherry-picked from #484) Incorporates the genuinely-better parts of the parallel PR #484 into this branch, which already carries the regression tests, the #15 annotation fix, and the localized messages: - ads: re-raise click.UsageError in all lifecycle handlers (update, delete, archive, unarchive, suspend, resume, moderate) in addition to get — so the whole resource matches bug #13's "get + 8 lifecycle" scope. Defensive: these handlers have no pre-API UsageError source today, but the guard keeps them consistent and future-proof. - retargeting get/delete, advideos get: same defensive re-raise for uniformity (issue #483 items 10/14; not live defects, but harmless consistency). - bids/keywordbids get: the empty-criteria message now also lists --serving-statuses, which likewise populates SelectionCriteria (kept the t() localization wrapper). - CHANGELOG.md: document the bug-hunt fixes (#483) and the --help network-hang follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: axisrow <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary\n- Rename the console script from to .\n- Pin Click usage/help to and update the README examples.\n- Adjust CLI help assertions to match the new command name.\n\n## Verification\n- \n-
==================================== ERRORS ====================================
______________________ ERROR collecting tests/test_cli.py ______________________
ImportError while importing test module '/home/hapi/direct-cli/tests/test_cli.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/test_cli.py:9: in
from direct_cli.cli import cli
direct_cli/cli.py:11: in
from .commands.campaigns import campaigns
direct_cli/commands/init.py:5: in
from .campaigns import campaigns
direct_cli/commands/campaigns.py:8: in
from ..api import create_client
direct_cli/api.py:7: in
from tapi_yandex_direct import YandexDirect
E ModuleNotFoundError: No module named 'tapi_yandex_direct'
=========================== short test summary info ============================
ERROR tests/test_cli.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 0.13s could not complete in this environment because is not installed.