Update pylint to 1.7.6, uncap networkx

This review squashes:
    Iac9afc7766d3640815dc20cfd6de1245d36a09cc
    Ie894b5801bd7b3815432882cd626941e89d9f9a1

We need to do this as we can't fix pylint without networkx as that
failes requirements-chak due to us having a cap on networkx and we can't
uncap networkx as part of tripleo-buildimage installs without
constratints which gets us 2.1 and DIB desn't support 2.x

This is the commit message Iac9afc7766d3640815dc20cfd6de1245d36a09cc
---
One of the pylint dependencies has updated to be python3 only; this
version of pylint correctly caps things so it still works with
python2.

This also exposes that we need to uncap networkx due to
I34045f87ca19c2f184b040f4d89347374cce518b.  We should remain on
version 1 for now thanks to upper-constraints, but we need to maintain
the lower-constraint.
---

This is the commit message Ie894b5801bd7b3815432882cd626941e89d9f9a1
---
Support different versions of networkx

Since the entry of networkx 2.0 nodes has a different
behaviour. Checking if dg.nodes is iterable is enough to add
compatibility for new/older versions.
---

Change-Id: I82dc61fac6c156a4f0d574290c7632077aa53195
This commit is contained in:
Ian Wienand 2018-07-17 10:36:01 +10:00 committed by Tony Breeds
parent b79952af2a
commit 1107326723
3 changed files with 14 additions and 8 deletions

View File

@ -159,6 +159,12 @@ def create_graph(config, default_config, state):
# add the appropriate nodes and edges.
dg = nx.DiGraph()
# check about dg.nodes, to support different networkx versions
if hasattr(dg.nodes, '__iter__'):
dg_nodes = dg.nodes
else:
dg_nodes = dg.node
for config_entry in config:
# this should have been checked by generate_config
assert len(config_entry) == 1
@ -190,7 +196,7 @@ def create_graph(config, default_config, state):
# ensure node names are unique. networkx by default
# just appends the attribute to the node dict for
# existing nodes, which is not what we want.
if node.name in dg.node:
if node.name in dg_nodes:
raise BlockDeviceSetupException(
"Duplicate node name: %s" % (node.name))
logger.debug("Adding %s : %s", node.name, node)
@ -210,12 +216,12 @@ def create_graph(config, default_config, state):
logger.debug("Edges for %s: f:%s t:%s", name,
edges_from, edges_to)
for edge_from in edges_from:
if edge_from not in dg.node:
if edge_from not in dg_nodes:
raise BlockDeviceSetupException(
"Edge not defined: %s->%s" % (edge_from, name))
dg.add_edge(edge_from, name)
for edge_to in edges_to:
if edge_to not in dg.node:
if edge_to not in dg_nodes:
raise BlockDeviceSetupException(
"Edge not defined: %s->%s" % (name, edge_to))
dg.add_edge(name, edge_to)
@ -231,9 +237,9 @@ def create_graph(config, default_config, state):
# Topological sort (i.e. create a linear array that satisfies
# dependencies) and return the object list
call_order_nodes = nx.topological_sort(dg)
logger.debug("Call order: %s", list(call_order_nodes))
call_order = [dg.node[n]['obj'] for n in call_order_nodes]
call_order_nodes = list(nx.topological_sort(dg))
logger.debug("Call order: %s", call_order_nodes)
call_order = [dg_nodes[n]['obj'] for n in call_order_nodes]
return dg, call_order

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
Babel!=2.4.0,>=2.3.4 # BSD
networkx<2.0,>=1.10 # BSD
networkx>=1.10 # BSD
pbr!=2.1.0,>=2.0.0 # Apache-2.0
PyYAML>=3.12 # MIT
flake8<2.6.0,>=2.5.4 # MIT

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking<0.11,>=0.10.0
pylint==1.7.1 # GPLv2
pylint==1.7.6 # GPLv2
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD