Skip to content

Commit 6100173

Browse files
committed
Fix for Python 4: replace unsafe six.PY3 with PY2
1 parent 8bf3d5e commit 6100173

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

packages/python/chart-studio/chart_studio/tests/test_plot_ly/test_get_figure/test_get_figure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_get_figure_raw(self):
9999

100100

101101
class TestBytesVStrings(PlotlyTestCase):
102-
@skipIf(not six.PY3, "Decoding and missing escapes only seen in PY3")
102+
@skipIf(six.PY2, "Decoding and missing escapes only seen in PY3")
103103
def test_proper_escaping(self):
104104
un = "PlotlyImageTest"
105105
ak = "786r5mecv0"

packages/python/chart-studio/chart_studio/tests/test_plot_ly/test_get_requests/test_get_requests.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def test_user_does_not_exist(self):
3636
hd["plotly-apikey"] = api_key
3737
resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id)
3838
response = requests.get(server + resource, headers=hd)
39-
if six.PY3:
40-
content = _json.loads(response.content.decode("unicode_escape"))
41-
else:
39+
if six.PY2:
4240
content = _json.loads(response.content)
41+
else:
42+
content = _json.loads(response.content.decode("unicode_escape"))
4343
error_message = (
4444
"Aw, snap! We don't have an account for {0}. Want to "
4545
"try again? Sign in is not case sensitive.".format(username)
@@ -58,10 +58,10 @@ def test_file_does_not_exist(self):
5858
hd["plotly-apikey"] = api_key
5959
resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id)
6060
response = requests.get(server + resource, headers=hd)
61-
if six.PY3:
62-
content = _json.loads(response.content.decode("unicode_escape"))
63-
else:
61+
if six.PY2:
6462
content = _json.loads(response.content)
63+
else:
64+
content = _json.loads(response.content.decode("unicode_escape"))
6565
error_message = (
6666
"Aw, snap! It looks like this file does " "not exist. Want to try again?"
6767
)
@@ -96,10 +96,10 @@ def test_private_permission_defined(self):
9696
hd["plotly-apikey"] = api_key
9797
resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id)
9898
response = requests.get(server + resource, headers=hd)
99-
if six.PY3:
100-
content = _json.loads(response.content.decode("unicode_escape"))
101-
else:
99+
if six.PY2:
102100
content = _json.loads(response.content)
101+
else:
102+
content = _json.loads(response.content.decode("unicode_escape"))
103103
self.assertEqual(response.status_code, 403)
104104

105105
# Private File that is shared
@@ -115,10 +115,10 @@ def test_missing_headers(self):
115115
hd = copy.copy(default_headers)
116116
del hd[header]
117117
response = requests.get(server + resource, headers=hd)
118-
if six.PY3:
119-
content = _json.loads(response.content.decode("unicode_escape"))
120-
else:
118+
if six.PY2:
121119
content = _json.loads(response.content)
120+
else:
121+
content = _json.loads(response.content.decode("unicode_escape"))
122122
self.assertEqual(response.status_code, 422)
123123

124124
@attr("slow")
@@ -132,10 +132,10 @@ def test_valid_request(self):
132132
hd["plotly-apikey"] = api_key
133133
resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id)
134134
response = requests.get(server + resource, headers=hd)
135-
if six.PY3:
136-
content = _json.loads(response.content.decode("unicode_escape"))
137-
else:
135+
if six.PY2:
138136
content = _json.loads(response.content)
137+
else:
138+
content = _json.loads(response.content.decode("unicode_escape"))
139139
self.assertEqual(response.status_code, 200)
140140
# content = _json.loads(res.content)
141141
# response_payload = content['payload']

packages/python/plotly/plotly/basedatatypes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -4458,12 +4458,7 @@ def __dir__(self):
44584458
Custom __dir__ that handles dynamic subplot properties
44594459
"""
44604460
# Include any active subplot values
4461-
if six.PY3:
4462-
return list(super(BaseLayoutHierarchyType, self).__dir__()) + sorted(
4463-
self._subplotid_props
4464-
)
4465-
else:
4466-
4461+
if six.PY2:
44674462
def get_attrs(obj):
44684463
import types
44694464

@@ -4493,6 +4488,11 @@ def dir2(obj):
44934488
return list(attrs)
44944489

44954490
return dir2(self) + sorted(self._subplotid_props)
4491+
else:
4492+
4493+
return list(super(BaseLayoutHierarchyType, self).__dir__()) + sorted(
4494+
self._subplotid_props
4495+
)
44964496

44974497

44984498
class BaseTraceHierarchyType(BasePlotlyType):

0 commit comments

Comments
 (0)