Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydocstyle implementation - Merge pull request #546 from iKostanOrg/master #547

Merged
merged 17 commits into from
Dec 2, 2024
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."""
24 changes: 16 additions & 8 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 @@ -74,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
"""
Expand Down Expand Up @@ -103,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
"""
Expand Down Expand Up @@ -139,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
"""
Expand All @@ -164,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.

ikostan marked this conversation as resolved.
Show resolved Hide resolved
: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
Loading