Quote number-like device names in generated YAML - #2841
Conversation
|
@esphbot review |
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2841 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 294 294
Lines 25436 25436
=======================================
Hits 25374 25374
Misses 62 62
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No blocking issues were identified; only a minor comment-convention nit remains.
Review effort: Lite
Findings: None
What changed in this PR
Fixes YAML generation for numeric-like device names by safely quoting them.
Changes:
- Applies
_safe_yaml_scalarto generated names. - Adds regression coverage for generators and device creation.
- Preserves plain formatting for normal slugs.
| File | Description |
|---|---|
tests/test_device_yaml.py |
Tests name handling across YAML generators. |
tests/controllers/devices/test_create.py |
Tests creating a device named 8266. |
esphome_device_builder/helpers/device_yaml/_generation.py |
Safely renders generated names. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
PR Review — Quote number-like device names in generated YAMLMerge-ready. The fix is small and correct, and it closes the int-coercion hole in every generator that writes Strengths:
No blocking or non-blocking issues found. Checklist
Automated review by Kōan (Claude) |
esphbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
What does this implement/fix?
Creating a device with an all digit name like
8266failed validation, because the generators wrotename: 8266unquoted and esphome read it back as an int. The name now goes through_safe_yaml_scalarlikefriendly_namealready does, so number like names get quoted and normal slugs stay plain.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.index.json/definitions/components/*.jsonhave not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.