diff --git a/apport/crashdb_impl/debian.py b/apport/crashdb_impl/debian.py index 2a35830f7..8766c2e3c 100644 --- a/apport/crashdb_impl/debian.py +++ b/apport/crashdb_impl/debian.py @@ -8,7 +8,6 @@ # option) any later version. See http://www.gnu.org/copyleft/gpl.html for # the full text of the license. - import email.mime.text import smtplib import tempfile diff --git a/apport/crashdb_impl/github.py b/apport/crashdb_impl/github.py index 83ec0e3f1..906564676 100644 --- a/apport/crashdb_impl/github.py +++ b/apport/crashdb_impl/github.py @@ -87,7 +87,7 @@ def __enter__(self): self.__authentication_data = { "client_id": self.__client_id, - "device_code": f'{response["device_code"]}', + "device_code": f"{response['device_code']}", "grant_type": "urn:ietf:params:oauth:grant-type:device_code", } self.__cooldown = response["interval"] diff --git a/apport/hookutils.py b/apport/hookutils.py index a17935677..6843e31aa 100644 --- a/apport/hookutils.py +++ b/apport/hookutils.py @@ -327,10 +327,7 @@ def attach_alsa_old(report): codec = os.path.basename(codecpath) for name in os.listdir(codecpath): path = os.path.join(codecpath, name) - key = ( - f"Card{card}.Codecs" - f".{path_to_key(codec)}.{path_to_key(name)}" - ) + key = f"Card{card}.Codecs.{path_to_key(codec)}.{path_to_key(name)}" attach_file(report, path, key) diff --git a/apport/report.py b/apport/report.py index edcb463ee..b8c70ee82 100644 --- a/apport/report.py +++ b/apport/report.py @@ -1446,10 +1446,7 @@ def _get_python_exception_title(self) -> str | None: if len(trace) < 1: return None if len(trace) < 3: - return ( - f"{os.path.basename(self['ExecutablePath'])}" - f" crashed with {trace[0]}" - ) + return f"{os.path.basename(self['ExecutablePath'])} crashed with {trace[0]}" trace_re = re.compile(r'^\s*File\s*"(\S+)".* in (.+)$') i = len(trace) - 1 diff --git a/apport/ui.py b/apport/ui.py index 02625972e..30687975a 100644 --- a/apport/ui.py +++ b/apport/ui.py @@ -363,8 +363,7 @@ def __init__(self, argv: list[str]) -> None: except ImportError as error: # this can happen while upgrading python packages apport.logging.fatal( - "Could not import module, is a package upgrade in progress?" - " Error: %s", + "Could not import module, is a package upgrade in progress? Error: %s", str(error), ) except KeyError: diff --git a/bin/apport-retrace b/bin/apport-retrace index 2e54db4e8..935b6375f 100755 --- a/bin/apport-retrace +++ b/bin/apport-retrace @@ -128,8 +128,7 @@ def parse_args(argv: list[str]) -> argparse.Namespace: "--dynamic-origins", action="store_true", help=_( - "Create and use third-party repositories from origins specified" - " in reports" + "Create and use third-party repositories from origins specified in reports" ), ) argparser.add_argument( @@ -683,8 +682,7 @@ Thank you for your understanding, and sorry for the inconvenience! crashdb.mark_retrace_failed(crashid, invalid_msg) else: apport.log( - "Report has no crash signature," - " so retrace is flawed", + "Report has no crash signature, so retrace is flawed", options.timestamps, ) crashdb.mark_retrace_failed(crashid) diff --git a/data/apport b/data/apport index d4119aa26..7a4316c96 100755 --- a/data/apport +++ b/data/apport @@ -554,8 +554,7 @@ def forward_crash_to_container( with open("uid_map", "r", encoding="utf-8", opener=proc_host_pid_opener) as fd: if not apport.fileutils.search_map(fd, task_uid): logger.error( - "host pid %s crashed in a container" - " with no access to the binary", + "host pid %s crashed in a container with no access to the binary", options.global_pid, ) return @@ -567,8 +566,7 @@ def forward_crash_to_container( with open("gid_map", "r", encoding="utf-8", opener=proc_host_pid_opener) as fd: if not apport.fileutils.search_map(fd, task_gid): logger.error( - "host pid %s crashed in a container" - " with no access to the binary", + "host pid %s crashed in a container with no access to the binary", options.global_pid, ) return @@ -925,8 +923,7 @@ def process_crash_from_kernel(options: argparse.Namespace) -> int: return process_crash_from_kernel_with_proc_pid(options, proc_pid) except FileNotFoundError as error: logging.getLogger().error( - "%s not found. " - "Cannot collect crash information for process %i any more.", + "%s not found. Cannot collect crash information for process %i any more.", error.filename, options.pid, ) diff --git a/data/general-hooks/parse_segv.py b/data/general-hooks/parse_segv.py index b037c76fb..d09b7525b 100644 --- a/data/general-hooks/parse_segv.py +++ b/data/general-hooks/parse_segv.py @@ -331,8 +331,7 @@ def report(self): # Handle I/O port operations if self.insn in {"out", "in"} and not understood: msg = ( - f"disallowed I/O port operation" - f" on port {self.register_value(self.src)}" + f"disallowed I/O port operation on port {self.register_value(self.src)}" ) reason.append(msg) details.append(msg) diff --git a/problem_report.py b/problem_report.py index 8e77afcbd..f2f361463 100644 --- a/problem_report.py +++ b/problem_report.py @@ -45,8 +45,7 @@ class MalformedProblemReport(ValueError): def __init__(self, message: str, *args: object): super().__init__( - f"Malformed problem report: {message}." - f" Is this a proper .crash text file?", + f"Malformed problem report: {message}. Is this a proper .crash text file?", *args, ) diff --git a/tests/integration/test_apport_unpack.py b/tests/integration/test_apport_unpack.py index e318674e9..a4549fc5e 100644 --- a/tests/integration/test_apport_unpack.py +++ b/tests/integration/test_apport_unpack.py @@ -131,8 +131,7 @@ def test_broken_core_dump(self) -> None: """Test unpacking a report file that has a malformed CoreDump entry.""" with tempfile.NamedTemporaryFile("wb") as report_file: report_file.write( - b"CoreDump: base64\n H4sICAAAAAAC/0NvcmVEdW1wAA==\n" - b" 7Z0LYFPV/cdP0rQ\n" + b"CoreDump: base64\n H4sICAAAAAAC/0NvcmVEdW1wAA==\n 7Z0LYFPV/cdP0rQ\n" ) report_file.flush() process = self._call_apport_unpack([report_file.name, self.unpack_dir]) diff --git a/tests/integration/test_crashdb_launchpad.py b/tests/integration/test_crashdb_launchpad.py index 3710ed0a0..908907494 100644 --- a/tests/integration/test_crashdb_launchpad.py +++ b/tests/integration/test_crashdb_launchpad.py @@ -153,8 +153,7 @@ def get_python_report(self) -> int: r.add_user_info() self.assertEqual( r.standard_title(), - "foo crashed with NameError in fuzz():" - " global name 'weird' is not defined", + "foo crashed with NameError in fuzz(): global name 'weird' is not defined", ) return self._create_bug_from_report("Python", r) @@ -189,8 +188,7 @@ def get_uncommon_description_report(self, force_fresh: bool = False) -> None: target=self.crashdb.lp_distro, ) sys.stderr.write( - f"(Created uncommon description:" - f" https://{self.hostname}/bugs/{bug.id}) " + f"(Created uncommon description: https://{self.hostname}/bugs/{bug.id}) " ) return bug.id @@ -855,8 +853,7 @@ def test_project(self): r.add_user_info() self.assertEqual( r.standard_title(), - "foo crashed with NameError in fuzz():" - " global name 'weird' is not defined", + "foo crashed with NameError in fuzz(): global name 'weird' is not defined", ) # file it diff --git a/tests/integration/test_dupdb_admin.py b/tests/integration/test_dupdb_admin.py index ae6868228..8e77622ce 100644 --- a/tests/integration/test_dupdb_admin.py +++ b/tests/integration/test_dupdb_admin.py @@ -84,8 +84,7 @@ def test_dump_database(self) -> None: lines = stdout.rstrip().split("\n") self.assertEqual(len(lines), 2, lines) self.assertIn( - "0: /bin/crash:11:foo_bar:d01:raise::__frob" - " [open]", + "0: /bin/crash:11:foo_bar:d01:raise::__frob [open]", lines[0], ) self.assertIn("2: /usr/bin/broken:11:h:g:f:e:d [fixed in: 42]", lines[1]) diff --git a/tests/integration/test_fileutils.py b/tests/integration/test_fileutils.py index f8660adb4..8852d7635 100644 --- a/tests/integration/test_fileutils.py +++ b/tests/integration/test_fileutils.py @@ -370,7 +370,7 @@ def test_get_config(self) -> None: # nonempty f.write( - b"[main]\none=1\ntwo = TWO\nb1 = 1\nb2=False\n" b"[spethial]\none= 99\n" + b"[main]\none=1\ntwo = TWO\nb1 = 1\nb2=False\n[spethial]\none= 99\n" ) f.flush() self.assertIsNone(apport.fileutils.get_config("main", "foo")) diff --git a/tests/integration/test_problem_report.py b/tests/integration/test_problem_report.py index 080182bf9..842c0422f 100644 --- a/tests/integration/test_problem_report.py +++ b/tests/integration/test_problem_report.py @@ -88,7 +88,7 @@ def test_write_append(self) -> None: WhiteSpace: foo bar baz - blip{' '} + blip{" "} Extra: appended """ ), diff --git a/tests/integration/test_python_crashes.py b/tests/integration/test_python_crashes.py index 55dc7e23a..ee1f931cf 100644 --- a/tests/integration/test_python_crashes.py +++ b/tests/integration/test_python_crashes.py @@ -68,7 +68,7 @@ def _test_crash( os.write( fd, f"""\ -#!/usr/bin/env {os.getenv('PYTHON', 'python3')} +#!/usr/bin/env {os.getenv("PYTHON", "python3")} import apport_python_hook apport_python_hook.install() @@ -386,7 +386,7 @@ def test_ignoring(self): fd, textwrap.dedent( f"""\ - #!/usr/bin/env {os.getenv('PYTHON', 'python3')} + #!/usr/bin/env {os.getenv("PYTHON", "python3")} import apport_python_hook apport_python_hook.install() diff --git a/tests/integration/test_recoverable_problem.py b/tests/integration/test_recoverable_problem.py index 7fdbb10ec..55b9d4935 100644 --- a/tests/integration/test_recoverable_problem.py +++ b/tests/integration/test_recoverable_problem.py @@ -46,8 +46,7 @@ def _wait_for_report(self) -> str: time.sleep(0.1) seconds += 0.1 self.fail( - f"timeout while waiting for .crash file to be created" - f" in {self.report_dir}." + f"timeout while waiting for .crash file to be created in {self.report_dir}." ) @unittest.mock.patch("os.listdir") diff --git a/tests/integration/test_report.py b/tests/integration/test_report.py index 34a1810e4..5de02b3eb 100644 --- a/tests/integration/test_report.py +++ b/tests/integration/test_report.py @@ -242,7 +242,7 @@ def test_add_proc_info(self) -> None: testscript.write_text( textwrap.dedent( f"""\ - #!/usr/bin/{os.getenv('PYTHON', 'python3')} + #!/usr/bin/{os.getenv("PYTHON", "python3")} import sys sys.stdin.readline() """ diff --git a/tests/integration/test_signal_crashes.py b/tests/integration/test_signal_crashes.py index ee31d3b4d..0b3ba701f 100644 --- a/tests/integration/test_signal_crashes.py +++ b/tests/integration/test_signal_crashes.py @@ -1229,8 +1229,7 @@ def do_crash( os.unlink(core_path) except OSError as error: sys.stderr.write( - f"WARNING: cannot clean up core file {core_path}:" - f" {str(error)}\n" + f"WARNING: cannot clean up core file {core_path}: {str(error)}\n" ) self.fail("leaves unexpected core file behind") diff --git a/tests/integration/test_ui.py b/tests/integration/test_ui.py index 414e2b1cc..546c15416 100644 --- a/tests/integration/test_ui.py +++ b/tests/integration/test_ui.py @@ -908,7 +908,6 @@ def _gen_test_crash(self) -> apport.Report: env={"HOME": self.workdir}, stdout=subprocess.PIPE, ) as gdb: - try: pid = wait_for_process_to_appear( self.TEST_EXECUTABLE, @@ -1996,9 +1995,7 @@ def test_run_symptom(self, stderr_mock: MagicMock) -> None: # working noninteractive script self._write_symptom_script( "itching.py", - "def run(report, ui):\n" - ' report["itch"] = "scratch"\n' - ' return "bash"\n', + 'def run(report, ui):\n report["itch"] = "scratch"\n return "bash"\n', ) self.ui = UserInterfaceMock(["ui-test", "-s", "itching"]) self.ui.present_details_response = apport.ui.Action(report=True) diff --git a/tests/system/test_packaging_apt_dpkg.py b/tests/system/test_packaging_apt_dpkg.py index f02404780..1b34d599d 100644 --- a/tests/system/test_packaging_apt_dpkg.py +++ b/tests/system/test_packaging_apt_dpkg.py @@ -742,7 +742,7 @@ def test_create_sources_for_a_named_ppa( if {"deb", "deb-src"} == set(e.types) and "jammy" in e.suites and "main" in e.comps - and "http://ppa.launchpad.net/" "daisy-pluckers/daisy-seeds/ubuntu" in e.uris + and "http://ppa.launchpad.net/daisy-pluckers/daisy-seeds/ubuntu" in e.uris ] assert [ e @@ -750,7 +750,7 @@ def test_create_sources_for_a_named_ppa( if "deb" in e.types and "jammy" in e.suites and "main/debug" in e.comps - and "http://ppa.launchpad.net/" "daisy-pluckers/daisy-seeds/ubuntu" in e.uris + and "http://ppa.launchpad.net/daisy-pluckers/daisy-seeds/ubuntu" in e.uris ] trusted_gpg_d = pathlib.Path(rootdir) / "etc" / "apt" / "trusted.gpg.d" @@ -781,8 +781,8 @@ def test_create_sources_for_an_unnamed_ppa( if {"deb", "deb-src"} == set(e.types) and "jammy" in e.suites and "main" in e.comps - and "http://ppa.launchpad.net/" - "apport-hackers/apport-autopkgtests/ubuntu" in e.uris + and "http://ppa.launchpad.net/apport-hackers/apport-autopkgtests/ubuntu" + in e.uris ] assert [ e @@ -790,8 +790,8 @@ def test_create_sources_for_an_unnamed_ppa( if "deb" in e.types and "jammy" in e.suites and "main/debug" in e.comps - and "http://ppa.launchpad.net/" - "apport-hackers/apport-autopkgtests/ubuntu" in e.uris + and "http://ppa.launchpad.net/apport-hackers/apport-autopkgtests/ubuntu" + in e.uris ] trusted_gpg_d = pathlib.Path(rootdir) / "etc" / "apt" / "trusted.gpg.d" diff --git a/tests/system/test_python_crashes.py b/tests/system/test_python_crashes.py index 2632baea5..18edf0f95 100644 --- a/tests/system/test_python_crashes.py +++ b/tests/system/test_python_crashes.py @@ -66,7 +66,7 @@ def _test_crash(self, extracode: str) -> str: os.write( fd, f"""\ -#!/usr/bin/env {os.getenv('PYTHON', 'python3')} +#!/usr/bin/env {os.getenv("PYTHON", "python3")} import apport_python_hook apport_python_hook.install() @@ -224,8 +224,7 @@ def test_dbus_service_other_error(self) -> None: signature = pr.crash_signature() assert signature self.assertIn( - "dbus.exceptions.DBusException" - "(org.freedesktop.DBus.Error.UnknownMethod):", + "dbus.exceptions.DBusException(org.freedesktop.DBus.Error.UnknownMethod):", signature, ) diff --git a/tests/unit/test_fileutils.py b/tests/unit/test_fileutils.py index 35a386a18..03b6b2c1a 100644 --- a/tests/unit/test_fileutils.py +++ b/tests/unit/test_fileutils.py @@ -140,9 +140,7 @@ def test_get_recent_crashes(self) -> None: # ancient report r = io.BytesIO( - b"ProblemType: Crash\n" - b"Date: Wed Aug 01 00:00:01 1990\n" - b"CrashCounter: 3\n" + b"ProblemType: Crash\nDate: Wed Aug 01 00:00:01 1990\nCrashCounter: 3\n" ) self.assertEqual(apport.fileutils.get_recent_crashes(r), 0) diff --git a/tests/unit/test_problem_report.py b/tests/unit/test_problem_report.py index 9dedfd099..49c56bc03 100644 --- a/tests/unit/test_problem_report.py +++ b/tests/unit/test_problem_report.py @@ -167,7 +167,7 @@ def test_load(self) -> None: WhiteSpace: foo bar baz - blip{' '} + blip{" "} """ ) pr = problem_report.ProblemReport() @@ -275,11 +275,7 @@ def test_load_invalid_utf8(self) -> None: def test_load_incorrect_padding(self) -> None: """Throw exception when base64 encoded data has incorrect padding.""" report = problem_report.ProblemReport() - content = ( - b"CoreDump: base64\n" - b" H4sICAAAAAAC/0NvcmVEdW1wAA==\n" - b" 7Z0LYFPV/cdP0rQ\n" - ) + content = b"CoreDump: base64\n H4sICAAAAAAC/0NvcmVEdW1wAA==\n 7Z0LYFPV/cdP0rQ\n" with io.BytesIO(content) as report_file: with self.assertRaisesRegex( problem_report.MalformedProblemReport, @@ -620,9 +616,9 @@ def test_write_mime_text(self) -> None: fourth fifth LargeMultiline: - {'A' * 120} - {'B' * 90} - Largeline: {'A' * 999} + {"A" * 120} + {"B" * 90} + Largeline: {"A" * 999} Simple: bar SimpleLineEnd: bar SimpleUTF8: 1äö2Φ3 @@ -665,7 +661,7 @@ def test_write_mime_text(self) -> None: f"""\ foo bar baz - blip{' '} + blip{" "} line4 line♥5!! łıµ€ ⅝ diff --git a/tests/unit/test_report.py b/tests/unit/test_report.py index 3bb5e3ab4..9b1a87f83 100644 --- a/tests/unit/test_report.py +++ b/tests/unit/test_report.py @@ -1252,8 +1252,7 @@ def test_crash_signature_addresses(self) -> None: # all resolvable, but too short pr["Stacktrace"] = ( - "#0 0x00007f491fac5687 in kill ()" - " at ../sysdeps/unix/syscall-template.S:82" + "#0 0x00007f491fac5687 in kill () at ../sysdeps/unix/syscall-template.S:82" ) self.assertIsNone(pr.crash_signature_addresses())