diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2021-05-26 16:39:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-26 17:39:15 -0400 |
commit | 90f877368227a66908311a381df146cf103a4001 (patch) | |
tree | a67ff06fd4acfe9d8a48bd00d0db77e4db2349a8 | |
parent | bdcc8b5877bfa60ae00bc124571816eed2913f3f (diff) | |
download | networkx-90f877368227a66908311a381df146cf103a4001.tar.gz |
Fix bad import pattern (#4839)
* Add a test to catch importing aliases.
* Add test for another bad import pattern.
* Fix one bad import pattern.
Adds __all__ to some modules where it was missing.
* RM networkx namespace test.
-rw-r--r-- | networkx/algorithms/chains.py | 2 | ||||
-rw-r--r-- | networkx/algorithms/smetric.py | 2 | ||||
-rw-r--r-- | networkx/classes/digraph.py | 2 | ||||
-rw-r--r-- | networkx/classes/graph.py | 2 | ||||
-rw-r--r-- | networkx/classes/multidigraph.py | 2 | ||||
-rw-r--r-- | networkx/classes/multigraph.py | 2 | ||||
-rw-r--r-- | networkx/readwrite/text.py | 2 | ||||
-rw-r--r-- | networkx/tests/test_import.py | 6 |
8 files changed, 20 insertions, 0 deletions
diff --git a/networkx/algorithms/chains.py b/networkx/algorithms/chains.py index a76941fb..da03aa38 100644 --- a/networkx/algorithms/chains.py +++ b/networkx/algorithms/chains.py @@ -3,6 +3,8 @@ import networkx as nx from networkx.utils import not_implemented_for +__all__ = ["chain_decomposition"] + @not_implemented_for("directed") @not_implemented_for("multigraph") diff --git a/networkx/algorithms/smetric.py b/networkx/algorithms/smetric.py index 5ea73036..e33f6702 100644 --- a/networkx/algorithms/smetric.py +++ b/networkx/algorithms/smetric.py @@ -1,5 +1,7 @@ import networkx as nx +__all__ = ["s_metric"] + def s_metric(G, normalized=True): """Returns the s-metric of graph. diff --git a/networkx/classes/digraph.py b/networkx/classes/digraph.py index 04cd6b5c..14da0b3f 100644 --- a/networkx/classes/digraph.py +++ b/networkx/classes/digraph.py @@ -14,6 +14,8 @@ from networkx.classes.reportviews import ( from networkx.exception import NetworkXError import networkx.convert as convert +__all__ = ["DiGraph"] + class DiGraph(Graph): """ diff --git a/networkx/classes/graph.py b/networkx/classes/graph.py index 216a37d2..6b0fb748 100644 --- a/networkx/classes/graph.py +++ b/networkx/classes/graph.py @@ -15,6 +15,8 @@ from networkx.classes.reportviews import NodeView, EdgeView, DegreeView from networkx.exception import NetworkXError import networkx.convert as convert +__all__ = ["Graph"] + class Graph: """ diff --git a/networkx/classes/multidigraph.py b/networkx/classes/multidigraph.py index b1594385..d8903606 100644 --- a/networkx/classes/multidigraph.py +++ b/networkx/classes/multidigraph.py @@ -14,6 +14,8 @@ from networkx.classes.reportviews import ( ) from networkx.exception import NetworkXError +__all__ = ["MultiDiGraph"] + class MultiDiGraph(MultiGraph, DiGraph): """A directed graph class that can store multiedges. diff --git a/networkx/classes/multigraph.py b/networkx/classes/multigraph.py index fc35e699..f8044c62 100644 --- a/networkx/classes/multigraph.py +++ b/networkx/classes/multigraph.py @@ -7,6 +7,8 @@ from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.reportviews import MultiEdgeView, MultiDegreeView from networkx import NetworkXError +__all__ = ["MultiGraph"] + class MultiGraph(Graph): """ diff --git a/networkx/readwrite/text.py b/networkx/readwrite/text.py index 67343d4d..b38b08de 100644 --- a/networkx/readwrite/text.py +++ b/networkx/readwrite/text.py @@ -2,6 +2,8 @@ Text-based visual representations of graphs """ +__all__ = ["forest_str"] + def forest_str(graph, with_labels=True, sources=None, write=None, ascii_only=False): """ diff --git a/networkx/tests/test_import.py b/networkx/tests/test_import.py new file mode 100644 index 00000000..6563439b --- /dev/null +++ b/networkx/tests/test_import.py @@ -0,0 +1,6 @@ +import pytest + + +def test_namespace_alias(): + with pytest.raises(ImportError): + from networkx import nx |