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:
Martí Bolívar 2021-04-22 11:37:54 -07:00 committed by Kumar Gala
commit a6ed7b262e

View file

@ -23,6 +23,7 @@ import os
import re import re
import sys import sys
import textwrap import textwrap
from typing import NoReturn
# NOTE: tests/test_dtlib.py is the test suite for this library. # 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 return cur
def _err(msg): def _err(msg) -> NoReturn:
raise DTError(msg) raise DTError(msg)
_escape_table = str.maketrans({ _escape_table = str.maketrans({