Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
fix: linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukarade committed May 10, 2024
1 parent 91f16ec commit c379d65
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit c379d65

Please sign in to comment.