Skip to content

Commit 19b979b

Browse files
committed
added from __future__ import absolute_import. Clearer imports.
In Python 3, you cannot have an ambiguous `import X` if X is both a module and a subpackage/submodule. By importing this here, we get rid of ridiculous relative imports like `from ... import X`.
1 parent 9481bed commit 19b979b

File tree

22 files changed

+94
-53
lines changed

22 files changed

+94
-53
lines changed

plotly/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@
2626
2727
"""
2828

29-
from . import plotly, graph_objs, tools, utils
29+
from __future__ import absolute_import
30+
31+
from plotly import plotly, graph_objs, tools, utils

plotly/graph_objs/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
88
99
"""
10-
from .graph_objs import *
10+
from __future__ import absolute_import
11+
12+
from plotly.graph_objs.graph_objs import *
1113

1214
__all__ = ["Data",
1315
"Annotations",

plotly/graph_objs/graph_objs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
from a dict/list JSON representation.
2323
2424
"""
25+
from __future__ import absolute_import
26+
2527
import warnings
2628
import textwrap
2729
import six
2830
import sys
29-
from . import graph_objs_tools
31+
from plotly.graph_objs import graph_objs_tools
3032
import copy
31-
from .. import exceptions
33+
from plotly import exceptions
3234
from plotly import utils
3335

3436
if sys.version[:3] == '2.6':

plotly/matplotlylib/renderer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
with the matplotlylib package.
77
88
"""
9+
from __future__ import absolute_import
10+
911
import warnings
1012

1113
from . mplexporter import Renderer
1214
from . import mpltools
13-
from ..graph_objs import *
15+
from plotly.graph_objs import *
1416

1517

1618

plotly/plotly/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
verifiable account (username/api-key pair) and a network connection.
88
99
"""
10-
from .plotly import *
10+
from __future__ import absolute_import
11+
12+
from plotly.plotly.plotly import *
1113

1214
__all__ = ["sign_in", "update_plot_options", "get_plot_options",
1315
"get_credentials", "iplot", "plot", "iplot_mpl", "plot_mpl",

plotly/plotly/plotly.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
4. update plot_options with kwargs!
1515
1616
"""
17+
from __future__ import absolute_import
18+
1719
import json
1820
import warnings
1921
import copy
@@ -22,11 +24,11 @@
2224

2325
import requests
2426

25-
from . import chunked_requests
26-
from .. import utils # TODO make non-relative
27-
from .. import tools
28-
from .. import exceptions
29-
from .. import version
27+
from plotly.plotly import chunked_requests
28+
from plotly import utils
29+
from plotly import tools
30+
from plotly import exceptions
31+
from plotly import version
3032

3133

3234
__all__ = ["sign_in", "update_plot_options", "get_plot_options",

plotly/tests/test_get_figure/test_get_figure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
A module intended for use with Nose.
66
77
"""
8-
from ... graph_objs import graph_objs
9-
from ... plotly import plotly as py
10-
from ... import exceptions
8+
from plotly.graph_objs import graph_objs
9+
from plotly.plotly import plotly as py
10+
from plotly import exceptions
1111

1212

1313
# username for tests: 'plotlyimagetest'

plotly/tests/test_graph_objs/test_annotations.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
A module intended for use with Nose.
66
77
"""
8+
from __future__ import absolute_import
9+
810
from nose.tools import raises
9-
from ...graph_objs.graph_objs import *
10-
from ...exceptions import (PlotlyError,
11-
PlotlyDictKeyError,
12-
PlotlyDictValueError,
13-
PlotlyDataTypeError, PlotlyListEntryError)
11+
from plotly.graph_objs.graph_objs import *
12+
from plotly.exceptions import (PlotlyError,
13+
PlotlyDictKeyError,
14+
PlotlyDictValueError,
15+
PlotlyDataTypeError,
16+
PlotlyListEntryError)
1417

1518

1619
def setup():

plotly/tests/test_graph_objs/test_data.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
A module intended for use with Nose.
66
77
"""
8+
from __future__ import absolute_import
9+
810
from nose.tools import raises
9-
from ...graph_objs.graph_objs import *
10-
from ...exceptions import (PlotlyError,
11-
PlotlyDictKeyError,
12-
PlotlyDictValueError,
13-
PlotlyDataTypeError, PlotlyListEntryError)
11+
from plotly.graph_objs.graph_objs import *
12+
from plotly.exceptions import (PlotlyError,
13+
PlotlyDictKeyError,
14+
PlotlyDictValueError,
15+
PlotlyDataTypeError,
16+
PlotlyListEntryError)
1417

1518

1619
def setup():

plotly/tests/test_graph_objs/test_error_bars.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
A module intended for use with Nose.
66
77
"""
8+
from __future__ import absolute_import
9+
810
from nose.tools import raises
9-
from ...graph_objs.graph_objs import *
10-
from ...exceptions import (PlotlyDictKeyError, PlotlyDictValueError,
11-
PlotlyDataTypeError, PlotlyListEntryError)
11+
from plotly.graph_objs.graph_objs import *
12+
from plotly.exceptions import (PlotlyDictKeyError,
13+
PlotlyDictValueError,
14+
PlotlyDataTypeError,
15+
PlotlyListEntryError)
1216

1317

1418
def test_instantiate_error_x():

0 commit comments

Comments
 (0)