Open xennygrimmato opened 6 months ago
ff4cc2a4a4
)[!TIP] I'll email you at vstulsyan@gmail.com when I complete this pull request!
Here are the GitHub Actions logs prior to making any changes:
fd8af0e
Checking code_to_data_dependency_graph.py for syntax errors... ✅ code_to_data_dependency_graph.py has no syntax errors!
1/1 ✓Checking code_to_data_dependency_graph.py for syntax errors... ✅ code_to_data_dependency_graph.py has no syntax errors!
Sandbox passed on the latest master
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
code_to_data_dependency_graph.py
✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/c79c4790e6bdf5ae1efca4ed5de54d41692a81de Edit
Modify code_to_data_dependency_graph.py with contents:
• Add type hints to the `get_deps` function. Specify the type of `code` as `str` and the return type as `Tuple[Dict[str, int], Dict[str, Set[str]]]`.
• Inside the function, add type hints to `declaration_line_num_map` as `Dict[str, int]` and `ddg` as `Dict[str, Set[str]]`.
--- +++ @@ -1,13 +1,13 @@ import ast -def get_deps(code): +def get_deps(code: str) -> Tuple[Dict[str, int], Dict[str, Set[str]]]: body = ast.parse(code) _, statements = next(ast.iter_fields(body)) # Line no. at which each identifier was first seen - declaration_line_num_map = {} - ddg = {} + declaration_line_num_map: Dict[str, int] = {} + ddg: Dict[str, Set[str]] = {} def update_decls(lhs_vars_input, num): lhs_var_nodes = []
code_to_data_dependency_graph.py
✓ Edit
Check code_to_data_dependency_graph.py with contents:
Ran GitHub Actions for c79c4790e6bdf5ae1efca4ed5de54d41692a81de:
code_to_data_dependency_graph.py
✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/3c12f4211dc71f32a005254b8df188056f7f705a Edit
Modify code_to_data_dependency_graph.py with contents:
• For the `MethodLevelDDGs` class, add type hints to the `__init__` method indicating `code` as `str`.
• In the `get_methods` method, specify the return type as `List[ast.FunctionDef]`.
• In the `recursive_ddg` method, add type hints to the parameter `fn_root_node` as `ast.FunctionDef` and the return type as `Dict[str, Set[str]]`.
--- +++ @@ -1,13 +1,13 @@ import ast -def get_deps(code): +def get_deps(code: str) -> Tuple[Dict[str, int], Dict[str, Set[str]]]: body = ast.parse(code) _, statements = next(ast.iter_fields(body)) # Line no. at which each identifier was first seen - declaration_line_num_map = {} - ddg = {} + declaration_line_num_map: Dict[str, int] = {} + ddg: Dict[str, Set[str]] = {} def update_decls(lhs_vars_input, num): lhs_var_nodes = [] @@ -51,7 +51,7 @@ def __init__(self, code): self.parsed_ast = ast.parse(code) - def get_methods(self): + def get_methods(self) -> List[ast.FunctionDef]: fn_nodes = [] class FnVisitor(ast.NodeVisitor):
code_to_data_dependency_graph.py
✓ Edit
Check code_to_data_dependency_graph.py with contents:
Ran GitHub Actions for 3c12f4211dc71f32a005254b8df188056f7f705a:
code_to_data_dependency_graph.py
✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/1b4a5b7ff4b45c1a80766af51462d814db67e445 Edit
Modify code_to_data_dependency_graph.py with contents:
• Add type hints to the `fn_ddgs` function. Specify the type of `code` as `str` and the return type as `Dict[str, Dict[str, Set[str]]]`.
--- +++ @@ -1,13 +1,13 @@ import ast -def get_deps(code): +def get_deps(code: str) -> Tuple[Dict[str, int], Dict[str, Set[str]]]: body = ast.parse(code) _, statements = next(ast.iter_fields(body)) # Line no. at which each identifier was first seen - declaration_line_num_map = {} - ddg = {} + declaration_line_num_map: Dict[str, int] = {} + ddg: Dict[str, Set[str]] = {} def update_decls(lhs_vars_input, num): lhs_var_nodes = [] @@ -51,7 +51,7 @@ def __init__(self, code): self.parsed_ast = ast.parse(code) - def get_methods(self): + def get_methods(self) -> List[ast.FunctionDef]: fn_nodes = [] class FnVisitor(ast.NodeVisitor): @@ -90,7 +90,7 @@ return ddg -def fn_ddgs(code): +def fn_ddgs(code: str) -> Dict[str, Dict[str, Set[str]]]: method_level_ddgs = MethodLevelDDGs(code) methods = method_level_ddgs.get_methods() ddgs = {method.name: method_level_ddgs.recursive_ddg(method) for method in methods}
code_to_data_dependency_graph.py
✓ Edit
Check code_to_data_dependency_graph.py with contents:
Ran GitHub Actions for 1b4a5b7ff4b45c1a80766af51462d814db67e445:
var_ddg.py
✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/c610f1763e9196c198d8c38041e72c25897d0136 Edit
Modify var_ddg.py with contents:
• In the `MyVisitor` class, add type hints to the `__init__` method indicating `path` as `str`.
• For the `ast_visit` method, add type hints to `node` as `ast.AST`, `level` as `int`, and specify the return type as `None`.
• In the `construct_ddg` method, specify the return type as `None`.
• For the `get_function_level_ddg` method, add type hints to specify the return type as `Dict[ast.FunctionDef, Set[Tuple[str, str]]]`.
--- +++ @@ -2,7 +2,7 @@ class MyVisitor: - def __init__(self, path): + def __init__(self, path: str): self.GLOBAL_FN = ast.FunctionDef(name='_global_') # FunctionDef -> set(x, y) such that x reads y @@ -67,8 +67,10 @@ if is_fn: self.fn_stack.pop() - def construct_ddg(self): + def construct_ddg(self) -> None: self.ast_visit(self.tree) def get_function_level_ddg(self): return {fn.name: value for fn, value in self.fn_to_ddg_map.items()} + def get_function_level_ddg(self) -> Dict[ast.FunctionDef, Set[Tuple[str, str]]]: + return {fn.name: value for fn, value in self.fn_to_ddg_map.items()}
var_ddg.py
✓ Edit
Check var_ddg.py with contents:
Ran GitHub Actions for c610f1763e9196c198d8c38041e72c25897d0136:
I have finished reviewing the code for completeness. I did not find errors for sweep/add_type_hints_for_all_py_files
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.Something wrong? Let us know.
This is an automated message generated by Sweep AI.
Details
Add typehints to all the code that is used by main.py (e.g. code_to_data_dependency_graph, var_ddg)
Checklist
- [X] Modify `code_to_data_dependency_graph.py` ✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/c79c4790e6bdf5ae1efca4ed5de54d41692a81de [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/code_to_data_dependency_graph.py#L4-L47) - [X] Running GitHub Actions for `code_to_data_dependency_graph.py` ✓ [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/code_to_data_dependency_graph.py#L4-L47) - [X] Modify `code_to_data_dependency_graph.py` ✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/3c12f4211dc71f32a005254b8df188056f7f705a [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/code_to_data_dependency_graph.py#L49-L90) - [X] Running GitHub Actions for `code_to_data_dependency_graph.py` ✓ [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/code_to_data_dependency_graph.py#L49-L90) - [X] Modify `code_to_data_dependency_graph.py` ✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/1b4a5b7ff4b45c1a80766af51462d814db67e445 [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/code_to_data_dependency_graph.py#L93-L96) - [X] Running GitHub Actions for `code_to_data_dependency_graph.py` ✓ [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/code_to_data_dependency_graph.py#L93-L96) - [X] Modify `var_ddg.py` ✓ https://github.com/xennygrimmato/py-data-dependency-graph/commit/c610f1763e9196c198d8c38041e72c25897d0136 [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/var_ddg.py#L4-L73) - [X] Running GitHub Actions for `var_ddg.py` ✓ [Edit](https://github.com/xennygrimmato/py-data-dependency-graph/edit/sweep/add_type_hints_for_all_py_files/var_ddg.py#L4-L73)