Skip to content

Commit

Permalink
Ruff D400
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodd committed Sep 10, 2023
1 parent d41db4c commit 38ba2d6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/lineprofilergui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lineprofilergui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion src/lineprofilergui/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/lineprofilergui/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 #"),
Expand Down Expand Up @@ -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()

Expand Down
16 changes: 8 additions & 8 deletions tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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():
Expand All @@ -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():
Expand All @@ -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"
Expand Down Expand Up @@ -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)

Expand All @@ -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():
Expand Down Expand Up @@ -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():
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 38ba2d6

Please sign in to comment.