Skip to content

Commit

Permalink
Use callable() to check if the object is calllable (#1) (networkx#4678
Browse files Browse the repository at this point in the history
)

Co-authored-by: erbeusgriffincasper@gmail.com

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
  • Loading branch information
HarshCasper and deepsource-autofix[bot] authored May 18, 2021
1 parent 5658cb9 commit 45bd170
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion networkx/drawing/nx_agraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def clean_attrs(which, added):

# 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]), " "])
Expand Down
4 changes: 2 additions & 2 deletions networkx/linalg/attrmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -94,7 +94,7 @@ def value(u, v):
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":
Expand Down

0 comments on commit 45bd170

Please sign in to comment.