ruff: use single quotes for multiline strings

This commit is contained in:
Yu Watanabe
2026-05-18 02:32:39 +09:00
parent aa0f03eb03
commit c54decc406
6 changed files with 53 additions and 47 deletions
+8 -2
View File
@@ -1,6 +1,12 @@
target-version = "py39"
line-length = 109
lint.select = ["E", "F", "I", "UP"]
lint.select = ["E", "F", "I", "Q", "UP"]
[format]
quote-style = "single"
# The formatter prefers double quotes for multiline quotes,
# Hence, let's make the formatter not change quotations.
quote-style = "preserve"
[lint.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "single"
+4 -4
View File
@@ -16,13 +16,13 @@ BYTES_PER_LINE = 16
hwids = ukify.parse_hwid_dir(Path(sys.argv[1]))
print(
"""/* SPDX-License-Identifier: LGPL-2.1-or-later */
'''/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stddef.h>
#include <stdint.h>
// NOLINTNEXTLINE(misc-use-internal-linkage)
const uint8_t hwids_section_data[] = {
""",
''',
end='',
)
@@ -34,9 +34,9 @@ for i, b in enumerate(hwids):
print('')
print(
"""};
'''};
// NOLINTNEXTLINE(misc-use-internal-linkage)
const size_t hwids_section_len =""",
const size_t hwids_section_len =''',
f'{len(hwids)};',
)
+2 -2
View File
@@ -30,12 +30,12 @@ with open(header) as file:
enumName = ''
if output == 'doc':
print("""\
print('''\
<?xml version="1.0"?>
<!DOCTYPE bpf-delegates PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<para>
""")
''')
for line in file:
line = line.strip()
+12 -12
View File
@@ -120,43 +120,43 @@ def process_source_file(file: IO[str]) -> None:
continue
print("""/* SPDX-License-Identifier: LGPL-2.1-or-later */
print('''/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
""")
''')
for header in sys.argv[3:]:
with open(header, 'r') as f:
if process_header_file(f):
print('#include "{}"'.format(header.split('/')[-1]))
print("""
print('''
/* We want to check deprecated symbols too, without complaining */
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
""")
''')
print("""
print('''
struct symbol {
const char *name;
const void *symbol;
};
static struct symbol symbols_from_sym[] = {""")
static struct symbol symbols_from_sym[] = {''')
with open(sys.argv[1], 'r') as f:
process_sym_file(f)
print(""" {}
}, symbols_from_header[] = {""")
print(''' {}
}, symbols_from_header[] = {''')
for header in sys.argv[3:]:
with open(header, 'r') as f:
print(process_header_file(f), end='')
print(""" {}
}, symbols_from_source[] = {""")
print(''' {}
}, symbols_from_source[] = {''')
for dirpath, _, filenames in sorted(os.walk(sys.argv[2])):
for filename in sorted(filenames):
@@ -168,7 +168,7 @@ for dirpath, _, filenames in sorted(os.walk(sys.argv[2])):
with p.open('rt') as f:
process_source_file(f)
print(""" {}
print(''' {}
};
static int sort_callback(const void *a, const void *b) {
@@ -239,4 +239,4 @@ int main(void) {
}
return n_error == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}""")
}''')
+7 -7
View File
@@ -599,7 +599,7 @@ class SystemdSbSign(SignTool):
)
cmd = [
tool,
"sign",
'sign',
'--private-key', opts.sb_key,
'--certificate', opts.sb_cert,
*(
@@ -1305,15 +1305,15 @@ def parse_efifw_dir(path: Path) -> bytes:
return efifw_blob
STUB_SBAT = """\
STUB_SBAT = '''\
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
uki,1,UKI,uki,1,https://uapi-group.org/specifications/specs/unified_kernel_image/
"""
'''
ADDON_SBAT = """\
ADDON_SBAT = '''\
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
uki-addon,1,UKI Addon,addon,1,https://www.freedesktop.org/software/systemd/man/latest/systemd-stub.html
"""
'''
def make_uki(opts: UkifyConfig) -> None:
@@ -2326,11 +2326,11 @@ def create_parser() -> argparse.ArgumentParser:
p = argparse.ArgumentParser(
description='Build and sign Unified Kernel Images',
usage='\n '
+ textwrap.dedent("""\
+ textwrap.dedent('''\
ukify {b}build{e} [--linux=LINUX] [--initrd=INITRD] [options…]
ukify {b}genkey{e} [options…]
ukify {b}inspect{e} FILE… [options…]
""").format(b=Style.bold, e=Style.reset),
''').format(b=Style.bold, e=Style.reset),
allow_abbrev=False,
add_help=False,
epilog='\n '.join(('config file:', *config_example())),
@@ -21,13 +21,13 @@ from pathlib import Path
from types import FrameType
from typing import Optional
EMERGENCY_EXIT_DROPIN = """\
EMERGENCY_EXIT_DROPIN = '''\
[Unit]
Wants=emergency-exit.service
"""
'''
EMERGENCY_EXIT_SERVICE = """\
EMERGENCY_EXIT_SERVICE = '''\
[Unit]
DefaultDependencies=no
Conflicts=shutdown.target
@@ -38,7 +38,7 @@ FailureAction=exit
[Service]
ExecStart=false
"""
'''
@dataclasses.dataclass(frozen=True)
@@ -472,43 +472,43 @@ def main() -> None:
name = args.name + (f'-{i}' if (i := os.getenv('MESON_TEST_ITERATION')) else '')
dropin = textwrap.dedent(
"""\
'''\
[Service]
StandardOutput=journal+console
"""
'''
)
if not shell:
dropin += textwrap.dedent(
"""
'''
[Unit]
SuccessAction=exit
SuccessActionExitStatus=123
"""
'''
)
if os.getenv('TEST_MATCH_SUBTEST'):
dropin += textwrap.dedent(
f"""
f'''
[Service]
Environment=TEST_MATCH_SUBTEST={os.environ['TEST_MATCH_SUBTEST']}
"""
'''
)
if os.getenv('TEST_MATCH_TESTCASE'):
dropin += textwrap.dedent(
f"""
f'''
[Service]
Environment=TEST_MATCH_TESTCASE={os.environ['TEST_MATCH_TESTCASE']}
"""
'''
)
if os.getenv('TEST_RUN_DFUZZER'):
dropin += textwrap.dedent(
f"""
f'''
[Service]
Environment=TEST_RUN_DFUZZER={os.environ['TEST_RUN_DFUZZER']}
"""
'''
)
if os.getenv('TEST_JOURNAL_USE_TMP', '0') == '1':
@@ -525,14 +525,14 @@ def main() -> None:
if not sys.stdin.isatty():
dropin += textwrap.dedent(
"""
'''
[Unit]
FailureAction=exit
"""
'''
)
elif not shell:
dropin += textwrap.dedent(
"""
'''
[Unit]
Wants=multi-user.target getty-pre.target
Before=getty-pre.target
@@ -546,17 +546,17 @@ def main() -> None:
IgnoreSIGPIPE=no
# bash ignores SIGTERM
KillSignal=SIGHUP
"""
'''
)
if sys.stdin.isatty():
dropin += textwrap.dedent(
"""
'''
[Service]
ExecStartPre=/usr/lib/systemd/tests/testdata/integration-test-setup.sh setup
ExecStopPost=/usr/lib/systemd/tests/testdata/integration-test-setup.sh finalize
StateDirectory=%N
"""
'''
)
if args.rtc: