Skip to content

Commit ff17cc0

Browse files
authored
feat: Add mapping asyncfunction to method in elementKind (#20)
* feat: Add mapping asyncfunction to method in elementKind * feat: Update test * feat: Add async function with annotation
1 parent 49478e0 commit ff17cc0

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/reqstool_python_decorators/processors/decorator_processor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@unique
1010
class DECORATOR_TYPES(Enum):
1111
FUNCTION = ("FUNCTION", "METHOD")
12+
ASYNCFUNCTION = ("ASYNCFUNCTION", "METHOD")
1213

1314
def __init__(self, from_value, to_value):
1415
self.from_value = from_value
@@ -173,7 +174,7 @@ def format_results(self, results):
173174

174175
return formatted_data
175176

176-
def create_dir_from_path(self, filepath: str):
177+
def create_dir_from_path(self, filepath: str) -> None:
177178
"""
178179
Creates directory of provided filepath if it does not exists
179180
@@ -184,7 +185,9 @@ def create_dir_from_path(self, filepath: str):
184185
if not os.path.exists(directory):
185186
os.makedirs(directory)
186187

187-
def process_decorated_data(self, path_to_python_files, output_file="build/reqstool/annotations.yml"):
188+
def process_decorated_data(
189+
self, path_to_python_files: str, output_file: str = "build/reqstool/annotations.yml"
190+
) -> None:
188191
"""
189192
"Main" function, runs all functions resulting in a yaml file containing decorated data.
190193

tests/resources/test_decorators/requirements_decorators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ class RequirementsClass:
77

88

99
@Requirements("REQ_333")
10-
def requirements_function():
10+
def requirements_function() -> None:
1111
# Test function for Requirements decorator
1212
pass
13+
14+
15+
@Requirements("REQ_444")
16+
async def asyncrequirements_function() -> None:
17+
# Test async function for Requirements decorator
18+
pass

tests/unit/reqstool_decorators/processors/test_processors.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ def test_get_functions_and_classes(process_decorator_instance: DecoratorProcesso
2525

2626

2727
def test_map_type_known_type(process_decorator_instance: DecoratorProcessor):
28-
result = process_decorator_instance.map_type("FUNCTION")
29-
assert result == "METHOD"
28+
map_funcion = process_decorator_instance.map_type("FUNCTION")
29+
map_asyncfunction = process_decorator_instance.map_type("ASYNCFUNCTION")
30+
assert map_funcion == "METHOD"
31+
assert map_asyncfunction == "METHOD"
3032

3133

3234
def test_map_type_unknown_type(process_decorator_instance: DecoratorProcessor):

0 commit comments

Comments
 (0)