From bbb6b1183825d9fb1ad451ac706db2eccf7fa320 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:53:50 +0000 Subject: [PATCH] style: format code with Autopep8, Black, Go fmt, Gofumpt, isort and Yapf This commit fixes the style issues introduced in 989487f according to the output from Autopep8, Black, Go fmt, Gofumpt, isort and Yapf. Details: None --- scripts/benchmark/benchmark_core.py | 47 +++++++++++++------------- scripts/demo/critical_highlights.py | 1 - tests/python/test_filtering.py | 4 +-- tests/python/test_macros.py | 6 ++-- tests/python/test_simple_sided_dice.py | 5 ++- tests/python/test_symbolic_dice.py | 10 +++--- tests/python/util.py | 1 - 7 files changed, 36 insertions(+), 38 deletions(-) diff --git a/scripts/benchmark/benchmark_core.py b/scripts/benchmark/benchmark_core.py index 570f1d9af..060602cce 100644 --- a/scripts/benchmark/benchmark_core.py +++ b/scripts/benchmark/benchmark_core.py @@ -6,7 +6,6 @@ class BenchMarker: - TIMEOUT_MINUTES = 1 TIMEOUT_SECONDS = TIMEOUT_MINUTES * 60 AVERAGING_RUNS = 50 @@ -16,9 +15,13 @@ def __init__(self, start_range=0, end_range=10): self.range = range(start_range, end_range) self.plt = plt - def add_function( - self, name, f, color="r", marker="o", hard_limit=None, override=None - ): + def add_function(self, + name, + f, + color="r", + marker="o", + hard_limit=None, + override=None): """Adds a function to the list of functions to benchmark. @name - Human Readable name @f - function @@ -27,16 +30,14 @@ def add_function( @hard_limit - don't execute benchmarks above this tolerance @override - Use values from a provided array """ - self.competitors.append( - { - "name": name, - "fn": f, - "color": color, - "marker": marker, - "hard_limit": hard_limit, - "override": override, - } - ) + self.competitors.append({ + "name": name, + "fn": f, + "color": color, + "marker": marker, + "hard_limit": hard_limit, + "override": override, + }) def benchmark(self, title): self.title = title @@ -80,9 +81,9 @@ def benchmark(self, title): # ------ BENCHMARK ------ time1 = time.time() try: - func_timeout.func_timeout( - self.TIMEOUT_SECONDS, roll_fn, args=[r] - ) + func_timeout.func_timeout(self.TIMEOUT_SECONDS, + roll_fn, + args=[r]) except (Exception, func_timeout.FunctionTimedOut) as e: print(f"Err: {c['name']}:{r}") print("\t", e) @@ -101,8 +102,10 @@ def benchmark(self, title): y.append(tt * 1000) if y: - plt.plot(shared_x[0: len(y)], y, - color=c["color"], marker=c["marker"]) + plt.plot(shared_x[0:len(y)], + y, + color=c["color"], + marker=c["marker"]) print("Result:", y) # Configuration and Output @@ -114,11 +117,9 @@ def benchmark(self, title): ax = plt.gca() ax.get_yaxis().set_major_formatter( - matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ",")) - ) + matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ","))) ax.get_xaxis().set_major_formatter( - matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ",")) - ) + matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x), ","))) legend_labels = [c["name"] for c in self.competitors] plt.legend(legend_labels) diff --git a/scripts/demo/critical_highlights.py b/scripts/demo/critical_highlights.py index 1d50f3406..fe4ea3b53 100644 --- a/scripts/demo/critical_highlights.py +++ b/scripts/demo/critical_highlights.py @@ -34,7 +34,6 @@ def main(): """Format a Dice Roll""" # Roll 1. for _ in range(100): - format_roll("d20+d20") diff --git a/tests/python/test_filtering.py b/tests/python/test_filtering.py index f81a33747..dd91522d4 100644 --- a/tests/python/test_filtering.py +++ b/tests/python/test_filtering.py @@ -11,7 +11,8 @@ ("10d10f>8", 19, Mock.RETURN_INCREMENTING, 1), # greater than ("10d10f!=1", 54, Mock.RETURN_INCREMENTING, 1), # is not ("10d10f==1", 1, Mock.RETURN_INCREMENTING, 1), # is equal - ("10d10f>=8", 27, Mock.RETURN_INCREMENTING, 1), # equal or greater than + ("10d10f>=8", 27, Mock.RETURN_INCREMENTING, + 1), # equal or greater than ("10d10f<=3", 6, Mock.RETURN_INCREMENTING, 1), # equal or less than ("10d10fis_even", 30, Mock.RETURN_INCREMENTING, 1), # even ("10d10fis_odd", 25, Mock.RETURN_INCREMENTING, 1), # odd @@ -19,7 +20,6 @@ ], ) def test_filter(r, out, mock, mock_const): - # https://github.com/ianfhunter/GNOLL/issues/216 result, _ = roll(r, mock_mode=mock, mock_const=mock_const, verbose=True) assert result == out diff --git a/tests/python/test_macros.py b/tests/python/test_macros.py index 9c481998f..8e869d4c5 100644 --- a/tests/python/test_macros.py +++ b/tests/python/test_macros.py @@ -19,13 +19,15 @@ def test_macro_storage(r, out, mock): assert result == out -@pytest.mark.parametrize("r,out,mock", [("#MY_DIE=d{A};@MY_DIE", "A", Mock.NO_MOCK)]) +@pytest.mark.parametrize("r,out,mock", + [("#MY_DIE=d{A};@MY_DIE", "A", Mock.NO_MOCK)]) def test_macro_usage(r, out, mock): result, _ = roll(r, mock_mode=mock) assert result == out -@pytest.mark.skip("Currently no support for rerolling operations like Addition") +@pytest.mark.skip( + "Currently no support for rerolling operations like Addition") def test_d66(): r = "#DSIXTYSIX=(d6*10)+d6;@DSIXTYSIX" result, _ = roll(r, mock_mode=Mock.RETURN_CONSTANT, mock_const=3) diff --git a/tests/python/test_simple_sided_dice.py b/tests/python/test_simple_sided_dice.py index 1ace8abab..11b0a7b66 100644 --- a/tests/python/test_simple_sided_dice.py +++ b/tests/python/test_simple_sided_dice.py @@ -75,9 +75,8 @@ def test_non_rolling_roll(): assert result == 0 -@pytest.mark.parametrize( - "r", [("d"), ("d2d"), ("2d2d2"), ("2d2d2d"), ("1d"), ("d-1"), ("-1d-1")] -) +@pytest.mark.parametrize("r", [("d"), ("d2d"), ("2d2d2"), ("2d2d2d"), ("1d"), + ("d-1"), ("-1d-1")]) def test_bad_simple_rolls(r): try: roll(r) diff --git a/tests/python/test_symbolic_dice.py b/tests/python/test_symbolic_dice.py index 983aacc83..f8e3a6191 100644 --- a/tests/python/test_symbolic_dice.py +++ b/tests/python/test_symbolic_dice.py @@ -16,9 +16,8 @@ def test_symbolic_dice(r, out, mock): assert result == out -@pytest.mark.parametrize( - "r,out,mock", [("2d{A,B,C,D}", ["D", "D"], Mock.RETURN_CONSTANT)] -) +@pytest.mark.parametrize("r,out,mock", + [("2d{A,B,C,D}", ["D", "D"], Mock.RETURN_CONSTANT)]) def test_multiple_symbolic_dice(r, out, mock): result, _ = roll(r, mock_mode=mock) assert result == out @@ -41,9 +40,8 @@ def test_long_string(r, out, mock): assert result == out -@pytest.mark.parametrize( - "r,out,mock", [("2d{2,2,2,2,3}", [2, 2], Mock.RETURN_CONSTANT)] -) +@pytest.mark.parametrize("r,out,mock", + [("2d{2,2,2,2,3}", [2, 2], Mock.RETURN_CONSTANT)]) def test_multiple_numeric_dice(r, out, mock): result, _ = roll(r, mock_mode=mock) assert result == out diff --git a/tests/python/util.py b/tests/python/util.py index c65edc92a..6f1b08ff8 100644 --- a/tests/python/util.py +++ b/tests/python/util.py @@ -30,7 +30,6 @@ def error_handled_by_gnoll(e): def get_roll(): - # We are explicitly using the local module here as we modify the yacc in order to mock our tests. # This ugly logic is to bypass the fact that you might have the pip package installed # and thus a name conflict