Skip to content

Commit

Permalink
Merge pull request #547 from iKostanOrg/kyu2
Browse files Browse the repository at this point in the history
pydocstyle implementation - Merge pull request #546 from iKostanOrg/master
  • Loading branch information
ikostan authored Dec 2, 2024
2 parents f128538 + 92981fe commit e3a69ea
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 14 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pydocstyle_kyu2.yml
Original file line number Diff line number Diff line change
@@ -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 --version
- name: Doc style checking with pydocstyle
# Pydocstyle testing (Guide)
# https://www.pydocstyle.org/en/stable/usage.html#cli-usage
run: |
pydocstyle --verbose --explain --count kyu_2
3 changes: 3 additions & 0 deletions .pydocstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pydocstyle]
inherit = false
match = .*\.py
1 change: 1 addition & 0 deletions kyu_2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Codewars kyu_2 package."""
1 change: 1 addition & 0 deletions kyu_2/evaluate_mathematical_expression/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Codewars kyu_2 package: Evaluate mathematical expression."""
28 changes: 19 additions & 9 deletions kyu_2/evaluate_mathematical_expression/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,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
Expand All @@ -53,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
"""
Expand All @@ -63,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:
Expand All @@ -73,8 +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
"""
Expand Down Expand Up @@ -103,7 +109,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
"""
Expand Down Expand Up @@ -139,7 +146,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
"""
Expand All @@ -164,7 +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
Expand Down
10 changes: 5 additions & 5 deletions kyu_2/evaluate_mathematical_expression/test_evaluate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> calc method
Test for -> calc method.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand Down Expand Up @@ -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.
"""
Expand Down

0 comments on commit e3a69ea

Please sign in to comment.