fix(hosting-cli): repair main after the whoami/token merge - #6954
Conversation
#6918 was branched before #6939 and #6893 landed, so merging it left main failing both pre-commit and the unit tests. - `reflex_cli.v2.auth` imported `reflex_base.utils.log` at module scope. #6939 made reflex-base optional, because it does not exist on the reflex versions the CLI advertises support for, and `reflex_cli.v2.deployments` imports auth unconditionally — so importing any hosting CLI command raised ImportError on reflex older than 0.9, failing `test_cli_imports_without_reflex_base[reflex_cli.v2.deployments]`. It now resolves `log` through `reflex_cli.utils.log`, the shim the rest of the CLI uses, which falls back to its own SUCCESS level when reflex-base is absent. `reflex_cli.v2.auth` joins that test's module list so the guard names the module directly instead of catching it only through deployments. - `tests/units/reflex_cli/v2/test_auth.py` resolved the CLI with an inline `get_command(...) if isinstance(hosting_cli, Typer)`, which types as `Group | Command`; since the typer upgrade in #6893 vendored click, that is not assignable to `click.Command`, so every `runner.invoke` call was a pyright error (22 in total). It now uses the `as_click_command` helper #6893 added for exactly this, which casts once. No behavior change: on reflex 0.9 and up `reflex_cli.utils.log.SUCCESS` is the same object the module imported before. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QNTSjh5JBcVFfTx7Jvn3DT
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryThis PR restores compatibility for hosting CLI authentication commands when
Confidence Score: 5/5The PR appears safe to merge, with no actionable correctness or security issues identified. The logging shim supplies the interface used by the authentication commands in both supported dependency configurations, and the shared command-conversion helper preserves the prior runtime conversion while resolving the type-checking failure.
|
| Filename | Overview |
|---|---|
| packages/reflex-hosting-cli/src/reflex_cli/v2/auth.py | Replaces the optional reflex_base logging import with the CLI shim, which preserves the logging interface used by authentication commands. |
| tests/units/reflex_cli/utils/test_log.py | Extends the optional-dependency import test to cover the authentication module directly. |
| tests/units/reflex_cli/v2/test_auth.py | Replaces an inline Typer conversion with the established typed helper without changing the tested command surface. |
Reviews (1): Last reviewed commit: "fix(hosting-cli): repair main after the ..." | Re-trigger Greptile
All Submissions:
Type of change
Changes To Core Features:
What happened
#6918 (
reflex cloud whoami/reflex cloud token, merged as dfb4ef0) was branched before #6939 and #6893 landed. Nothing conflicted textually, so it merged cleanly and brokemainon two fronts:1. Unit tests —
test_cli_imports_without_reflex_base[reflex_cli.v2.deployments]reflex_cli/v2/auth.pyimportsreflex_base.utils.logat module scope, but #6939 made reflex-base optional precisely because it does not exist on the reflex versions the hosting CLI advertises support for (MINIMUM_REFLEX_VERSIONpredates the workspace split).reflex_cli/v2/deployments.pyimportsauthunconditionally, so on reflex older than 0.9 importing any hosting CLI command raisedImportError: No module named 'reflex_base':2. Pre-commit — 22 pyright errors in
tests/units/reflex_cli/v2/test_auth.pyThe test resolved the CLI with an inline
get_command(hosting_cli) if isinstance(hosting_cli, Typer) else hosting_cli, which types asGroup | Command. Since the typer upgrade in #6893 vendored click, that is not assignable toclick.Command, so every one of the 22runner.invoke(hosting_cli, ...)calls failed thepyrighthook:The fix
auth.pyresolveslogthroughreflex_cli.utils.log— the shim every other CLI module already uses, which re-exports reflex-base'sSUCCESSwhen it is importable and defines its own otherwise. On reflex 0.9 and up this is the identical object, so there is no behavior change.reflex_cli.v2.authis added totest_cli_imports_without_reflex_base's module list, so the guard names the module directly instead of only catching it transitively throughdeployments. It fails without theauth.pychange.test_auth.pyusesas_click_command, the helper Upgrade dev tooling and fix docstring style #6893 added for exactly this and which the sibling CLI tests already use, instead of casting inline.Verification
Both failures reproduce on
9f7f82c5(currentmain) and are gone here:uv run pytest tests/units/reflex_cli— 444 passed (was 1 failed)uv run pytest tests/units— 7766 passed, 18 skipped. The only remaining failures,test_processes.py::test_is_process_on_port_free_portand::test_is_process_on_port_concurrent_access, are pre-existing and environmental (this sandbox has no IPv6:Address family not supported by protocol); they fail identically onmainatdfb4ef0d^.uv run pre-commit run --all-files— all hooks pass (ruff-format, ruff-check, codespell, update-pyi-files, pyright, ty, biome)No news fragment: #6918 and #6939 are both unreleased (latest tag is
reflex-hosting-cli-v0.1.70, before either merged), so the broken import never shipped and there is nothing user-facing to describe. Please applyskip-changelog.🤖 Generated with Claude Code
https://claude.ai/code/session_01QNTSjh5JBcVFfTx7Jvn3DT
Generated by Claude Code