Skip to content

fix(cli): follow re-exported SDK names and ignore non-SDK .widget decorators in validate - #136

Merged
manish-wekan merged 1 commit into
nitrocloudofficial:developfrom
ROHIT-JR:fix/widget-routes-reexport-and-qualified-decorators
Nov 12, 2026
Merged

manish-wekan merged 1 commit into
nitrocloudofficial:developfrom
ROHIT-JR:fix/widget-routes-reexport-and-qualified-decorators

Conversation

@ROHIT-JR

Copy link
Copy Markdown
Collaborator

Follow-up to #127. Two regressions were found in the new route discovery in nitrostack/cli/widget_routes.py.

What was wrong

  1. Re-exports were not followed. If shared/__init__.py re-exports the SDK's WidgetOptions, then from shared import WidgetOptions followed 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.
  2. Any .widget decorator counted as the SDK's. @pytest.mark.widget("smoke") wrongly warned that widgets/out/smoke.html is missing.

Fix

  • Name lookup now follows re-exports through project modules (plain, aliased and multi-hop), with a guard against import cycles. A re-exported factory is still a factory. A name re-exported from a project's own class is not treated as the SDK's.
  • A widget decorator counts only if it resolves to the SDK's own: imported from nitrostack, reached through import nitrostack or nitrostack.decorators, or re-exported by a project module. pytest.mark.widget, a local def widget, and widget from another library are ignored.

Tests

13 new tests in tests/test_validate_widgets.py. 10 of them fail on the current develop and pass with this change: plain, aliased and two-hop re-exports, a re-exported factory, an end-to-end validate_widgets run for the reported case, five non-SDK .widget forms, and pytest.mark.widget next to a real @widget. The rest cover import cycles, a non-SDK re-export, and that nitrostack.widget and deco.widget are still collected.

Full suite passes locally (excluding tests/test_oauth_client.py, which fails on this machine's Python 3.14 on unmodified develop). The file-length check passes (widget_routes.py is 294 lines).

…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.
@manish-wekan
manish-wekan merged commit 416e932 into nitrocloudofficial:develop Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants