fix(cli): single import style for importlib in the operator CLI - #33
Merged
Conversation
github-code-quality flagged `importlib` imported both ways in rootsign/cli.py: `from importlib import resources` at module level (pre-existing) and `import importlib` inside `_require()`, which came in with the no-extras console-script fix (#28). Accurate, and mine. Rather than renaming the local import, hoisted `import_module` into the existing module-level `from importlib import ...` and dropped the function-local import entirely — `importlib` is stdlib, so there is nothing to defer, and `_require` is now three lines shorter. Note this does NOT undo #28: what had to be lazy there was psycopg2/alembic (the optional postgres extra), never importlib itself. Re-verified on a real bare install — the behaviour #28 fixed is unchanged: rootsign-admin --help -> exit 0 rootsign-admin status -> install hint, exit 1 (missing module: psycopg2) rootsign-admin init -> install hint, exit 1 (missing module: alembic) Full suite: 500 passed, 6 skipped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
oabolade
added a commit
that referenced
this pull request
Aug 19, 2026
Patch release. Every change that ships in the wheel since v0.2.0 is a bug fix; no new public API and nothing breaking. #25 fix(security) log injection — `tool_name` off the MCP proxy wire reached two logger calls unescaped #27 fix(security) same guard reshaped so CodeQL can see it; output byte-identical #28 fix(sdk) BOTH console scripts were unusable on a bare install — `rootsign version`, `rootsign --help`, `rootsign verify --local` and every `rootsign-admin` command died on ModuleNotFoundError #30 fix(sdk) missing `postgres` extra now names the install command on every DB-backed path, not just some #33 fix(cli) single import style for importlib #29/#31/#32 (test + CI) and #26 (actions bump) change nothing in the distribution. README's Status headline moves to v0.2.1; the phase table's "✅ v0.2.0" row stays put — that records when 1.5 shipped, which is history, not the current version. `rootsign/_version.py` reads the version from installed distribution metadata, so pyproject.toml is the only place it is written. Reinstalled and verified it propagates to `rootsign.__version__`, `SDK_VERSION` (which lands in every envelope's `sdk_version`), and `rootsign version`. Built the artifacts and smoke-tested the wheel in a fresh no-extras venv — the #28 fix holds in the thing that would actually go to PyPI: rootsign version -> rootsign 0.2.1 rootsign --help -> exit 0 rootsign-admin --help -> exit 0 rootsign verify <uuid> -> install hint, exit 1 DB packages resolved -> none Full suite: 500 passed, 6 skipped. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clears the remaining code-quality finding on
main.The finding
github-code-qualityflaggedimportlibimported both ways inrootsign/cli.py:from importlib import resources— pre-existingimport importlib— came in with #28's_require()Accurate, and mine.
The fix
Rather than renaming the local import, hoisted
import_moduleinto the existing module-levelfrom importlib import ...and dropped the function-local import entirely:importlibis stdlib, so there was never anything to defer —_requireis now three lines shorter and the file has one import style.This does not undo #28. What had to be lazy there was
psycopg2/alembic(the optionalpostgresextra), neverimportlibitself.Verification
Re-ran against a real bare install to confirm #28's behaviour is intact:
ruff checkclean apart from the 2 pre-existingE402sThe other open finding
except BaseExceptionatrootsign/sdk/decorator.py:344— dismissed, not fixed. It's the ADR-002 failure-isolation pattern: the handler storeserror = exc, runs_try_ingest, then re-raises unconditionally (raise error), soKeyboardInterrupt/SystemExitstill propagate — just after the ACTION_RECORD is emitted, which is the whole point.Worth noting why it reappeared: it was dismissed earlier in this audit at
decorator.py:299. Dismissals are pinned to a location, so when_log_safeand thepostgres_extra_requiredimport shifted the line to 344, CodeQL opened it as a new finding. Same mechanism that reopened log-injection alerts #8/#9 as #10/#11. Expect this one to resurface on any future edit above it in that file.🤖 Generated with Claude Code