Repository navigation
fix(cli): follow re-exported SDK names and ignore non-SDK .widget decorators in validate - #136
Merged
manish-wekan merged 1 commit intoNov 12, 2026
Conversation
…orators in validate Two regressions in the AST route discovery added in nitrocloudofficial#127: - A name re-exported through a project module (for example shared/__init__.py doing `from nitrostack import WidgetOptions`) was not followed, so `from shared import WidgetOptions` skipped the missing-HTML check. Name lookup now follows re-exports through project modules, with a guard against import cycles. - Any decorator ending in `.widget` was treated as the SDK decorator, so `@pytest.mark.widget("smoke")` warned about a missing smoke.html. A `widget` decorator now counts only when it resolves to the SDK's own, by direct import, `import nitrostack`, or a project re-export. Adds regression tests for both, including aliases, multi-hop and cyclic re-exports, and a non-SDK name that is re-exported.
2 tasks
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.
Follow-up to #127. Two regressions were found in the new route discovery in
nitrostack/cli/widget_routes.py.What was wrong
shared/__init__.pyre-exports the SDK'sWidgetOptions, thenfrom shared import WidgetOptionsfollowed by@widget(WidgetOptions(route="missing-card"))silently skipped the missing-HTML check. This worked before fix(cli): validate collects @widget routes passed through a helper (#116) #127..widgetdecorator counted as the SDK's.@pytest.mark.widget("smoke")wrongly warned thatwidgets/out/smoke.htmlis missing.Fix
widgetdecorator counts only if it resolves to the SDK's own: imported fromnitrostack, reached throughimport nitrostackornitrostack.decorators, or re-exported by a project module.pytest.mark.widget, a localdef widget, andwidgetfrom another library are ignored.Tests
13 new tests in
tests/test_validate_widgets.py. 10 of them fail on the currentdevelopand pass with this change: plain, aliased and two-hop re-exports, a re-exported factory, an end-to-endvalidate_widgetsrun for the reported case, five non-SDK.widgetforms, andpytest.mark.widgetnext to a real@widget. The rest cover import cycles, a non-SDK re-export, and thatnitrostack.widgetanddeco.widgetare still collected.Full suite passes locally (excluding
tests/test_oauth_client.py, which fails on this machine's Python 3.14 on unmodifieddevelop). The file-length check passes (widget_routes.pyis 294 lines).