From 07d8ce9c41cc49cb7e65d1ef80524e6587ede73f Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Wed, 11 Dec 2024 22:35:11 +0000 Subject: [PATCH] Add type hints for profiling calls --- app/models.py | 2 +- app/musicmuster.py | 2 +- app/playlistmodel.py | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models.py b/app/models.py index 7cf73fc..d46e5d5 100644 --- a/app/models.py +++ b/app/models.py @@ -567,7 +567,7 @@ class PlaylistRows(dbtables.PlaylistRowsTable): session: Session, playlist_id: int, sqla_map: List[dict[str, int]], - dummy_for_profiling=None, + dummy_for_profiling: Optional[int] = None, ) -> None: """ Take a {plrid: row_number} dictionary and update the row numbers accordingly diff --git a/app/musicmuster.py b/app/musicmuster.py index d72be6b..955c6e9 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -1066,7 +1066,7 @@ class Window(QMainWindow, Ui_MainWindow): webbrowser.get("browser").open_new_tab(url) @line_profiler.profile - def paste_rows(self, dummy_for_profiling=None) -> None: + def paste_rows(self, dummy_for_profiling: Optional[int] = None) -> None: """ Paste earlier cut rows. """ diff --git a/app/playlistmodel.py b/app/playlistmodel.py index afdf28b..dd8b0b6 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -747,7 +747,10 @@ class PlaylistModel(QAbstractTableModel): @line_profiler.profile def move_rows( - self, from_rows: list[int], to_row_number: int, dummy_for_profiling=None + self, + from_rows: list[int], + to_row_number: int, + dummy_for_profiling: Optional[int] = None, ) -> None: """ Move the playlist rows given to to_row and below. @@ -819,7 +822,7 @@ class PlaylistModel(QAbstractTableModel): from_rows: list[int], to_row_number: int, to_playlist_id: int, - dummy_for_profiling=None, + dummy_for_profiling: Optional[int] = None, ) -> None: """ Move the playlist rows given to to_row and below of to_playlist. @@ -992,7 +995,9 @@ class PlaylistModel(QAbstractTableModel): self.invalidate_row(track_sequence.previous.row_number) @line_profiler.profile - def refresh_data(self, session: db.session, dummy_for_profiling=None) -> None: + def refresh_data( + self, session: db.session, dummy_for_profiling: Optional[int] = None + ) -> None: """Populate self.playlist_rows with playlist data""" # We used to clear self.playlist_rows each time but that's @@ -1019,7 +1024,9 @@ class PlaylistModel(QAbstractTableModel): # Same as refresh data, but only used when creating playslit. # Distinguishes profile time between initial load and other # refreshes. - def load_data(self, session: db.session, dummy_for_profiling=None) -> None: + def load_data( + self, session: db.session, dummy_for_profiling: Optional[int] = None + ) -> None: """Populate self.playlist_rows with playlist data""" # We used to clear self.playlist_rows each time but that's