Skip to content

crashdb_impl: add type annotations to memory backend - #636

Open
Arnab-atra wants to merge 7 commits into
canonical:mainfrom
Arnab-atra:typing-memory-cleanup
Open

crashdb_impl: add type annotations to memory backend#636
Arnab-atra wants to merge 7 commits into
canonical:mainfrom
Arnab-atra:typing-memory-cleanup

Conversation

@Arnab-atra

Copy link
Copy Markdown

Summary

This pull request adds type annotations to apport/crashdb_impl/memory.py.

Changes

  • Add type annotations throughout the module.
  • Replace the explicit base class constructor call with super().
  • Minor formatting improvements.
  • No functional behavior changes.

Verification

I verified the changes with:

  • python -m py_compile apport/crashdb_impl/memory.py
  • ruff check apport/crashdb_impl/memory.py
  • black --check apport/crashdb_impl/memory.py
  • mypy apport/crashdb_impl/memory.py

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.49%. Comparing base (2eacb11) to head (72726bc).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #636   +/-   ##
=======================================
  Coverage   84.48%   84.49%           
=======================================
  Files         106      106           
  Lines       21018    21019    +1     
  Branches     3195     3195           
=======================================
+ Hits        17758    17760    +2     
  Misses       2785     2785           
+ Partials      475      474    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdrung bdrung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

Can you rebase your change and squash the fixup commits into the relevant commit?

This class does not support bug patterns and authentication.
"""
apport.crashdb.CrashDatabase.__init__(self, auth_file, options)
super().__init__(auth_file, options)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this change into a separate commit since that is unrelated to type hints?

self.add_sample_data()

def upload(self, report, progress_callback=None, user_message_callback=None):
def upload(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a type hint here, a type hint should be added to the base class (and probably all other subclasses) as well to match.

return crash_id

def get_comment_url(self, report, handle):
def get_comment_url(self, report: apport.report.Report, handle: int | str) -> str:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can take a ProblemReport object as well.

Adding a type hint here, a type hint should be added to the base class (and probably all other subclasses) as well to match.

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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can take a ProblemReport object as well.

Adding a type hint here, a type hint should be added to the base class (and probably all other subclasses) as well to match.

return self.get_comment_url(report, crash_id)

def download(self, crash_id):
def download(self, crash_id: int) -> apport.report.Report:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can take a ProblemReport object as well.

Adding a type hint here, a type hint should be added to the base class (and probably all other subclasses) as well to match.

@@ -115,13 +121,13 @@ def can_update(self, crash_id: int) -> bool:
# pylint: disable-next=too-many-arguments,too-many-positional-arguments
def update(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can take a ProblemReport object as well.

Adding a type hint here, a type hint should be added to the base class (and probably all other subclasses) as well to match.

return self.reports[crash_id]["dup_of"]

def close_duplicate(self, report, crash_id, master_id):
def close_duplicate(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can take a ProblemReport object as well.

Adding a type hint here, a type hint should be added to the base class (and probably all other subclasses) as well to match.

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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can take a ProblemReport object as well.

Adding a type hint here, a type hint should be added to the base class (and probably all other subclasses) as well to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants