Skip to content

Commit 9a50785

Browse files
Merge pull request #35 from kognitos/fix-all-linting-issues
fix: fixed all docstring issues
2 parents e1ce8b0 + 941a214 commit 9a50785

3 files changed

Lines changed: 52 additions & 63 deletions

File tree

tests/test_lint.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
import os
2-
import subprocess
3-
4-
import pytest
5-
from change_dir import change_dir
6-
from generate_project import generate_project
7-
from pylint.lint import Run
8-
from pylint.reporters import CollectingReporter
9-
10-
PROJECT_SLUG = "test_project"
11-
PROJECT_NAME = "Test Project"
12-
13-
14-
def run_pylint(project_directory):
15-
report = CollectingReporter()
16-
17-
src_directory = os.path.join(project_directory, "src", PROJECT_SLUG)
18-
19-
with change_dir(project_directory):
20-
result = subprocess.run(["poetry", "install"], capture_output=True, text=True)
21-
22-
try:
23-
pylint_output = Run([src_directory], reporter=report, exit=False)
24-
25-
pylint_score = pylint_output.linter.stats.global_note
26-
except Exception as e:
27-
pylint_score = None
28-
29-
return pylint_score, report.messages
30-
31-
32-
@pytest.mark.parametrize(
33-
"generate_project",
34-
[{"project_slug": PROJECT_SLUG, "project_name": PROJECT_NAME}],
35-
indirect=True,
36-
)
37-
def test_pylint_passes(generate_project):
38-
pylint_score, pylint_messages = run_pylint(generate_project)
39-
40-
# Check if pylint passed based on your criteria, for example, a score of 8.0+
41-
assert (
42-
pylint_score >= 8.0
43-
), f"Pylint failed with score {pylint_score}\n{pylint_messages}"
1+
import os
2+
import subprocess
3+
4+
import pytest
5+
from change_dir import change_dir
6+
from generate_project import generate_project
7+
from pylint.lint import Run
8+
from pylint.reporters import CollectingReporter
9+
10+
PROJECT_SLUG = "test_project"
11+
PROJECT_NAME = "Test Project"
12+
13+
14+
def run_pylint(project_directory):
15+
report = CollectingReporter()
16+
17+
src_directory = os.path.join(project_directory, "src", PROJECT_SLUG)
18+
19+
with change_dir(project_directory):
20+
result = subprocess.run(["poetry", "install"], capture_output=True, text=True)
21+
22+
try:
23+
pylint_output = Run([src_directory], reporter=report, exit=False)
24+
25+
pylint_score = pylint_output.linter.stats.global_note
26+
except Exception as e:
27+
pylint_score = None
28+
29+
return pylint_score, report.messages
30+
31+
32+
@pytest.mark.parametrize(
33+
"generate_project",
34+
[{"project_slug": PROJECT_SLUG, "project_name": PROJECT_NAME}],
35+
indirect=True,
36+
)
37+
def test_pylint_passes(generate_project):
38+
pylint_score, pylint_messages = run_pylint(generate_project)
39+
40+
# Check if pylint passed
41+
assert (
42+
pylint_score == 10.0
43+
), f"Pylint failed with score {pylint_score}\n{pylint_messages}"
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"""
2-
Initialization file for {{ cookiecutter.__book_class_name }}
3-
"""
1+
"""Initialization file for {{ cookiecutter.__book_class_name }}"""
42

53
from .book import {{ cookiecutter.__base_url_name }}, {{ cookiecutter.__book_class_name }}

{{cookiecutter.project_folder_name}}/src/{{cookiecutter.project_slug}}/book.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
{{cookiecutter.project_description}}
3-
"""
1+
"""{{cookiecutter.project_description}}"""
42

53
import logging
64
from typing import Optional
@@ -21,16 +19,14 @@
2119

2220
@book(icon="data/icon.svg", name="{{ cookiecutter.project_name }}", tags=["Example"])
2321
class {{ cookiecutter.__book_class_name }}:
24-
"""
25-
A book for {{cookiecutter.project_description}}
22+
"""A book for {{cookiecutter.project_description}}
2623
2724
Author:
2825
{{cookiecutter.author_name}}
2926
"""
3027

3128
def __init__(self):
32-
"""
33-
Initializes an instance of the class.
29+
"""Initializes an instance of the class.
3430
3531
:param self: The instance of the class.
3632
"""
@@ -40,8 +36,7 @@ def __init__(self):
4036

4137
@property
4238
def timeout(self) -> float:
43-
"""
44-
Get the value of the timeout.
39+
"""Get the value of the timeout.
4540
4641
Parameters:
4742
None
@@ -54,8 +49,7 @@ def timeout(self) -> float:
5449

5550
@timeout.setter
5651
def timeout(self, timeout: float):
57-
"""
58-
Sets the timeout value in milliseconds.
52+
"""Sets the timeout value in milliseconds.
5953
6054
Args:
6155
timeout (int): The timeout value to set. Must be a positive integer.
@@ -70,8 +64,7 @@ def timeout(self, timeout: float):
7064

7165
@connect(noun_phrase="api keys", name="Api Keys")
7266
def connect(self, api_key: str):
73-
"""
74-
Connects to an API using the provided API key.
67+
"""Connects to an API using the provided API key.
7568
7669
Arguments:
7770
api_key: The API key to be used for connecting
@@ -96,8 +89,7 @@ def connect(self, api_key: str):
9689
def current_temperature(
9790
self, city: NounPhrase, unit: Optional[NounPhrase] = NounPhrase("metric")
9891
) -> float:
99-
"""
100-
Fetch the current temperature for a specified city.
92+
"""Fetch the current temperature for a specified city.
10193
10294
Input Concepts:
10395
the city: The name of the city. Please refer to ISO 3166 for the state codes or country codes.
@@ -142,8 +134,7 @@ def current_temperature(
142134

143135
@procedure("to capitalize a (string)", connection_required=ConnectionRequired.NEVER)
144136
def capitalize_string(self, string: str) -> str:
145-
"""
146-
Capitalizes the input string.
137+
"""Capitalizes the input string.
147138
148139
Input Concepts:
149140
the string: The string value you want to capitalize.

0 commit comments

Comments
 (0)