From 467a39b6028adcf15a31f83bc64b90f9598cafa8 Mon Sep 17 00:00:00 2001 From: Arnab Patra Date: Sat, 11 Jul 2026 19:28:13 +0530 Subject: [PATCH 1/5] crashdb_impl: add type annotations to memory backend --- apport/crashdb_impl/memory.py | 42 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/apport/crashdb_impl/memory.py b/apport/crashdb_impl/memory.py index f6a7cc2ba..c3cfc4d6e 100644 --- a/apport/crashdb_impl/memory.py +++ b/apport/crashdb_impl/memory.py @@ -10,6 +10,7 @@ # the full text of the license. import time +from collections.abc import Callable, Iterable from typing import Any import apport.crashdb @@ -28,7 +29,8 @@ def __init__(self, auth_file: str | None, options: dict[str, Any]) -> None: This class does not support bug patterns and authentication. """ - apport.crashdb.CrashDatabase.__init__(self, auth_file, options) + + super().__init__(auth_file, options) # reports is a list of dictionaries with keys: # report, fixed_version, dup_of, comment @@ -36,13 +38,18 @@ def __init__(self, auth_file: str | None, options: dict[str, Any]) -> None: self.unretraced: set[int] = set() self.dup_unchecked: set[int] = set() - self.upload_delay = 0.0 + self.upload_delay: float = 0.0 self.upload_msg: tuple[str, str] | None = None if "sample_data" in options: self.add_sample_data() - def upload(self, report, progress_callback=None, user_message_callback=None): + def upload( + self, + report: apport.report.Report, + progress_callback: Callable[[int, int], None] | None = None, + user_message_callback: Callable[[str, str], None] | None = None, + ) -> int: """Store the report and return a handle number (starting from 0). This does not support (nor need) progress callbacks. @@ -71,7 +78,7 @@ def upload(self, report, progress_callback=None, user_message_callback=None): return crash_id - def get_comment_url(self, report, handle): + def get_comment_url(self, report: apport.report.Report, handle: int | str) -> str: """Return http://.bugs.example.com/ for package bugs or http://bugs.example.com/ for reports without a SourcePackage. @@ -80,7 +87,7 @@ def get_comment_url(self, report, handle): return f"http://{report['SourcePackage']}.bugs.example.com/{handle}" return f"http://bugs.example.com/{handle}" - def get_id_url(self, report, crash_id): + def get_id_url(self, report: apport.report.Report, crash_id: int) -> str | None: """Return URL for a given report ID. The report is passed in case building the URL needs additional @@ -90,7 +97,7 @@ def get_id_url(self, report, crash_id): """ return self.get_comment_url(report, crash_id) - def download(self, crash_id): + def download(self, crash_id: int) -> apport.report.Report: """Download the problem report from given ID and return a Report.""" return self.reports[crash_id]["report"] @@ -115,13 +122,13 @@ def can_update(self, crash_id: int) -> bool: # pylint: disable-next=too-many-arguments,too-many-positional-arguments def update( self, - crash_id, - report, - comment, - change_description=False, - attachment_comment=None, - key_filter=None, - ): + crash_id: int, + report: apport.report.Report, + comment: str, + change_description: bool = False, + attachment_comment: str | None = None, + key_filter: Iterable[str] | None = None, + ) -> None: """Update the given report ID with all data from report. This creates a text comment with the "short" data (see @@ -194,7 +201,12 @@ def duplicate_of(self, crash_id: int) -> int | None: """ return self.reports[crash_id]["dup_of"] - def close_duplicate(self, report, crash_id, master_id): + def close_duplicate( + self, + report: apport.report.Report, + crash_id: int, + master_id: int | None, + ) -> None: """Mark a crash id as duplicate of given master ID. If master is None, id gets un-duplicated. @@ -208,7 +220,7 @@ def mark_regression(self, crash_id: int, master: int) -> None: assert self.reports[master]["fixed_version"] is not None self.reports[crash_id]["comment"] = f"regression, already fixed in #{master}" - def _mark_dup_checked(self, crash_id, report): + def _mark_dup_checked(self, crash_id: int, report: apport.report.Report) -> None: """Mark crash id as checked for being a duplicate.""" try: self.dup_unchecked.remove(crash_id) From ff1757c84f817376f97e4185c4b0abe55929b36c Mon Sep 17 00:00:00 2001 From: Arnab Patra Date: Sun, 12 Jul 2026 13:27:14 +0530 Subject: [PATCH 2/5] Trigger CI after signing CLA From 3faac3942c2e72ea5caaff387218292fa524e854 Mon Sep 17 00:00:00 2001 From: Arnab Patra Date: Sun, 12 Jul 2026 20:02:05 +0530 Subject: [PATCH 3/5] Format close_duplicate() for Black --- apport/crashdb_impl/memory.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apport/crashdb_impl/memory.py b/apport/crashdb_impl/memory.py index c3cfc4d6e..970a53acc 100644 --- a/apport/crashdb_impl/memory.py +++ b/apport/crashdb_impl/memory.py @@ -202,10 +202,7 @@ def duplicate_of(self, crash_id: int) -> int | None: return self.reports[crash_id]["dup_of"] def close_duplicate( - self, - report: apport.report.Report, - crash_id: int, - master_id: int | None, + self, report: apport.report.Report, crash_id: int, master_id: int | None ) -> None: """Mark a crash id as duplicate of given master ID. From 644a6f3176a35572096b5055497026eabd78fad4 Mon Sep 17 00:00:00 2001 From: Arnab Patra Date: Sun, 12 Jul 2026 20:09:36 +0530 Subject: [PATCH 4/5] style: remove blank line after __init__ docstring --- apport/crashdb_impl/memory.py | 1 - 1 file changed, 1 deletion(-) diff --git a/apport/crashdb_impl/memory.py b/apport/crashdb_impl/memory.py index 970a53acc..52b126f5b 100644 --- a/apport/crashdb_impl/memory.py +++ b/apport/crashdb_impl/memory.py @@ -29,7 +29,6 @@ def __init__(self, auth_file: str | None, options: dict[str, Any]) -> None: This class does not support bug patterns and authentication. """ - super().__init__(auth_file, options) # reports is a list of dictionaries with keys: From 096372b544078362c59cd76e019e393ee37c3691 Mon Sep 17 00:00:00 2001 From: Arnab Patra Date: Sun, 12 Jul 2026 20:38:01 +0530 Subject: [PATCH 5/5] typing: relax unused report parameter type --- apport/crashdb_impl/memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apport/crashdb_impl/memory.py b/apport/crashdb_impl/memory.py index 52b126f5b..1d55de856 100644 --- a/apport/crashdb_impl/memory.py +++ b/apport/crashdb_impl/memory.py @@ -201,7 +201,7 @@ def duplicate_of(self, crash_id: int) -> int | None: return self.reports[crash_id]["dup_of"] def close_duplicate( - self, report: apport.report.Report, crash_id: int, master_id: int | None + self, report: Any, crash_id: int, master_id: int | None ) -> None: """Mark a crash id as duplicate of given master ID.