← index #10751Issue #8070
Related · high · value 0.423
QUERY · ISSUE

codeformat.py bug

openby mbedNoobNinjaopened 2023-02-14updated 2024-09-01
bug

Description:

When codeformat.py formats *.h or *.c files (#10595) , it reduces file content by deleting not only formating symbols and whitespaces but also the code being formated!

before_codeformat.txt
after_codeformat.txt

and while working on before_codeformat.h codformat.py gives the folowing error:

Parsing: ..\ports\renesas-ra\boards\VK_RA4W1\ra_cfg\fsp_cfg\bsp\bsp_cfg.h as language C
Traceback (most recent call last):
   File "D:\micropython\tools\codeformat.py", line 218, in <module>
     main()
   File "D:\micropython\tools\codeformat.py", line 205, in main
     fixup_c(file)
   File "D:\micropython\tools\codeformat.py", line 136, in fixup_c
     if dedent_stack[-1] >= 0:
        ~~~~~~~~~~~~^^^^
IndexError: list index out of range

Environment:

OS Win 10 (22H2)
Uncrustify 0.72.0_f
Python 3.11.1
Package Version
black 22.12.0
click 8.1.3
colorama 0.4.6
mypy-extensions 0.4.3
pathspec 0.11.0
pip 23.0
platformdirs 2.6.2
pyserial 3.5
setuptools 65.5.0
CANDIDATE · ISSUE

build system: New code formatting errors flagged in old code.

closedby robert-hhopened 2021-12-08updated 2021-12-08

One of my latest update to a PR caused code formatting error in files not in any way related to that PR and files, being unchanged since quite a while. These files are:

extmod/uasyncio/event.py
ports/stm32/make-stmconst.py
tests/extmod/utimeq1.py
tools/pydfu.py

The flagged errors are in all cases obsolete empty lines. Was something changed in the build system?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied