From a1a2d04ae69bd50aba9dac2783737dfda8f048c9 Mon Sep 17 00:00:00 2001 From: Daniel Raniz Raneland Date: Fri, 15 Sep 2023 18:25:53 +0200 Subject: [PATCH] Fix linting errors --- pyproject.toml | 2 +- src/python_starter/__init__.py | 2 +- src/python_starter/calculator.py | 8 +++++--- tests/test_calculator.py | 9 ++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f9f4840..c6756b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ ruff = "^0.0.289" [tool.ruff] select = ["ALL"] -ignore = ["D211", "D213"] +ignore = ["D211", "D213", "T201"] [tool.ruff.per-file-ignores] "tests/**" = ["D", "S101", "S105", "INP001", "ANN201"] diff --git a/src/python_starter/__init__.py b/src/python_starter/__init__.py index e0692d9..b9d0863 100644 --- a/src/python_starter/__init__.py +++ b/src/python_starter/__init__.py @@ -1,3 +1,3 @@ """String calculator.""" -from .calculator import evaluate +from .calculator import evaluate # noqa: F401 diff --git a/src/python_starter/calculator.py b/src/python_starter/calculator.py index fc1beea..c625793 100644 --- a/src/python_starter/calculator.py +++ b/src/python_starter/calculator.py @@ -1,3 +1,4 @@ +"""String calculator.""" import sys @@ -6,6 +7,7 @@ def evaluate(expression: str) -> int: return 0 -def main(): - input = " ".join(sys.argv[1:]) - print(f"{input} = {evaluate(input)}") +def main() -> None: + """Calculate the value of a mathematical expression.""" + expression = " ".join(sys.argv[1:]) + print(f"{expression} = {evaluate(input)}") diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 46f4a9b..1ec1b67 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,18 +1,17 @@ import pytest - from python_starter import evaluate @pytest.mark.parametrize( - "expression, expected", - ( + ("expression", "expected"), + [ ("0", 0), # ("1 + 2", 3), # ("1 + 2", 3), # ("(1 + 2) * 5 / 2 + -3 * 7", -14) - ), + ], ) -def test_expression(expression, expected): +def test_expression(expression: str, expected: int): # When the expression is evaluated result = evaluate(expression)