fix(scoreboards): tell the shared code where the plugin lives - #405
Merged
Conversation
Every grid-snapped font was rendering a pixel narrow on every device. The shared sports code reads this plugin's config_schema.json to tell a default font size from one the user chose: a default is snapped to the font's pixel grid, a choice is left alone. It located the schema by inspecting loaded modules, which cannot work under the real plugin loader -- PluginLoader._namespace_plugin_modules renames a plugin's modules to "_plg_<id>_<module>" and removes the original names, so nothing is left to inspect. The lookup returned nothing, every configured size then looked user-chosen, the snap was skipped, and 4x6-font.ttf drew at 6 instead of 7: 3px-wide glyphs instead of 4px. On a 256x64 panel the betting odds, the team records and the date row were hard to read. Each SportsCore now declares _PLUGIN_DIR from its own __file__, which the shared code prefers over guessing (ChuckBuilds/LEDMatrix#519). scripts/test_plugin_dir_under_loader.py stops this recurring. It reproduces the loader's sequence exactly -- import sports.py under its BARE name, then rename it away -- because that is what makes the class report __module__ == "sports" with no such entry in sys.modules. Both halves matter, and the first draft of this guard got it wrong: it imported under the namespaced name, __module__ still resolved, and it passed against the broken code. Verified the corrected version fails for all eight with the declarations removed and passes with them restored. Found by a user counting pixels on a photo of the panel. No gate here caught it: every test imported plugins directly, which leaves the bare module entry in place, and the safety harness loads plugins its own way.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Every grid-snapped font was rendering a pixel narrow, on every device.
The shared sports code reads a plugin's
config_schema.jsonto tell a default font size from one the user chose — a default gets snapped to the font's pixel grid, a choice is left alone. It located the schema by inspecting loaded modules, which cannot work under the real plugin loader:So the lookup returned nothing → every configured size looked user-chosen → the snap was skipped →
4x6-font.ttfdrew at 6 instead of 7, which is 3px-wide glyphs instead of 4px.On a 256×64 panel that made the betting odds, the team records and the date row hard to read.
Fix
Each
SportsCoredeclares_PLUGIN_DIRfrom its own__file__, which the shared code prefers over guessing. Needs core ChuckBuilds/LEDMatrix#519.The guard
scripts/test_plugin_dir_under_loader.pyreproduces the loader's sequence exactly — importsports.pyunder its bare name, then rename it away — because that combination is what makes the class report__module__ == "sports"with no such entry insys.modules.Both halves matter, and my first draft of this guard got it wrong: it imported under the namespaced name,
__module__still resolved, and it passed against the broken code. The corrected version was verified to fail for all eight with the declarations removed, and pass with them restored.How this shipped
Found by a user counting pixels on a photo of the panel — not by any gate here.
That gap is what the new guard closes.
Verified on hardware
plugin_dir=None,4x6-font.ttf@6for all six football managersplugin_dirresolves,odds=@7 detail=@7, all eight scoreboardsPatch bumps. No behaviour change beyond restoring the intended font sizes.