From 38ba2d672c3c280c63daa7cfe0c7c49befe06776 Mon Sep 17 00:00:00 2001 From: Joseph Martinot-Lagarde Date: Sun, 10 Sep 2023 19:04:48 +0200 Subject: [PATCH] Ruff D400 --- src/lineprofilergui/gui.py | 2 +- src/lineprofilergui/main.py | 2 +- src/lineprofilergui/theme.py | 2 +- src/lineprofilergui/tree.py | 8 ++++---- tests/test_mainwindow.py | 16 ++++++++-------- tests/test_tree.py | 6 +++--- tests/utils.py | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/lineprofilergui/gui.py b/src/lineprofilergui/gui.py index bdf7843..714a578 100644 --- a/src/lineprofilergui/gui.py +++ b/src/lineprofilergui/gui.py @@ -289,7 +289,7 @@ def set_running_state(self, running): @QtCore.Slot(int, QtCore.QProcess.ExitStatus) def process_finished(self, exit_code, exit_status): - """Note: if process was aborted, exit_status should be 1""" + """Note: if process was aborted, exit_status should be 1.""" # Time and duration values profile_stop_time = datetime.datetime.now() profile_duration = profile_stop_time - self.profile_start_time diff --git a/src/lineprofilergui/main.py b/src/lineprofilergui/main.py index a8bb578..c7f195b 100644 --- a/src/lineprofilergui/main.py +++ b/src/lineprofilergui/main.py @@ -16,7 +16,7 @@ def positive_float(value): def commandline_args(args): - """Manage arguments with argparse""" + """Manage arguments with argparse.""" parser = argparse.ArgumentParser( description="Run, profile a python script and display results." diff --git a/src/lineprofilergui/theme.py b/src/lineprofilergui/theme.py index 69de4c1..8557c58 100644 --- a/src/lineprofilergui/theme.py +++ b/src/lineprofilergui/theme.py @@ -48,7 +48,7 @@ def apply_default_theme(): def is_windows_dark_theme(): - """Detect Windows theme""" + """Detect Windows theme.""" # From https://successfulsoftware.net/2021/03/31/how-to-add-a-dark-theme-to-your-qt-application/ settings = QtCore.QSettings( "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", diff --git a/src/lineprofilergui/tree.py b/src/lineprofilergui/tree.py index 942fd06..c6ebf49 100644 --- a/src/lineprofilergui/tree.py +++ b/src/lineprofilergui/tree.py @@ -15,7 +15,7 @@ def load_profile_data(filename): - """Load line profiler data saved by kernprof module""" + """Load line profiler data saved by kernprof module.""" # stats has the following layout : # stats.timings = # {(filename1, line_no1, function_name1): @@ -88,7 +88,7 @@ def parse_stats(self, stats): @functools.cached_property def color(self): - """Choose deteministic unique color for the function""" + """Choose deteministic unique color for the function.""" key = (self.filename + self.name).encode("utf8") hue = float(zlib.crc32(key) & 0xFFFFFFFF) / 2**32 * 360 color = QtGui.QColor.fromHsv(int(hue), 100, 255) @@ -157,7 +157,7 @@ def color(self): class ResultsTreeWidget(QtWidgets.QTreeWidget): - """Tree widget to view line_profiler results""" + """Tree widget to view line_profiler results.""" column_header_text = [ _("Line #"), @@ -238,7 +238,7 @@ def show_tree(self, profiledata): scrollbar.setValue(scroll) def populate_tree(self, profiledata): - """Create each item (and associated data) in the tree""" + """Create each item (and associated data) in the tree.""" # Clear before re-populating self.clear() diff --git a/tests/test_mainwindow.py b/tests/test_mainwindow.py index d22f09a..7f24f02 100644 --- a/tests/test_mainwindow.py +++ b/tests/test_mainwindow.py @@ -9,14 +9,14 @@ class TestMainWindow: - """Global checks for the main window and profiling results + """Global checks for the main window and profiling results. Those are more functional tests rather than unit tests, but at least is assures that there is no basic problem in most of the code. """ def test_profile_1_function(self, qtbot, tmp_path): - """Check that the result tree is filled correctly""" + """Check that the result tree is filled correctly.""" code = """ @profile def profiled_function(): @@ -69,7 +69,7 @@ def profiled_function(): assert func_item.child(1).data(0, Qt.UserRole) == (scriptfile, 4) def test_profile_2_functions(self, qtbot, tmp_path): - """Check the profiling of 2 different functions""" + """Check the profiling of 2 different functions.""" code = """ @profile def profiled_function1(): @@ -95,7 +95,7 @@ def profiled_function2(): assert tree.topLevelItemCount() == 2 # functions profiled def test_function_not_called(self, qtbot, tmp_path): - """Check the case of a decoracted function not called""" + """Check the case of a decoracted function not called.""" code = """ @profile def not_profiled_function(): @@ -114,7 +114,7 @@ def not_profiled_function(): assert tree.topLevelItemCount() == 1 # function decorated but not profiled def test_warn_no_decorator(self, qtbot, tmp_path): - """Check the case of no @profile decorator in script""" + """Check the case of no @profile decorator in script.""" code = """ def not_profiled_function(): return "This was not profiled" @@ -142,7 +142,7 @@ def not_profiled_function(): assert warn_item.data(0, Qt.UserRole) is None def test_script_error(self, qtbot, tmp_path): - """Check the case of the script ending with an error""" + """Check the case of the script ending with an error.""" code = "1 / 0" win = run_code(code, tmp_path, qtbot) @@ -151,7 +151,7 @@ def test_script_error(self, qtbot, tmp_path): assert lines[-1] == "ZeroDivisionError: division by zero" def test_script_kill(self, qtbot, tmp_path): - """Check the case of a script killed""" + """Check the case of a script killed.""" code = """ import time def long_running_function(): @@ -181,7 +181,7 @@ def long_running_function(): assert warn_item.data(0, Qt.UserRole) is None def test_load_lprof(self, qtbot, tmp_path): - """Check that laoding a .lprof file directly works""" + """Check that laoding a .lprof file directly works.""" code = """ @profile def profiled_function(): diff --git a/tests/test_tree.py b/tests/test_tree.py index 6bbd9ad..f4b5f28 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -6,10 +6,10 @@ class TestResultsTreeWidget: - """Specific checks for resultsTreeWidget behavior""" + """Specific checks for resultsTreeWidget behavior.""" def test_collapse_expand(self, qtbot, tmp_path): - """Check the tracking of expanded functions""" + """Check the tracking of expanded functions.""" code = """ @profile def profiled_function(): @@ -33,7 +33,7 @@ def profiled_function(): assert tree.expanded_functions == {(scriptfile, "profiled_function")} def test_open_editor(self, qtbot, tmp_path, monkeypatch): - """Check the command to open an editor at the correct line""" + """Check the command to open an editor at the correct line.""" code = """ @profile def profiled_function(): diff --git a/tests/utils.py b/tests/utils.py index 1a11071..afed570 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,7 +4,7 @@ def run_code(code, tmp_path, qtbot): - """Helper function to run profiled code from UI_MainWindow""" + """Helper function to run profiled code from UI_MainWindow.""" scriptfile = tmp_path / "script.py" scriptfile.write_text(textwrap.dedent(code))