dtlib: type annotate _err()
Marking this NoReturn helps the type checker figure out that functions which call it are only returning valid values or failing to return. (It unfortunately doesn't always work as mypy's control flow analysis seems to treat a direct 'raise DTError(...)' differently than calling _err() in some situations, but it helps.) Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
587b3248dc
commit
a6ed7b262e
1 changed files with 2 additions and 1 deletions
|
@ -23,6 +23,7 @@ import os
|
|||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
from typing import NoReturn
|
||||
|
||||
# NOTE: tests/test_dtlib.py is the test suite for this library.
|
||||
|
||||
|
@ -1820,7 +1821,7 @@ def _root_and_path_to_node(cur, path, fullpath):
|
|||
|
||||
return cur
|
||||
|
||||
def _err(msg):
|
||||
def _err(msg) -> NoReturn:
|
||||
raise DTError(msg)
|
||||
|
||||
_escape_table = str.maketrans({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue