mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 11:10:14 +01:00
tools/codeformat.py: Print filename + linenumber when dedenting fails.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This commit is contained in:
committed by
Damien George
parent
6e450dba7e
commit
485dac783b
@@ -75,6 +75,10 @@ TOP = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
UNCRUSTIFY_CFG = os.path.join(TOP, "tools/uncrustify.cfg")
|
||||
|
||||
|
||||
class IndentationError(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
def list_files(paths, exclusions=None, prefix=""):
|
||||
files = set()
|
||||
for pattern in paths:
|
||||
@@ -111,6 +115,10 @@ def fixup_c(filename):
|
||||
# This #-line does not need dedenting.
|
||||
dedent_stack.append(-1)
|
||||
else:
|
||||
if len(dedent_stack) == 0:
|
||||
raise IndentationError(
|
||||
f'dedent stack is empty for "{directive}" at {filename}:{line_number}'
|
||||
)
|
||||
if dedent_stack[-1] >= 0:
|
||||
# This associated #-line needs dedenting to match the #if.
|
||||
indent_diff = indent - dedent_stack[-1]
|
||||
|
||||
Reference in New Issue
Block a user