Conversation
📝 WalkthroughWalkthroughThe PR adds node aliases, phandle support, and C 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
Buildscripts/DevicetreeCompiler/source/models.py (1)
8-12: Makenode_aliasoptional to reflect missing-alias cases.Aliases are optional in the grammar/transformer flow, so
node_aliascan beNone. Consider typing it as optional (with a default) to match actual usage and avoid misleading type hints.🔧 Suggested typing adjustment
-from dataclasses import dataclass +from dataclasses import dataclass +from typing import Optional @@ class Device: node_name: str - node_alias: str + node_alias: Optional[str] = None properties: list devices: listBuildscripts/DevicetreeCompiler/source/generator.py (1)
13-17: Consider defensive sanitization if node names may contain special characters in future.Current DTS files in this codebase use only simple identifiers (alphanumeric, hyphens, underscores), so the current implementation is sufficient. However, if DTS node names may contain characters like
@or/in the future (or from external device trees), the function should normalize all non-identifier characters. Usingnode_aliasas a fallback would also be safer where available.🔧 Optional defensive normalization
+import re @@ def get_device_node_name_safe(device: Device): if device.node_name == "/": return "root" - else: - return device.node_name.replace("-", "_") + name = device.node_alias or device.node_name + return re.sub(r"[^A-Za-z0-9_]", "_", name)
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
Buildscripts/DevicetreeCompiler/source/models.py (1)
8-11: Makenode_aliasoptional to match the grammar.Aliases are optional and the transformer can pass
None. Typing it as optional (with a default) avoids type-checker noise and clarifies intent.♻️ Suggested typing tweak
-from dataclasses import dataclass +from dataclasses import dataclass +from typing import Optional @@ class Device: node_name: str - node_alias: str + node_alias: Optional[str] = None properties: list devices: listBuildscripts/DevicetreeCompiler/source/transformer.py (1)
33-41: Drop the unused loop index indevice().
indexis unused; a direct iteration (or renaming to_) avoids the B007 warning.♻️ Suggested cleanup
- for index, item in enumerate(tokens): + for item in tokens:
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Buildscripts/DevicetreeCompiler/source/transformer.py (1)
14-17: RemoveNodeNameAndAlias— it's unused across the repository.This dataclass is defined but never referenced anywhere in the codebase. Removing it eliminates dead code and avoids maintaining an unused public API surface.
Added support for device aliases and phandle type.,
Summary by CodeRabbit
New Features
Improvements
Other