]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ruff: use single quotes for multiline strings
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 20 Feb 2026 21:14:53 +0000 (06:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 17 May 2026 17:32:39 +0000 (02:32 +0900)
ruff.toml
src/boot/generate-hwids-section.py
src/core/generate-bpf-delegate-configs.py
src/test/generate-sym-test.py
src/ukify/ukify.py
test/integration-tests/integration-test-wrapper.py

index 6c0ec6ceb84bb067e895ea07a4afb8bb58a65bec..d4b77fb1e724b0afe30ac471616eab13cfca682a 100644 (file)
--- a/ruff.toml
+++ b/ruff.toml
@@ -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"
index cfe6aea739aa347d42d8ad0ddb98f3c4c08e48a3..df929af3b764d8d2992669be1a54ddd0a7316fcf 100755 (executable)
@@ -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)};',
 )
index 200c913b8a8264d976a88cfc6ea073f24ae036c0..4e4a54322a4804782d4a298c57a37df92d3ac0cd 100755 (executable)
@@ -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()
index b8d64d623f04f19e30f151c30ce4109aa71ce690..aa6c916fc7c92693271a1a9230658e57337f720f 100755 (executable)
@@ -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;
-}""")
+}''')
index 03d475e5e763e37cb5a6f2e3feeb9cb9e0e0e03f..11374f607dd51dea1dcc505ba0d0045268812918 100755 (executable)
@@ -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())),
index 69b4333fee3bd7c2c83fc96ebd14cedd2f6da5be..38d0415a1bbf2b58803aaeba1f9a8f8248d67b5c 100755 (executable)
@@ -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: