Skip to content

Commit 294d743

Browse files
authored
Merge pull request #4357 from plotly/no-universal
remove py2 from build
2 parents 59cdd99 + 7d85198 commit 294d743

File tree

110 files changed

+42
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+42
-366
lines changed

Diff for: contributing.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ pytest plotly/tests/test_plotly/test_plot.py::test_function
271271

272272
Running tests with tox is much more powerful, but requires a bit more setup.
273273

274-
You'll need to export an environment variable for *each* tox environment you wish to test with. For example, if you want to test with `Python 2.7` and
274+
You'll need to export an environment variable for *each* tox environment you wish to test with. For example, if you want to test with `Python 3.9` and
275275
`Python 3.6`, but only care to check the `core` specs, you would need to ensure that the following variables are exported:
276276

277277
```
278-
export PLOTLY_TOX_PYTHON_27=<python binary>
278+
export PLOTLY_TOX_PYTHON_39=<python binary>
279279
export PLOTLY_TOX_PYTHON_36=<python binary>
280280
```
281281

@@ -286,15 +286,15 @@ Where the `<python binary` is going to be specific to your development setup. As
286286
# tox envs #
287287
############
288288

289-
export PLOTLY_TOX_PYTHON_27=python2.7
290-
export PLOTLY_TOX_PYTHON_34=python3.4
291-
export TOXENV=py27-core,py34-core
289+
export PLOTLY_TOX_PYTHON_39=python3.9
290+
export PLOTLY_TOX_PYTHON_36=python3.6
291+
export TOXENV=py39-core,py36-core
292292
```
293293

294294
Where `TOXENV` is the environment list you want to use when invoking `tox` from the command line. Note that the `PLOTLY_TOX_*` pattern is used to pass in variables for use in the `tox.ini` file. Though this is a little setup, intensive, you'll get the following benefits:
295295

296296
* `tox` will automatically manage a virtual env for each environment you want to test in.
297-
* You only have to run `tox` and know that the module is working in both `Python 2` and `Python 3`.
297+
* You only have to run `tox` and know that the module is working in all included Python versions.
298298

299299
Finally, `tox` allows you to pass in additional command line arguments that are formatted in (by us) in the `tox.ini` file, see `{posargs}`. This is setup to help with our configuration of [pytest markers](http://doc.pytest.org/en/latest/example/markers.html), which are set up in `packages/python/plotly/pytest.ini`. To run only tests that are *not* tagged with `nodev`, you could use the following command:
300300

Diff for: doc/apidoc/conf.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
#
31
# Configuration file for the Sphinx documentation builder.
42
#
53
# This file does only contain a selection of the most common options. For a

Diff for: doc/unconverted/python/amazon-redshift.md

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ This notebook will go over one of the easiest ways to graph data from your [Amaz
4545
In this notebook we'll be using [Amazon's Sample Redshift Data](http://docs.aws.amazon.com/redshift/latest/gsg/rs-gsg-create-sample-db.html) for this notebook. Although we won't be connecting through a JDBC/ODBC connection we'll be using the [psycopg2 package](http://initd.org/psycopg/docs/index.html) with [SQLAlchemy](http://www.sqlalchemy.org/) and [pandas](http://pandas.pydata.org/) to make it simple to query and analyze our data.
4646

4747
```python
48-
from __future__ import print_function #python 3 support
49-
5048
import plotly.plotly as py
5149
import plotly.graph_objs as go
5250
import plotly.tools as tls

Diff for: doc/unconverted/python/apache-spark.md

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ We can test for the Spark Context's existence with `print sc`.
122122
<!-- #endregion -->
123123

124124
```python
125-
from __future__ import print_function #python 3 support
126125
print(sc)
127126
```
128127

Diff for: packages/python/plotly/_plotly_utils/basevalidators.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
import base64
42
import numbers
53
import textwrap
@@ -146,7 +144,7 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
146144
# --------------------------
147145
if force_numeric and new_v.dtype.kind not in numeric_kinds:
148146
raise ValueError(
149-
"Input value is not numeric and" "force_numeric parameter set to True"
147+
"Input value is not numeric and force_numeric parameter set to True"
150148
)
151149

152150
if "U" not in kind:

Diff for: packages/python/plotly/_plotly_utils/colors/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373
Be careful! If you have a lot of unique numbers in your color column you will
7474
end up with a colormap that is massive and may slow down graphing performance.
7575
"""
76-
from __future__ import absolute_import
77-
7876
import decimal
7977
from numbers import Number
8078

Diff for: packages/python/plotly/_plotly_utils/optional_imports.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
Stand-alone module to provide information about whether optional deps exist.
33
44
"""
5-
from __future__ import absolute_import
6-
75
from importlib import import_module
86
import logging
97
import sys
@@ -30,7 +28,7 @@ def get_module(name, should_load=True):
3028
return import_module(name)
3129
except ImportError:
3230
_not_importable.add(name)
33-
except Exception as e:
31+
except Exception:
3432
_not_importable.add(name)
3533
msg = f"Error importing optional module {name}"
3634
logger.exception(msg)

