From 0c24103f80031aac604035711a24ba4df91bcfc9 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:57:50 +0000 Subject: [PATCH] style: apply automated linter fixes --- .../api/purity_analysis/_get_module_data.py | 4 +++- .../purity_analysis/_resolve_references.py | 3 ++- .../purity_analysis/test_get_module_data.py | 21 ++++++++++++++++--- .../api/purity_analysis/test_infer_purity.py | 5 ++++- .../test_resolve_references.py | 12 ++++++++--- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/library_analyzer/processing/api/purity_analysis/_get_module_data.py b/src/library_analyzer/processing/api/purity_analysis/_get_module_data.py index 2ba86f7b..f15993c5 100644 --- a/src/library_analyzer/processing/api/purity_analysis/_get_module_data.py +++ b/src/library_analyzer/processing/api/purity_analysis/_get_module_data.py @@ -194,7 +194,9 @@ def get_symbol(self, node: astroid.NodeNG, current_scope: astroid.NodeNG | None) astroid.TryExcept() | astroid.TryFinally() ): # TODO: can we summarize Lambda and ListComp here? -> only if nodes in try except are not global return LocalVariable( - node=node, id=NodeID.calc_node_id(node), name=node.name if hasattr(node, "name") else "None", + node=node, + id=NodeID.calc_node_id(node), + name=node.name if hasattr(node, "name") else "None", ) # This line is a fallback but should never be reached diff --git a/src/library_analyzer/processing/api/purity_analysis/_resolve_references.py b/src/library_analyzer/processing/api/purity_analysis/_resolve_references.py index 598b5e86..7f4378e6 100644 --- a/src/library_analyzer/processing/api/purity_analysis/_resolve_references.py +++ b/src/library_analyzer/processing/api/purity_analysis/_resolve_references.py @@ -418,7 +418,8 @@ def _find_target_references( continue # Do not add functions that are not of the current class (or superclass). if function.symbol.name not in klass.class_variables or not is_function_of_class( - function.symbol.node, klass, + function.symbol.node, + klass, ): # Collect all functions of superclasses for the current klass instance. super_functions = [] diff --git a/tests/library_analyzer/processing/api/purity_analysis/test_get_module_data.py b/tests/library_analyzer/processing/api/purity_analysis/test_get_module_data.py index 889173cc..f230c89f 100644 --- a/tests/library_analyzer/processing/api/purity_analysis/test_get_module_data.py +++ b/tests/library_analyzer/processing/api/purity_analysis/test_get_module_data.py @@ -324,7 +324,12 @@ def transform_member_access(member_access: MemberAccess) -> str: ), ( astroid.ClassDef( - "A", lineno=2, col_offset=3, parent=astroid.Module("numpy"), end_lineno=2, end_col_offset=10, + "A", + lineno=2, + col_offset=3, + parent=astroid.Module("numpy"), + end_lineno=2, + end_col_offset=10, ), "numpy.A.2.3", ), @@ -343,7 +348,12 @@ def transform_member_access(member_access: MemberAccess) -> str: lineno=1, col_offset=0, parent=astroid.ClassDef( - "A", lineno=2, col_offset=3, parent=astroid.Module("numpy"), end_lineno=2, end_col_offset=10, + "A", + lineno=2, + col_offset=3, + parent=astroid.Module("numpy"), + end_lineno=2, + end_col_offset=10, ), ), "numpy.global_func.1.0", @@ -371,7 +381,12 @@ def transform_member_access(member_access: MemberAccess) -> str: lineno=1, col_offset=0, parent=astroid.ClassDef( - "A", lineno=2, col_offset=3, parent=astroid.Module("numpy"), end_lineno=2, end_col_offset=10, + "A", + lineno=2, + col_offset=3, + parent=astroid.Module("numpy"), + end_lineno=2, + end_col_offset=10, ), ), ), diff --git a/tests/library_analyzer/processing/api/purity_analysis/test_infer_purity.py b/tests/library_analyzer/processing/api/purity_analysis/test_infer_purity.py index fe38c4dc..717a413f 100644 --- a/tests/library_analyzer/processing/api/purity_analysis/test_infer_purity.py +++ b/tests/library_analyzer/processing/api/purity_analysis/test_infer_purity.py @@ -227,7 +227,10 @@ def g(): { "__init__.line3": Pure(), "f.line9": SimpleImpure( - {"NonLocalVariableRead.ClassVariable.B.upper_class", "NonLocalVariableRead.InstanceVariable.A.name"}, + { + "NonLocalVariableRead.ClassVariable.B.upper_class", + "NonLocalVariableRead.InstanceVariable.A.name", + }, ), "g.line13": SimpleImpure({ "NonLocalVariableWrite.ClassVariable.B.upper_class", diff --git a/tests/library_analyzer/processing/api/purity_analysis/test_resolve_references.py b/tests/library_analyzer/processing/api/purity_analysis/test_resolve_references.py index f6c62a36..611d5edd 100644 --- a/tests/library_analyzer/processing/api/purity_analysis/test_resolve_references.py +++ b/tests/library_analyzer/processing/api/purity_analysis/test_resolve_references.py @@ -1542,13 +1542,19 @@ def try_except_else_finally(num1, num2, num3): ReferenceTestNode("num3.line12", "FunctionDef.try_except_else_finally", ["Parameter.num3.line2"]), ReferenceTestNode("print.line14", "FunctionDef.try_except_else_finally", ["Builtin.print"]), ReferenceTestNode( - "result.line14", "FunctionDef.try_except_else_finally", ["LocalVariable.result.line4"], + "result.line14", + "FunctionDef.try_except_else_finally", + ["LocalVariable.result.line4"], ), ReferenceTestNode( - "result2.line14", "FunctionDef.try_except_else_finally", ["LocalVariable.result2.line10"], + "result2.line14", + "FunctionDef.try_except_else_finally", + ["LocalVariable.result2.line10"], ), ReferenceTestNode( - "final.line14", "FunctionDef.try_except_else_finally", ["LocalVariable.final.line12"], + "final.line14", + "FunctionDef.try_except_else_finally", + ["LocalVariable.final.line12"], ), ], ),