diff --git a/src/library_analyzer/processing/api/purity_analysis/_build_call_graph.py b/src/library_analyzer/processing/api/purity_analysis/_build_call_graph.py index 949263ea..d521c267 100644 --- a/src/library_analyzer/processing/api/purity_analysis/_build_call_graph.py +++ b/src/library_analyzer/processing/api/purity_analysis/_build_call_graph.py @@ -218,12 +218,12 @@ def _handle_unknown_call(self, call: Symbol, reason: Reasons) -> None: # Deal with the case that the call calls a function parameter. elif isinstance(call, Parameter): self.call_graph_forest.get_graph(reason.id).reasons.unknown_calls[call.id] = UnknownProto( - symbol=call, origin=reason.function_scope.symbol, + symbol=call, origin=reason.function_scope.symbol if reason.function_scope else None, ) else: self.call_graph_forest.get_graph(reason.id).reasons.unknown_calls[call.id] = UnknownProto( - symbol=call, origin=reason.function_scope.symbol, + symbol=call, origin=reason.function_scope.symbol if reason.function_scope else None, ) def _handle_cycles(self, removed_nodes: set[NodeID] | None = None) -> None: 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 a4c76d37..2a49efe4 100644 --- a/src/library_analyzer/processing/api/purity_analysis/_resolve_references.py +++ b/src/library_analyzer/processing/api/purity_analysis/_resolve_references.py @@ -476,7 +476,7 @@ def _find_value_references( import_def, inferred_node=inferred_node_def, # type: ignore[type-var] # import def is not None. ) - specified_import_def.id.name = specified_import_def.id.name + "." + specified_import_def.name + specified_import_def.id.name = specified_import_def.id.name + "." + specified_import_def.name # type: ignore[union-attr] # specified_import_def is not None. if specified_import_def: result_value_reference.referenced_symbols.append(specified_import_def) diff --git a/src/library_analyzer/processing/api/purity_analysis/model/_purity.py b/src/library_analyzer/processing/api/purity_analysis/model/_purity.py index 401b747f..711a460f 100644 --- a/src/library_analyzer/processing/api/purity_analysis/model/_purity.py +++ b/src/library_analyzer/processing/api/purity_analysis/model/_purity.py @@ -203,7 +203,7 @@ def to_dict(self, shorten: bool = False) -> dict[str, Any]: case _: raise TypeError(f"Unknown reason type: {reason}") if not shorten: - combined_reasons = { + combined_reasons: dict[str, Any] = { "NonLocalVariableRead": non_local_variable_reads, "NonLocalVariableWrite": non_local_variable_writes, "FileRead": file_reads, diff --git a/src/library_analyzer/processing/api/purity_analysis/model/_reference.py b/src/library_analyzer/processing/api/purity_analysis/model/_reference.py index d93d66d2..fd2ebcdc 100644 --- a/src/library_analyzer/processing/api/purity_analysis/model/_reference.py +++ b/src/library_analyzer/processing/api/purity_analysis/model/_reference.py @@ -186,9 +186,6 @@ def join_reasons_list(self, reasons_list: list[Reasons]) -> Reasons: result.join_reasons(reason) return result - def __iter__(self) -> Iterator[Symbol]: - return iter(self.writes_to.union(self.reads_from).union(self.calls)) - def join_reasons(self, other: Reasons) -> Reasons: """Join two Reasons objects. 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 38dd1a1b..d530aec6 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 @@ -251,7 +251,7 @@ def transform_reasons(reasons: dict[NodeID, Reasons]) -> dict[str, SimpleReasons else ( f"{target_reference.symbol.__class__.__name__}.{target_reference.symbol.klass.name}.{target_reference.symbol.node.member}.line{target_reference.symbol.node.node.fromlineno}" # type: ignore[union-attr] # "None" has no attribute "name" but since we check for the type before, this is fine if isinstance(target_reference.symbol, InstanceVariable) - else f"{target_reference.symbol.__class__.__name__}.{target_reference.symbol.node.name}.line{target_reference.symbol.node.fromlineno}" + else f"{target_reference.symbol.__class__.__name__}.{target_reference.symbol.node.name}.line{target_reference.symbol.node.fromlineno}" # type: ignore[union-attr] # "None" has no attribute "name" but since we check for the type before, this is fine ) ) for target_reference in function_references.writes_to.values() @@ -263,7 +263,7 @@ def transform_reasons(reasons: dict[NodeID, Reasons]) -> dict[str, SimpleReasons else ( f"{value_reference.symbol.__class__.__name__}.{value_reference.symbol.klass.name}.{value_reference.symbol.node.member}.line{value_reference.symbol.node.node.fromlineno}" # type: ignore[union-attr] # "None" has no attribute "name" but since we check for the type before, this is fine if isinstance(value_reference.symbol, InstanceVariable) - else f"{value_reference.symbol.__class__.__name__}.{value_reference.symbol.node.name}.line{value_reference.symbol.node.fromlineno}" + else f"{value_reference.symbol.__class__.__name__}.{value_reference.symbol.node.name}.line{value_reference.symbol.node.fromlineno}" # type: ignore[union-attr] # "None" has no attribute "name" but since we check for the type before, this is fine ) ) for value_reference in function_references.reads_from.values()