Diff for: packages/python/plotly/_plotly_utils/utils.py

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
from _plotly_utils.basevalidators import ImageUriValidator
99

1010

11-
PY36_OR_LATER = sys.version_info >= (3, 6)
12-
13-
1411
def cumsum(x):
1512
"""
1613
Custom cumsum to avoid a numpy import.

Diff for: packages/python/plotly/plotly/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
- exceptions: defines our custom exception classes
2626
2727
"""
28-
from __future__ import absolute_import
2928
import sys
3029
from typing import TYPE_CHECKING
3130
from _plotly_utils.importers import relative_import

Diff for: packages/python/plotly/plotly/_subplots.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, unicode_literals
3-
41
# Constants
52
# ---------
63
# Subplot types that are each individually positioned with a domain

Diff for: packages/python/plotly/plotly/api/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from _plotly_future_ import _chart_studio_error
32

43
_chart_studio_error("api.utils")

Diff for: packages/python/plotly/plotly/api/v1.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from _plotly_future_ import _chart_studio_error
32

43
_chart_studio_error("api.v1")

Diff for: packages/python/plotly/plotly/api/v2.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from _plotly_future_ import _chart_studio_error
32

43
_chart_studio_error("api.v2")

Diff for: packages/python/plotly/plotly/basedatatypes.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
import collections
42
from collections import OrderedDict
53
import re

Diff for: packages/python/plotly/plotly/basewidget.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
import uuid
2-
from importlib import import_module
3-
import os
4-
import numbers
5-
6-
try:
7-
from urllib import parse
8-
except ImportError:
9-
from urlparse import urlparse as parse
10-
111
import ipywidgets as widgets
122
from traitlets import List, Unicode, Dict, observe, Integer
3+
134
from .basedatatypes import BaseFigure, BasePlotlyType
145
from .callbacks import BoxSelector, LassoSelector, InputDeviceState, Points
156
from .serializers import custom_serializers

Diff for: packages/python/plotly/plotly/callbacks.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from plotly.utils import _list_repr_elided
32

43

