We'd like users of this API to know that DT.root is always a Node, and not an Optional[Node]. However, although DT.__init__ throws an exception if the resulting DT object would have no root node, static analysis can't tell that since the root instance attribute starts out as None during initialization, so checkers like mypy are convinced it's Optional[Node]. Since this is really OK, we'll quiet the type checker down by stashing the instance attribute in self._root instead, and providing a root property accessor that is annotated to return Node instead of Optional[Node]. We can tell mypy to ignore what looks like a potential None here to allow callers to treat the result as a Node. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no> |
||
|---|---|---|
| .. | ||
| src/devicetree | ||
| tests | ||
| .gitignore | ||
| requirements.txt | ||
| setup.py | ||
| tox.ini | ||