From 45bd170c5493347f38616fc3ecbab55fb615a91b Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 19 May 2021 03:45:54 +0530 Subject: Use `callable()` to check if the object is calllable (#1) (#4678) Co-authored-by: erbeusgriffincasper@gmail.com Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- networkx/drawing/nx_agraph.py | 2 +- networkx/linalg/attrmatrix.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/networkx/drawing/nx_agraph.py b/networkx/drawing/nx_agraph.py index ad2a79ea..0e3d3897 100644 --- a/networkx/drawing/nx_agraph.py +++ b/networkx/drawing/nx_agraph.py @@ -398,7 +398,7 @@ def view_pygraphviz( # If the user passed in an edgelabel, we update the labels for all edges. if edgelabel is not None: - if not hasattr(edgelabel, "__call__"): + if not callable(edgelabel): def func(data): return "".join([" ", str(data[edgelabel]), " "]) diff --git a/networkx/linalg/attrmatrix.py b/networkx/linalg/attrmatrix.py index ffa6fa5b..6d9eab6d 100644 --- a/networkx/linalg/attrmatrix.py +++ b/networkx/linalg/attrmatrix.py @@ -34,7 +34,7 @@ def _node_value(G, node_attr): def value(u): return u - elif not hasattr(node_attr, "__call__"): + elif not callable(node_attr): # assume it is a key for the node attribute dictionary def value(u): return G.nodes[u][node_attr] @@ -94,7 +94,7 @@ def _edge_value(G, edge_attr): def value(u, v): return 1 - elif not hasattr(edge_attr, "__call__"): + elif not callable(edge_attr): # assume it is a key for the edge attribute dictionary if edge_attr == "weight": -- cgit v1.2.1