@@ -17,11 +16,11 @@ def __init__(
1716
def __repr__(self):
1817
return """\
1918
InputDeviceState(
20-
ctrl={ctrl},
21-
alt={alt},
22-
shift={shift},
23-
meta={meta},
24-
button={button},
19+
ctrl={ctrl},
20+
alt={alt},
21+
shift={shift},
22+
meta={meta},
23+
button={button},
2524
buttons={buttons})""".format(
2625
ctrl=repr(self.ctrl),
2726
alt=repr(self.alt),

Diff for: packages/python/plotly/plotly/colors/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* sequential
1313
"""
1414

15-
from __future__ import absolute_import
1615
from _plotly_utils.colors import * # noqa: F401
1716

1817
__all__ = [

Diff for: packages/python/plotly/plotly/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from _plotly_future_ import _chart_studio_error
32

43
_chart_studio_error("config")

Diff for: packages/python/plotly/plotly/conftest.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21
import os
32

43

Diff for: packages/python/plotly/plotly/dashboard_objs.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from _plotly_future_ import _chart_studio_error
32

43
_chart_studio_error("dashboard_objs")

Diff for: packages/python/plotly/plotly/exceptions.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from __future__ import absolute_import
21
from _plotly_utils.exceptions import *

Diff for: packages/python/plotly/plotly/express/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
`plotly.express` is a terse, consistent, high-level wrapper around `plotly.graph_objects`
33
for rapid data exploration and figure generation. Learn more at https://plotly.com/python/plotly-express/
44
"""
5-
from __future__ import absolute_import
65
from plotly import optional_imports
76

87
pd = optional_imports.get_module("pandas")

Diff for: packages/python/plotly/plotly/express/colors/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* sequential
1313
"""
1414

15-
from __future__ import absolute_import
1615
from plotly.colors import *
1716

1817

Diff for: packages/python/plotly/plotly/express/data/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Built-in datasets for demonstration, educational and test purposes.
22
"""
33

4-
from __future__ import absolute_import
54
from plotly.data import *
65

76
__all__ = [

Diff for: packages/python/plotly/plotly/figure_factory/README.md

+13-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Add A Figure Factory to the Plotly [Python Library](https://plot.ly/python/)
22

3+
Note: we are generally NOT accepting new figure factories anymore. We'll keep this doc around for context and in case we decide to make an exception, but we've found that figure factories expand the scope of the library (and its maintenance burden) beyond what really makes sense, and generates confusion about how these figures relate to the underlying plotly.js objects.
4+
5+
That doesn't mean this pattern is discouraged though, far from it! We encourage you to make more such high-level functions and share them with the community as separate PyPI packages, GitHub Gists, or posts on https://community.plotly.com.
6+
37
## What is a Figure Factory?
48
In the Python Plotly Library:
59

@@ -61,8 +65,6 @@ If you are making a chart called `foo`, then you must create `_foo.py` in this d
6165
The inside of the `__init__.py` looks like:
6266

6367
```
64-
from __future__ import absolute_import
65-
6668
# Require that numpy exists for figure_factory
6769
import numpy
6870
@@ -78,19 +80,9 @@ Now add the following line to the end of `__init__.py`:
7880
from plotly.figure_factory._foo import create_foo
7981
```
8082

81-
3. Imports
83+
3. The main function
8284

83-
In `_foo.py` write
84-
85-
```
86-
from __future__ import absolute_import
87-
```
88-
89-
at line 1. You can add other imports later if you will need them.
90-
91-
4. The main function
92-
93-
It's now time to write the main function `create_foo` that will be called directly by the user. It has the form:
85+
It's now time to write the main function `create_foo` that will be called directly by the user. It lives in `_foo.py` and has the form:
9486

9587
```
9688
def create_foo(attribute1, attribute2=value, ...):
@@ -101,15 +93,15 @@ def create_foo(attribute1, attribute2=value, ...):
10193
:param (type) attribute2: description of what 'attribute2' is.
10294
Default = value
10395
# ...
104-
96+
10597
Example 1:
10698
'''
107-
99+
108100
'''
109-
101+
110102
Example 2:
111103
'''
112-
104+
113105
'''
114106
"""
115107
# code goes here
@@ -136,15 +128,15 @@ py.iplot(fig, filename='my_figure')
136128

137129
The figure `fig` must be a Plotly Figure, meaning it must have the form `fig = graph_objs.Figure(data=data, layout=layout)`.
138130

139-
5. Useful Tips
131+
4. Useful Tips
140132

141133
It is often not a good idea to put all your code into your `create_foo()` function. It is best practice to not repeat yourself and this requires taking repeated blocks of code and putting them into a separate function.
142134

143135
It is best to make all other functions besides `create_foo()` secret so a user cannot access them. This is done by placing a `_` before the name of the function, so `_aux_func()` for example.
144136

145-
6. Tests
137+
5. Tests
146138

147-
Add unit tests in
139+
Add unit tests in
148140
`plotly/tests/test_optional/test_figure_factory/test_figure_factory.py`.
149141

150142
## Create a Pull Request

Diff for: packages/python/plotly/plotly/figure_factory/_2d_density.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from numbers import Number
42

53
import plotly.exceptions

Diff for: packages/python/plotly/plotly/figure_factory/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from plotly import optional_imports
42

53
# Require that numpy exists for figure_factory

Diff for: packages/python/plotly/plotly/figure_factory/_annotated_heatmap.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, division
2-
31
import plotly.colors as clrs
42
from plotly import exceptions, optional_imports
53
from plotly.figure_factory import utils

Diff for: packages/python/plotly/plotly/figure_factory/_bullet.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from __future__ import absolute_import
2-
3-
import collections
41
import math
52

63
from plotly import exceptions, optional_imports

Diff for: packages/python/plotly/plotly/figure_factory/_candlestick.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from plotly.figure_factory import utils
42
from plotly.figure_factory._ohlc import (
53
_DEFAULT_INCREASING_COLOR,

Diff for: packages/python/plotly/plotly/figure_factory/_dendrogram.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
3-
from __future__ import absolute_import
4-
51
from collections import OrderedDict
62

73
from plotly import exceptions, optional_imports

Diff for: packages/python/plotly/plotly/figure_factory/_distplot.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from plotly import exceptions, optional_imports
42
from plotly.figure_factory import utils
53
from plotly.graph_objs import graph_objs

Diff for: packages/python/plotly/plotly/figure_factory/_facet_grid.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from plotly import exceptions, optional_imports
42
import plotly.colors as clrs
53
from plotly.figure_factory import utils

Diff for: packages/python/plotly/plotly/figure_factory/_gantt.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from numbers import Number
42

53
import copy

Diff for: packages/python/plotly/plotly/figure_factory/_ohlc.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from plotly import exceptions
42
from plotly.graph_objs import graph_objs
53
from plotly.figure_factory import utils

Diff for: packages/python/plotly/plotly/figure_factory/_quiver.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
import math
42

53
from plotly import exceptions

Diff for: packages/python/plotly/plotly/figure_factory/_scatterplot.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from plotly import exceptions, optional_imports
42
import plotly.colors as clrs
53
from plotly.figure_factory import utils

Diff for: packages/python/plotly/plotly/figure_factory/_streamline.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
import math
42

53
from plotly import exceptions, optional_imports

0 commit comments

Comments
 (0)