summaryrefslogtreecommitdiff
path: root/networkx/readwrite
diff options
context:
space:
mode:
authorMridul Seth <seth.mridul@gmail.com>2022-06-02 19:54:09 +0400
committerGitHub <noreply@github.com>2022-06-02 08:54:09 -0700
commit5c0b11afb4c0882a070d522ef3fa41482ba935d3 (patch)
tree1b8f21413afd65617420203cf834a8d15d8282ab /networkx/readwrite
parent4dba24ba22fc8c4906e16f67b5cf103ee0a830b3 (diff)
downloadnetworkx-5c0b11afb4c0882a070d522ef3fa41482ba935d3.tar.gz
Use isort with pre-commit to enforce import guidelines (#5659)
* Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
Diffstat (limited to 'networkx/readwrite')
-rw-r--r--networkx/readwrite/adjlist.py2
-rw-r--r--networkx/readwrite/edgelist.py2
-rw-r--r--networkx/readwrite/gexf.py9
-rw-r--r--networkx/readwrite/gml.py10
-rw-r--r--networkx/readwrite/gpickle.py4
-rw-r--r--networkx/readwrite/graph6.py2
-rw-r--r--networkx/readwrite/graphml.py1
-rw-r--r--networkx/readwrite/json_graph/adjacency.py1
-rw-r--r--networkx/readwrite/json_graph/jit.py1
-rw-r--r--networkx/readwrite/json_graph/node_link.py1
-rw-r--r--networkx/readwrite/json_graph/tests/test_adjacency.py2
-rw-r--r--networkx/readwrite/json_graph/tests/test_cytoscape.py4
-rw-r--r--networkx/readwrite/json_graph/tests/test_jit.py2
-rw-r--r--networkx/readwrite/json_graph/tests/test_node_link.py2
-rw-r--r--networkx/readwrite/json_graph/tests/test_tree.py2
-rw-r--r--networkx/readwrite/json_graph/tree.py1
-rw-r--r--networkx/readwrite/multiline_adjlist.py2
-rw-r--r--networkx/readwrite/nx_shp.py1
-rw-r--r--networkx/readwrite/sparse6.py2
-rw-r--r--networkx/readwrite/tests/test_adjlist.py6
-rw-r--r--networkx/readwrite/tests/test_edgelist.py8
-rw-r--r--networkx/readwrite/tests/test_gexf.py1
-rw-r--r--networkx/readwrite/tests/test_gml.py12
-rw-r--r--networkx/readwrite/tests/test_gpickle.py2
-rw-r--r--networkx/readwrite/tests/test_graph6.py5
-rw-r--r--networkx/readwrite/tests/test_graphml.py10
-rw-r--r--networkx/readwrite/tests/test_leda.py3
-rw-r--r--networkx/readwrite/tests/test_p2g.py3
-rw-r--r--networkx/readwrite/tests/test_pajek.py5
-rw-r--r--networkx/readwrite/tests/test_shp.py1
-rw-r--r--networkx/readwrite/tests/test_sparse6.py5
-rw-r--r--networkx/readwrite/tests/test_text.py4
32 files changed, 72 insertions, 44 deletions
diff --git a/networkx/readwrite/adjlist.py b/networkx/readwrite/adjlist.py
index 6dc89414..c27b836d 100644
--- a/networkx/readwrite/adjlist.py
+++ b/networkx/readwrite/adjlist.py
@@ -24,8 +24,8 @@ adjacency list (anything following the # in a line is a comment)::
__all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"]
-from networkx.utils import open_file
import networkx as nx
+from networkx.utils import open_file
def generate_adjlist(G, delimiter=" "):
diff --git a/networkx/readwrite/edgelist.py b/networkx/readwrite/edgelist.py
index 4c021d79..558cbaea 100644
--- a/networkx/readwrite/edgelist.py
+++ b/networkx/readwrite/edgelist.py
@@ -36,8 +36,8 @@ __all__ = [
"write_weighted_edgelist",
]
-from networkx.utils import open_file
import networkx as nx
+from networkx.utils import open_file
def generate_edgelist(G, delimiter=" ", data=True):
diff --git a/networkx/readwrite/gexf.py b/networkx/readwrite/gexf.py
index a331e6df..b7c5a5ac 100644
--- a/networkx/readwrite/gexf.py
+++ b/networkx/readwrite/gexf.py
@@ -18,18 +18,17 @@ specification and http://gexf.net/basic.html for examples.
"""
import itertools
import time
-
-import networkx as nx
-from networkx.utils import open_file
-
from xml.etree.ElementTree import (
Element,
ElementTree,
SubElement,
- tostring,
register_namespace,
+ tostring,
)
+import networkx as nx
+from networkx.utils import open_file
+
__all__ = ["write_gexf", "read_gexf", "relabel_gexf_graph", "generate_gexf"]
diff --git a/networkx/readwrite/gml.py b/networkx/readwrite/gml.py
index 0ecba104..1a14b80b 100644
--- a/networkx/readwrite/gml.py
+++ b/networkx/readwrite/gml.py
@@ -27,19 +27,19 @@ For additional documentation on the GML file format, please see the
Several example graphs in GML format may be found on Mark Newman's
`Network data page <http://www-personal.umich.edu/~mejn/netdata/>`_.
"""
-from io import StringIO
+import html.entities as htmlentitydefs
+import re
+import warnings
from ast import literal_eval
from collections import defaultdict
from enum import Enum
+from io import StringIO
from typing import Any, NamedTuple
+
import networkx as nx
from networkx.exception import NetworkXError
from networkx.utils import open_file
-import warnings
-import re
-import html.entities as htmlentitydefs
-
__all__ = ["read_gml", "parse_gml", "generate_gml", "write_gml"]
diff --git a/networkx/readwrite/gpickle.py b/networkx/readwrite/gpickle.py
index b6029710..0054afd8 100644
--- a/networkx/readwrite/gpickle.py
+++ b/networkx/readwrite/gpickle.py
@@ -27,11 +27,11 @@ See https://docs.python.org/3/library/pickle.html
__all__ = ["read_gpickle", "write_gpickle"]
-from networkx.utils import open_file
-
import pickle
import warnings
+from networkx.utils import open_file
+
@open_file(1, mode="wb")
def write_gpickle(G, path, protocol=pickle.HIGHEST_PROTOCOL):
diff --git a/networkx/readwrite/graph6.py b/networkx/readwrite/graph6.py
index 886ba299..cb579ecd 100644
--- a/networkx/readwrite/graph6.py
+++ b/networkx/readwrite/graph6.py
@@ -14,7 +14,7 @@ from itertools import islice
import networkx as nx
from networkx.exception import NetworkXError
-from networkx.utils import open_file, not_implemented_for
+from networkx.utils import not_implemented_for, open_file
__all__ = ["from_graph6_bytes", "read_graph6", "to_graph6_bytes", "write_graph6"]
diff --git a/networkx/readwrite/graphml.py b/networkx/readwrite/graphml.py
index 2e98373c..0a175922 100644
--- a/networkx/readwrite/graphml.py
+++ b/networkx/readwrite/graphml.py
@@ -43,7 +43,6 @@ for examples.
import warnings
from collections import defaultdict
-
import networkx as nx
from networkx.utils import open_file
diff --git a/networkx/readwrite/json_graph/adjacency.py b/networkx/readwrite/json_graph/adjacency.py
index 4b869e4f..7962ea9a 100644
--- a/networkx/readwrite/json_graph/adjacency.py
+++ b/networkx/readwrite/json_graph/adjacency.py
@@ -1,4 +1,5 @@
from itertools import chain
+
import networkx as nx
__all__ = ["adjacency_data", "adjacency_graph"]
diff --git a/networkx/readwrite/json_graph/jit.py b/networkx/readwrite/json_graph/jit.py
index 430a5162..043f1a1f 100644
--- a/networkx/readwrite/json_graph/jit.py
+++ b/networkx/readwrite/json_graph/jit.py
@@ -28,6 +28,7 @@ var json = [
import json
import warnings
+
import networkx as nx
from networkx.utils.decorators import not_implemented_for
diff --git a/networkx/readwrite/json_graph/node_link.py b/networkx/readwrite/json_graph/node_link.py
index c16adda5..be186583 100644
--- a/networkx/readwrite/json_graph/node_link.py
+++ b/networkx/readwrite/json_graph/node_link.py
@@ -1,4 +1,5 @@
from itertools import chain, count
+
import networkx as nx
__all__ = ["node_link_data", "node_link_graph"]
diff --git a/networkx/readwrite/json_graph/tests/test_adjacency.py b/networkx/readwrite/json_graph/tests/test_adjacency.py
index 57a2a6b1..48f34404 100644
--- a/networkx/readwrite/json_graph/tests/test_adjacency.py
+++ b/networkx/readwrite/json_graph/tests/test_adjacency.py
@@ -1,5 +1,7 @@
import json
+
import pytest
+
import networkx as nx
from networkx.readwrite.json_graph import adjacency_data, adjacency_graph
diff --git a/networkx/readwrite/json_graph/tests/test_cytoscape.py b/networkx/readwrite/json_graph/tests/test_cytoscape.py
index 64cfa577..cdb101f9 100644
--- a/networkx/readwrite/json_graph/tests/test_cytoscape.py
+++ b/networkx/readwrite/json_graph/tests/test_cytoscape.py
@@ -1,7 +1,9 @@
+import copy
import json
+
import pytest
+
import networkx as nx
-import copy
from networkx.readwrite.json_graph import cytoscape_data, cytoscape_graph
diff --git a/networkx/readwrite/json_graph/tests/test_jit.py b/networkx/readwrite/json_graph/tests/test_jit.py
index 9a2ef682..309c4055 100644
--- a/networkx/readwrite/json_graph/tests/test_jit.py
+++ b/networkx/readwrite/json_graph/tests/test_jit.py
@@ -1,5 +1,7 @@
import json
+
import pytest
+
import networkx as nx
from networkx.readwrite.json_graph import jit_data, jit_graph
diff --git a/networkx/readwrite/json_graph/tests/test_node_link.py b/networkx/readwrite/json_graph/tests/test_node_link.py
index e5773d26..bc46e7ba 100644
--- a/networkx/readwrite/json_graph/tests/test_node_link.py
+++ b/networkx/readwrite/json_graph/tests/test_node_link.py
@@ -1,5 +1,7 @@
import json
+
import pytest
+
import networkx as nx
from networkx.readwrite.json_graph import node_link_data, node_link_graph
diff --git a/networkx/readwrite/json_graph/tests/test_tree.py b/networkx/readwrite/json_graph/tests/test_tree.py
index 848edd0b..ea19810e 100644
--- a/networkx/readwrite/json_graph/tests/test_tree.py
+++ b/networkx/readwrite/json_graph/tests/test_tree.py
@@ -1,5 +1,7 @@
import json
+
import pytest
+
import networkx as nx
from networkx.readwrite.json_graph import tree_data, tree_graph
diff --git a/networkx/readwrite/json_graph/tree.py b/networkx/readwrite/json_graph/tree.py
index 615907ee..ab7098c5 100644
--- a/networkx/readwrite/json_graph/tree.py
+++ b/networkx/readwrite/json_graph/tree.py
@@ -1,4 +1,5 @@
from itertools import chain
+
import networkx as nx
__all__ = ["tree_data", "tree_graph"]
diff --git a/networkx/readwrite/multiline_adjlist.py b/networkx/readwrite/multiline_adjlist.py
index 73d783e4..83986851 100644
--- a/networkx/readwrite/multiline_adjlist.py
+++ b/networkx/readwrite/multiline_adjlist.py
@@ -32,8 +32,8 @@ __all__ = [
"read_multiline_adjlist",
]
-from networkx.utils import open_file
import networkx as nx
+from networkx.utils import open_file
def generate_multiline_adjlist(G, delimiter=" "):
diff --git a/networkx/readwrite/nx_shp.py b/networkx/readwrite/nx_shp.py
index 58acc757..dd487120 100644
--- a/networkx/readwrite/nx_shp.py
+++ b/networkx/readwrite/nx_shp.py
@@ -12,6 +12,7 @@ interoperability among Esri and other software products."
See https://en.wikipedia.org/wiki/Shapefile for additional information.
"""
import warnings
+
import networkx as nx
__all__ = ["read_shp", "write_shp"]
diff --git a/networkx/readwrite/sparse6.py b/networkx/readwrite/sparse6.py
index 03e136de..e7c36383 100644
--- a/networkx/readwrite/sparse6.py
+++ b/networkx/readwrite/sparse6.py
@@ -13,8 +13,8 @@ For more information, see the `sparse6`_ homepage.
"""
import networkx as nx
from networkx.exception import NetworkXError
-from networkx.utils import open_file, not_implemented_for
from networkx.readwrite.graph6 import data_to_n, n_to_data
+from networkx.utils import not_implemented_for, open_file
__all__ = ["from_sparse6_bytes", "read_sparse6", "to_sparse6_bytes", "write_sparse6"]
diff --git a/networkx/readwrite/tests/test_adjlist.py b/networkx/readwrite/tests/test_adjlist.py
index 2713895c..aecfb87e 100644
--- a/networkx/readwrite/tests/test_adjlist.py
+++ b/networkx/readwrite/tests/test_adjlist.py
@@ -2,11 +2,13 @@
Unit tests for adjlist.
"""
import io
-import pytest
import os
import tempfile
+
+import pytest
+
import networkx as nx
-from networkx.utils import nodes_equal, edges_equal, graphs_equal
+from networkx.utils import edges_equal, graphs_equal, nodes_equal
class TestAdjlist:
diff --git a/networkx/readwrite/tests/test_edgelist.py b/networkx/readwrite/tests/test_edgelist.py
index b4672656..abd1d3c7 100644
--- a/networkx/readwrite/tests/test_edgelist.py
+++ b/networkx/readwrite/tests/test_edgelist.py
@@ -1,15 +1,15 @@
"""
Unit tests for edgelists.
"""
-import pytest
import io
-import tempfile
import os
+import tempfile
import textwrap
-import networkx as nx
-from networkx.utils import nodes_equal, edges_equal, graphs_equal
+import pytest
+import networkx as nx
+from networkx.utils import edges_equal, graphs_equal, nodes_equal
edges_no_data = textwrap.dedent(
"""
diff --git a/networkx/readwrite/tests/test_gexf.py b/networkx/readwrite/tests/test_gexf.py
index 6dcc85fa..7166c099 100644
--- a/networkx/readwrite/tests/test_gexf.py
+++ b/networkx/readwrite/tests/test_gexf.py
@@ -1,5 +1,6 @@
import io
import time
+
import pytest
import networkx as nx
diff --git a/networkx/readwrite/tests/test_gml.py b/networkx/readwrite/tests/test_gml.py
index 53dea957..19fb7ed0 100644
--- a/networkx/readwrite/tests/test_gml.py
+++ b/networkx/readwrite/tests/test_gml.py
@@ -1,15 +1,17 @@
-from ast import literal_eval
import codecs
-from contextlib import contextmanager
import io
import math
-import pytest
-import networkx as nx
-from networkx.readwrite.gml import literal_stringizer, literal_destringizer
import os
import tempfile
+from ast import literal_eval
+from contextlib import contextmanager
from textwrap import dedent
+import pytest
+
+import networkx as nx
+from networkx.readwrite.gml import literal_destringizer, literal_stringizer
+
class TestGraph:
@classmethod
diff --git a/networkx/readwrite/tests/test_gpickle.py b/networkx/readwrite/tests/test_gpickle.py
index 5059d6db..3ef83b51 100644
--- a/networkx/readwrite/tests/test_gpickle.py
+++ b/networkx/readwrite/tests/test_gpickle.py
@@ -2,7 +2,7 @@ import os
import tempfile
import networkx as nx
-from networkx.utils import nodes_equal, edges_equal, graphs_equal
+from networkx.utils import edges_equal, graphs_equal, nodes_equal
class TestGpickle:
diff --git a/networkx/readwrite/tests/test_graph6.py b/networkx/readwrite/tests/test_graph6.py
index 065fbb50..062a96f0 100644
--- a/networkx/readwrite/tests/test_graph6.py
+++ b/networkx/readwrite/tests/test_graph6.py
@@ -1,10 +1,11 @@
-from io import BytesIO
import tempfile
+from io import BytesIO
+
import pytest
import networkx as nx
import networkx.readwrite.graph6 as g6
-from networkx.utils import nodes_equal, edges_equal
+from networkx.utils import edges_equal, nodes_equal
class TestGraph6Utils:
diff --git a/networkx/readwrite/tests/test_graphml.py b/networkx/readwrite/tests/test_graphml.py
index c26220c8..cc371325 100644
--- a/networkx/readwrite/tests/test_graphml.py
+++ b/networkx/readwrite/tests/test_graphml.py
@@ -1,10 +1,12 @@
+import io
+import os
+import tempfile
+
import pytest
+
import networkx as nx
-from networkx.utils import nodes_equal, edges_equal
from networkx.readwrite.graphml import GraphMLWriter
-import io
-import tempfile
-import os
+from networkx.utils import edges_equal, nodes_equal
class BaseGraphML:
diff --git a/networkx/readwrite/tests/test_leda.py b/networkx/readwrite/tests/test_leda.py
index 03e2b68d..8ac5ecc3 100644
--- a/networkx/readwrite/tests/test_leda.py
+++ b/networkx/readwrite/tests/test_leda.py
@@ -1,6 +1,7 @@
-import networkx as nx
import io
+import networkx as nx
+
class TestLEDA:
def test_parse_leda(self):
diff --git a/networkx/readwrite/tests/test_p2g.py b/networkx/readwrite/tests/test_p2g.py
index 93ab1381..8280870f 100644
--- a/networkx/readwrite/tests/test_p2g.py
+++ b/networkx/readwrite/tests/test_p2g.py
@@ -1,5 +1,6 @@
-import networkx as nx
import io
+
+import networkx as nx
from networkx.readwrite.p2g import read_p2g, write_p2g
from networkx.utils import edges_equal
diff --git a/networkx/readwrite/tests/test_pajek.py b/networkx/readwrite/tests/test_pajek.py
index d5b6f728..e617c3fc 100644
--- a/networkx/readwrite/tests/test_pajek.py
+++ b/networkx/readwrite/tests/test_pajek.py
@@ -1,10 +1,11 @@
"""
Pajek tests
"""
-import networkx as nx
import os
import tempfile
-from networkx.utils import nodes_equal, edges_equal
+
+import networkx as nx
+from networkx.utils import edges_equal, nodes_equal
class TestPajek:
diff --git a/networkx/readwrite/tests/test_shp.py b/networkx/readwrite/tests/test_shp.py
index 6b65b26e..7ada2e86 100644
--- a/networkx/readwrite/tests/test_shp.py
+++ b/networkx/readwrite/tests/test_shp.py
@@ -3,6 +3,7 @@
import os
import tempfile
+
import pytest
ogr = pytest.importorskip("osgeo.ogr")
diff --git a/networkx/readwrite/tests/test_sparse6.py b/networkx/readwrite/tests/test_sparse6.py
index ac694d65..c8b5e4de 100644
--- a/networkx/readwrite/tests/test_sparse6.py
+++ b/networkx/readwrite/tests/test_sparse6.py
@@ -1,9 +1,10 @@
-from io import BytesIO
import tempfile
+from io import BytesIO
+
import pytest
import networkx as nx
-from networkx.utils import nodes_equal, edges_equal
+from networkx.utils import edges_equal, nodes_equal
class TestSparseGraph6:
diff --git a/networkx/readwrite/tests/test_text.py b/networkx/readwrite/tests/test_text.py
index 5f82c7b2..4cd618c3 100644
--- a/networkx/readwrite/tests/test_text.py
+++ b/networkx/readwrite/tests/test_text.py
@@ -1,6 +1,8 @@
+from textwrap import dedent
+
import pytest
+
import networkx as nx
-from textwrap import dedent
def test_directed_tree_str():