Skip to content

Commit 7793c8f

Browse files
committed
Only send the stable portion of the version in plot.ly requests
Addresses #1044
1 parent 40b31cf commit 7793c8f

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

Diff for: plotly/api/v1/clientresp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def clientresp(data, **kwargs):
2525
dumps_kwargs = {'sort_keys': True, 'cls': utils.PlotlyJSONEncoder}
2626

2727
payload = {
28-
'platform': 'python', 'version': version.__version__,
28+
'platform': 'python', 'version': version.stable_semver(),
2929
'args': _json.dumps(data, **dumps_kwargs),
3030
'un': creds['username'], 'key': creds['api_key'], 'origin': 'plot',
3131
'kwargs': _json.dumps(kwargs, **dumps_kwargs)

Diff for: plotly/api/v2/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def get_headers():
9393
creds = config.get_credentials()
9494

9595
headers = {
96-
'plotly-client-platform': 'python {}'.format(version.__version__),
96+
'plotly-client-platform': 'python {}'.format(version.stable_semver()),
9797
'content-type': 'application/json'
9898
}
9999

Diff for: plotly/tests/test_core/test_api/test_v1/test_clientresp.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_data_only(self):
3434
expected_data = ({
3535
'origin': 'plot',
3636
'args': '[{"name": "what else floats?", "y": [3, 5]}]',
37-
'platform': 'python', 'version': version.__version__, 'key': 'bar',
37+
'platform': 'python', 'version': version.stable_semver(), 'key': 'bar',
3838
'kwargs': '{}', 'un': 'foo'
3939
})
4040
self.assertEqual(kwargs['data'], expected_data)
@@ -53,7 +53,7 @@ def test_data_and_kwargs(self):
5353
expected_data = ({
5454
'origin': 'plot',
5555
'args': '[{"name": "what else floats?", "y": [3, 5]}]',
56-
'platform': 'python', 'version': version.__version__, 'key': 'bar',
56+
'platform': 'python', 'version': version.stable_semver(), 'key': 'bar',
5757
'kwargs': '{"filename": "ok", "layout": {"title": "mah plot"}}',
5858
'un': 'foo'
5959
})

Diff for: plotly/tests/test_core/test_api/test_v2/test_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class GetHeadersTest(PlotlyApiTestCase):
167167
def test_normal_auth(self):
168168
headers = utils.get_headers()
169169
expected_headers = {
170-
'plotly-client-platform': 'python {}'.format(version.__version__),
170+
'plotly-client-platform': 'python {}'.format(version.stable_semver()),
171171
'authorization': 'Basic Zm9vOmJhcg==',
172172
'content-type': 'application/json'
173173
}
@@ -177,7 +177,7 @@ def test_proxy_auth(self):
177177
sign_in(self.username, self.api_key, plotly_proxy_authorization=True)
178178
headers = utils.get_headers()
179179
expected_headers = {
180-
'plotly-client-platform': 'python {}'.format(version.__version__),
180+
'plotly-client-platform': 'python {}'.format(version.stable_semver()),
181181
'authorization': 'Basic Y25ldDpob29wbGE=',
182182
'plotly-authorization': 'Basic Zm9vOmJhcg==',
183183
'content-type': 'application/json'

Diff for: plotly/version.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
__version__ = '3.0.0-rc.11'
22
__frontend_version__ = '^0.1.1'
3+
4+
5+
def stable_semver():
6+
"""
7+
Get the stable portion of the semantic version string (the first three
8+
numbers), without any of the trailing labels
9+
10+
'3.0.0-rc.11' -> '3.0.0'
11+
"""
12+
13+
return __version__.split('-')[0]

0 commit comments

Comments
 (0)