From 817d43ab08e0a591b0ebb522c66c449d2be1491d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 20:59:38 -0800 Subject: [PATCH 01/16] Create pydocstyle_kyu2.yml --- .github/workflows/pydocstyle_kyu2.yml | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/pydocstyle_kyu2.yml diff --git a/.github/workflows/pydocstyle_kyu2.yml b/.github/workflows/pydocstyle_kyu2.yml new file mode 100644 index 00000000000..0ebdf58314e --- /dev/null +++ b/.github/workflows/pydocstyle_kyu2.yml @@ -0,0 +1,46 @@ +--- +name: pydocstyle for kyu2 + +on: # yamllint disable-line rule:truthy + push: + branches: + - 'kyu2' + +permissions: + contents: read + pull-requests: read + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.x"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + # This is the version of the action for setting up Python, + # not the Python version. + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + # You can test your matrix by printing the current Python version + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + pip install -r requirements.txt + pip install pydocstyle + pip install types-requests + - name: Check to make sure that the module is in your Python path + run: | + echo $PYTHONPATH + - name: Check pydocstyle version + run: | + pydocstyle --versio + - name: Python Data Type Checking with MyPy + # Pydocstyle testing (Guide) + # https://www.pydocstyle.org/en/stable/usage.html#cli-usage + run: | + pydocstyle --verbose --explain --count kyu_2 From a295ca29dba28f6abaa5b48c2282f4e523ec5c28 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:12:50 -0800 Subject: [PATCH 02/16] Create .pydocstyle --- .pydocstyle | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .pydocstyle diff --git a/.pydocstyle b/.pydocstyle new file mode 100644 index 00000000000..91b66bb3549 --- /dev/null +++ b/.pydocstyle @@ -0,0 +1,3 @@ +[pydocstyle] +inherit = false +match='(?!__ini__).*\.py' \ No newline at end of file From 1f9ca1347433e1a4a9761acdd7280a38ab269c2b Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:15:55 -0800 Subject: [PATCH 03/16] Update pydocstyle_kyu2.yml --- .github/workflows/pydocstyle_kyu2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pydocstyle_kyu2.yml b/.github/workflows/pydocstyle_kyu2.yml index 0ebdf58314e..022538f9c8a 100644 --- a/.github/workflows/pydocstyle_kyu2.yml +++ b/.github/workflows/pydocstyle_kyu2.yml @@ -39,7 +39,7 @@ jobs: - name: Check pydocstyle version run: | pydocstyle --versio - - name: Python Data Type Checking with MyPy + - name: Doc style Checking with pydocstyle # Pydocstyle testing (Guide) # https://www.pydocstyle.org/en/stable/usage.html#cli-usage run: | From 7fc97eaea7902ad46e8558f3a3ee34a5b88f5dfa Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:15:59 -0800 Subject: [PATCH 04/16] Update .pydocstyle --- .pydocstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pydocstyle b/.pydocstyle index 91b66bb3549..f1ca9b912e0 100644 --- a/.pydocstyle +++ b/.pydocstyle @@ -1,3 +1,3 @@ [pydocstyle] inherit = false -match='(?!__ini__).*\.py' \ No newline at end of file +match='(?!__ini__).' \ No newline at end of file From e6b5ba368cb4a953ff70778701bd60eb11aa5a23 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:17:37 -0800 Subject: [PATCH 05/16] Update .pydocstyle --- .pydocstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pydocstyle b/.pydocstyle index f1ca9b912e0..7182aa80170 100644 --- a/.pydocstyle +++ b/.pydocstyle @@ -1,3 +1,3 @@ [pydocstyle] inherit = false -match='(?!__ini__).' \ No newline at end of file +match = .*\.py \ No newline at end of file From eea57b6ebb56aefe12346765b00344d2a294eab9 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:21:24 -0800 Subject: [PATCH 06/16] Update .pydocstyle --- .pydocstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pydocstyle b/.pydocstyle index 7182aa80170..045d8a1c320 100644 --- a/.pydocstyle +++ b/.pydocstyle @@ -1,3 +1,3 @@ [pydocstyle] inherit = false -match = .*\.py \ No newline at end of file +match = ^(?!(__init__)\.py$) \ No newline at end of file From b2f2cff031a5ec862e6f6772fd5ca21934ce898e Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:23:16 -0800 Subject: [PATCH 07/16] Update pydocstyle_kyu2.yml --- .github/workflows/pydocstyle_kyu2.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pydocstyle_kyu2.yml b/.github/workflows/pydocstyle_kyu2.yml index 022538f9c8a..f27a6ba054f 100644 --- a/.github/workflows/pydocstyle_kyu2.yml +++ b/.github/workflows/pydocstyle_kyu2.yml @@ -38,8 +38,8 @@ jobs: echo $PYTHONPATH - name: Check pydocstyle version run: | - pydocstyle --versio - - name: Doc style Checking with pydocstyle + pydocstyle --version + - name: Doc style checking with pydocstyle # Pydocstyle testing (Guide) # https://www.pydocstyle.org/en/stable/usage.html#cli-usage run: | From c65560efe6ba1a9cb81f26126943b47a57af9317 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:23:19 -0800 Subject: [PATCH 08/16] Update .pydocstyle --- .pydocstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pydocstyle b/.pydocstyle index 045d8a1c320..7182aa80170 100644 --- a/.pydocstyle +++ b/.pydocstyle @@ -1,3 +1,3 @@ [pydocstyle] inherit = false -match = ^(?!(__init__)\.py$) \ No newline at end of file +match = .*\.py \ No newline at end of file From b434092c77b8442dcf08b3be437686be86edc747 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:30:49 -0800 Subject: [PATCH 09/16] Update __init__.py --- kyu_2/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kyu_2/__init__.py b/kyu_2/__init__.py index e69de29bb2d..aca44cda225 100644 --- a/kyu_2/__init__.py +++ b/kyu_2/__init__.py @@ -0,0 +1 @@ +"""Codewars kyu_2 package""" \ No newline at end of file From 41681a1c4821120df786aa6140050653b5741e09 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:33:37 -0800 Subject: [PATCH 10/16] Docstring for __init_ files --- kyu_2/__init__.py | 2 +- kyu_2/evaluate_mathematical_expression/__init__.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/kyu_2/__init__.py b/kyu_2/__init__.py index aca44cda225..bd812863680 100644 --- a/kyu_2/__init__.py +++ b/kyu_2/__init__.py @@ -1 +1 @@ -"""Codewars kyu_2 package""" \ No newline at end of file +"""Codewars kyu_2 package.""" diff --git a/kyu_2/evaluate_mathematical_expression/__init__.py b/kyu_2/evaluate_mathematical_expression/__init__.py index e69de29bb2d..92e7bfd6530 100644 --- a/kyu_2/evaluate_mathematical_expression/__init__.py +++ b/kyu_2/evaluate_mathematical_expression/__init__.py @@ -0,0 +1 @@ +"""Codewars kyu_2 package: Evaluate mathematical expression.""" From 2594062d8494fa893db61180130d926fc582f921 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:37:09 -0800 Subject: [PATCH 11/16] Update test_evaluate.py --- .../evaluate_mathematical_expression/test_evaluate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kyu_2/evaluate_mathematical_expression/test_evaluate.py b/kyu_2/evaluate_mathematical_expression/test_evaluate.py index 8e0ca54451b..2adbbc6f463 100644 --- a/kyu_2/evaluate_mathematical_expression/test_evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/test_evaluate.py @@ -1,5 +1,6 @@ """ -Test for -> calc method +Test for -> calc method. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -34,13 +35,12 @@ name='Source/Kata') # pylint: enable=R0801 class CalcTestCase(unittest.TestCase): - """ - Testing calc method - """ + """Testing calc method.""" def test_calc(self): """ - Testing calc class + Testing calc class. + Given a mathematical expression as a string you must return the result as a number. """ From d1b41c86b5e3e9dba70193ad94faf48452e074c1 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:38:54 -0800 Subject: [PATCH 12/16] Update evaluate.py kyu_2/evaluate_mathematical_expression/evaluate.py:15 in public function `calculate`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_2/evaluate_mathematical_expression/evaluate.py:15 in public function `calculate`: D400: First line should end with a period (not 'n') The [first line of a] docstring is a phrase ending in a period. --- kyu_2/evaluate_mathematical_expression/evaluate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kyu_2/evaluate_mathematical_expression/evaluate.py b/kyu_2/evaluate_mathematical_expression/evaluate.py index 838725fb105..6769efad73b 100644 --- a/kyu_2/evaluate_mathematical_expression/evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/evaluate.py @@ -13,7 +13,8 @@ def calculate(i: int, char: str, strings: list) -> None: """ - Calculate math expression + Calculate math expression. + :param i: int :param char: str :param strings: list From fabc1c3d52af87c63e2da910598f524e97eee79b Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:40:01 -0800 Subject: [PATCH 13/16] Update evaluate.py --- .../evaluate.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/kyu_2/evaluate_mathematical_expression/evaluate.py b/kyu_2/evaluate_mathematical_expression/evaluate.py index 6769efad73b..97c580a3208 100644 --- a/kyu_2/evaluate_mathematical_expression/evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/evaluate.py @@ -14,7 +14,7 @@ def calculate(i: int, char: str, strings: list) -> None: """ Calculate math expression. - + :param i: int :param char: str :param strings: list @@ -36,7 +36,8 @@ def calculate(i: int, char: str, strings: list) -> None: def process_math_expression(string: str, operators: list) -> str: """ - Process math expression + Process math expression. + :param string: str :param operators: list :return: str @@ -54,7 +55,8 @@ def process_math_expression(string: str, operators: list) -> str: def bracket_start(strings: list) -> int: """ - Return index of first (open) bracket + Return index of first (open) bracket. + :param strings: list :return: int """ @@ -64,7 +66,8 @@ def bracket_start(strings: list) -> int: def bracket_end(strings: list, start: int) -> int: """ - Return index of last (close) bracket + Return index of last (close) bracket. + :param strings: :param start: :return: @@ -75,7 +78,8 @@ def bracket_end(strings: list, start: int) -> int: def process_brackets(strings: list) -> str: """ Process brackets in order to convert - input string into math expression + input string into math expression. + :param strings: list :return: str """ @@ -104,7 +108,8 @@ def process_brackets(strings: list) -> str: def process_duplicate_minus(string: str) -> str: """ - Eliminate duplicate minus + Eliminate duplicate minus. + :param string: str :return: str """ @@ -140,7 +145,8 @@ def process_duplicate_minus(string: str) -> str: def calc(string: str) -> float: """ - Calculate math expression from input string + Calculate math expression from input string. + :param string: str :return: float """ @@ -165,7 +171,8 @@ def calc(string: str) -> float: def check_conditions(strings: list, string: str, temp: str) -> tuple[str, str]: """ - Normalizing string input by checking conditions + Normalizing string input by checking conditions. + :param strings: list :param string: str :param temp: str From 90ef1ba73ca2b47dd50061268f08cb0ac65699c3 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:41:34 -0800 Subject: [PATCH 14/16] Update evaluate.py ./kyu_2/evaluate_mathematical_expression/evaluate.py:175:1: W293 blank line contains whitespace """ Normalizing string input by checking conditions. :param strings: list :param string: str :param temp: str :return: tuple(str, str) """ --- kyu_2/evaluate_mathematical_expression/evaluate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyu_2/evaluate_mathematical_expression/evaluate.py b/kyu_2/evaluate_mathematical_expression/evaluate.py index 97c580a3208..0a1fb58a574 100644 --- a/kyu_2/evaluate_mathematical_expression/evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/evaluate.py @@ -172,7 +172,7 @@ def calc(string: str) -> float: def check_conditions(strings: list, string: str, temp: str) -> tuple[str, str]: """ Normalizing string input by checking conditions. - + :param strings: list :param string: str :param temp: str From 0c05c7dd997d5f7470887923a404b8e92a5c4671 Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:44:59 -0800 Subject: [PATCH 15/16] Update evaluate.py kyu_2/evaluate_mathematical_expression/evaluate.py:79 in public function `process_brackets`: D205: 1 blank line required between summary line and description (found 0) Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. kyu_2/evaluate_mathematical_expression/evaluate.py:79 in public function `process_brackets`: D400: First line should end with a period (not 't') The [first line of a] docstring is a phrase ending in a period. --- kyu_2/evaluate_mathematical_expression/evaluate.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kyu_2/evaluate_mathematical_expression/evaluate.py b/kyu_2/evaluate_mathematical_expression/evaluate.py index 0a1fb58a574..2c05a45a115 100644 --- a/kyu_2/evaluate_mathematical_expression/evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/evaluate.py @@ -77,9 +77,10 @@ def bracket_end(strings: list, start: int) -> int: def process_brackets(strings: list) -> str: """ - Process brackets in order to convert - input string into math expression. + Test bracket processing. + Process brackets in order to convert input + string into math expression. :param strings: list :return: str """ From 92981fe31299eaf6c7f6bc751f6b972571c3b04a Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:46:24 -0800 Subject: [PATCH 16/16] Update evaluate.py kyu_2/evaluate_mathematical_expression/evaluate.py:173 in public function `check_conditions`: D401: First line should be in imperative mood (perhaps 'Normalize', not 'Normalizing') [Docstring] prescribes the function or method's effect as a command: ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...". --- kyu_2/evaluate_mathematical_expression/evaluate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kyu_2/evaluate_mathematical_expression/evaluate.py b/kyu_2/evaluate_mathematical_expression/evaluate.py index 2c05a45a115..5df8845753f 100644 --- a/kyu_2/evaluate_mathematical_expression/evaluate.py +++ b/kyu_2/evaluate_mathematical_expression/evaluate.py @@ -172,8 +172,9 @@ def calc(string: str) -> float: def check_conditions(strings: list, string: str, temp: str) -> tuple[str, str]: """ - Normalizing string input by checking conditions. + Test string normalization. + Normalize string input by checking conditions. :param strings: list :param string: str :param temp: str