fix: import design system components - #179
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the public examples/design_system example by switching it to the supported {% from ... import ... %} component-library pattern (since {% include %} does not export defs into the caller’s scope) and ensures the standard smoke suite can load examples that use either run.py or app.py.
Changes:
- Add
design_systemto the curatedtests/test_examples.pysmoke inventory. - Update the smoke loader to import either
run.pyor (if absent)app.py. - Replace
{% include %}-based component loading in the design-system page with explicit{% from ... import ... %}imports.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/test_examples.py |
Adds design_system to smoke coverage and updates the loader to support app.py-based examples. |
examples/design_system/templates/page.html |
Imports button, card, and alert defs explicitly so component names are available in-page. |
Comment on lines
+40
to
46
| module_path = EXAMPLES_DIR / name / "run.py" | ||
| if not module_path.exists(): | ||
| module_path = EXAMPLES_DIR / name / "app.py" | ||
| spec = importlib.util.spec_from_file_location( | ||
| f"examples.{name}.{module_path.stem}", module_path | ||
| ) | ||
| mod = importlib.util.module_from_spec(spec) |
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.
Summary
button,card, andalertdefinitions explicitly in the design-system pagerun.pyorapp.pydesign_systemto the standard smoke inventoryRoot cause
Kida includes render a template in an isolated scope; they do not export definitions into the caller. The example relied on three
{% include %}statements to make component names available, so importingapp.pyfailed withUndefinedError: cardbefore any colocated assertion could run.Impact
The public design-system example runs again and demonstrates the supported
{% from ... import ... %}component-library pattern. Its import-time render is now exercised by the normaltests/suite, making this regression visible in CI while the broader example-gate work in #140 remains separate.Validation
python -m pytest tests/test_examples.py -q— 15 passedpython -m pytest examples/design_system -q— 12 passedpython -m pytest examples -q— 147 passed, with one upstream Starlette deprecation warninggit diff --checkRelated to #140.