Hi,
I missed this discussion and the patch that applied the formatting in various subdirectories like libc++. I just wanted to give some feedback regarding the results that Black generates. In various places where we had “repetitive” code that was meant to be aligned together, Black generated something quite difficult to read that lost useful formatting properties of the original code. Is it possible to turn off Black for a local scope like // clang-format off?
One example of this is here: ⚙ D150763 [NFC][Py Reformat] Reformat python files in libcxx/libcxxabi
The original code was:
Parameter(name='use_sanitizer', choices=['', 'Address', 'HWAddress', 'Undefined', 'Memory', 'MemoryWithOrigins', 'Thread', 'DataFlow', 'Leaks'], type=str, default='',
help="An optional sanitizer to enable when building and running the test suite.",
actions=lambda sanitizer: filter(None, [
AddFlag('-g -fno-omit-frame-pointer') if sanitizer else None,
AddFlag('-fsanitize=undefined -fno-sanitize=float-divide-by-zero -fno-sanitize-recover=all') if sanitizer == 'Undefined' else None,
AddFeature('ubsan') if sanitizer == 'Undefined' else None,
AddFlag('-fsanitize=address') if sanitizer == 'Address' else None,
AddFeature('asan') if sanitizer == 'Address' else None,
AddFlag('-fsanitize=hwaddress') if sanitizer == 'HWAddress' else None,
AddFeature('hwasan') if sanitizer == 'HWAddress' else None,
AddFlag('-fsanitize=memory') if sanitizer in ['Memory', 'MemoryWithOrigins'] else None,
AddFeature('msan') if sanitizer in ['Memory', 'MemoryWithOrigins'] else None,
AddFlag('-fsanitize-memory-track-origins') if sanitizer == 'MemoryWithOrigins' else None,
AddFlag('-fsanitize=thread') if sanitizer == 'Thread' else None,
AddFeature('tsan') if sanitizer == 'Thread' else None,
AddFlag('-fsanitize=dataflow') if sanitizer == 'DataFlow' else None,
AddFlag('-fsanitize=leaks') if sanitizer == 'Leaks' else None,
AddFeature('sanitizer-new-delete') if sanitizer in ['Address', 'HWAddress', 'Memory', 'MemoryWithOrigins', 'Thread'] else None,
])),
The new code is:
Parameter(
name="use_sanitizer",
choices=[
"",
"Address",
"HWAddress",
"Undefined",
"Memory",
"MemoryWithOrigins",
"Thread",
"DataFlow",
"Leaks",
],
type=str,
default="",
help="An optional sanitizer to enable when building and running the test suite.",
actions=lambda sanitizer: filter(
None,
[
AddFlag("-g -fno-omit-frame-pointer") if sanitizer else None,
AddFlag(
"-fsanitize=undefined -fno-sanitize=float-divide-by-zero -fno-sanitize-recover=all"
)
if sanitizer == "Undefined"
else None,
AddFeature("ubsan") if sanitizer == "Undefined" else None,
AddFlag("-fsanitize=address") if sanitizer == "Address" else None,
AddFeature("asan") if sanitizer == "Address" else None,
AddFlag("-fsanitize=hwaddress") if sanitizer == "HWAddress" else None,
AddFeature("hwasan") if sanitizer == "HWAddress" else None,
AddFlag("-fsanitize=memory")
if sanitizer in ["Memory", "MemoryWithOrigins"]
else None,
AddFeature("msan")
if sanitizer in ["Memory", "MemoryWithOrigins"]
else None,
AddFlag("-fsanitize-memory-track-origins")
if sanitizer == "MemoryWithOrigins"
else None,
AddFlag("-fsanitize=thread") if sanitizer == "Thread" else None,
AddFeature("tsan") if sanitizer == "Thread" else None,
AddFlag("-fsanitize=dataflow") if sanitizer == "DataFlow" else None,
AddFlag("-fsanitize=leaks") if sanitizer == "Leaks" else None,
AddFeature("sanitizer-new-delete")
if sanitizer
in ["Address", "HWAddress", "Memory", "MemoryWithOrigins", "Thread"]
else None,
],
),
),