diff --git a/plotly/api/v1/clientresp.py b/plotly/api/v1/clientresp.py index c3af66c6b1..d27fc5e812 100644 --- a/plotly/api/v1/clientresp.py +++ b/plotly/api/v1/clientresp.py @@ -25,7 +25,7 @@ def clientresp(data, **kwargs): dumps_kwargs = {'sort_keys': True, 'cls': utils.PlotlyJSONEncoder} payload = { - 'platform': 'python', 'version': version.__version__, + 'platform': 'python', 'version': version.stable_semver(), 'args': _json.dumps(data, **dumps_kwargs), 'un': creds['username'], 'key': creds['api_key'], 'origin': 'plot', 'kwargs': _json.dumps(kwargs, **dumps_kwargs) diff --git a/plotly/api/v2/utils.py b/plotly/api/v2/utils.py index 21bd0ddd01..52a6a46429 100644 --- a/plotly/api/v2/utils.py +++ b/plotly/api/v2/utils.py @@ -93,7 +93,7 @@ def get_headers(): creds = config.get_credentials() headers = { - 'plotly-client-platform': 'python {}'.format(version.__version__), + 'plotly-client-platform': 'python {}'.format(version.stable_semver()), 'content-type': 'application/json' } diff --git a/plotly/tests/test_core/test_api/test_v1/test_clientresp.py b/plotly/tests/test_core/test_api/test_v1/test_clientresp.py index 64960f3b6d..18ee643549 100644 --- a/plotly/tests/test_core/test_api/test_v1/test_clientresp.py +++ b/plotly/tests/test_core/test_api/test_v1/test_clientresp.py @@ -34,7 +34,7 @@ def test_data_only(self): expected_data = ({ 'origin': 'plot', 'args': '[{"name": "what else floats?", "y": [3, 5]}]', - 'platform': 'python', 'version': version.__version__, 'key': 'bar', + 'platform': 'python', 'version': version.stable_semver(), 'key': 'bar', 'kwargs': '{}', 'un': 'foo' }) self.assertEqual(kwargs['data'], expected_data) @@ -53,7 +53,7 @@ def test_data_and_kwargs(self): expected_data = ({ 'origin': 'plot', 'args': '[{"name": "what else floats?", "y": [3, 5]}]', - 'platform': 'python', 'version': version.__version__, 'key': 'bar', + 'platform': 'python', 'version': version.stable_semver(), 'key': 'bar', 'kwargs': '{"filename": "ok", "layout": {"title": "mah plot"}}', 'un': 'foo' }) diff --git a/plotly/tests/test_core/test_api/test_v2/test_utils.py b/plotly/tests/test_core/test_api/test_v2/test_utils.py index 5f551f79cd..0b1b83400e 100644 --- a/plotly/tests/test_core/test_api/test_v2/test_utils.py +++ b/plotly/tests/test_core/test_api/test_v2/test_utils.py @@ -167,7 +167,7 @@ class GetHeadersTest(PlotlyApiTestCase): def test_normal_auth(self): headers = utils.get_headers() expected_headers = { - 'plotly-client-platform': 'python {}'.format(version.__version__), + 'plotly-client-platform': 'python {}'.format(version.stable_semver()), 'authorization': 'Basic Zm9vOmJhcg==', 'content-type': 'application/json' } @@ -177,7 +177,7 @@ def test_proxy_auth(self): sign_in(self.username, self.api_key, plotly_proxy_authorization=True) headers = utils.get_headers() expected_headers = { - 'plotly-client-platform': 'python {}'.format(version.__version__), + 'plotly-client-platform': 'python {}'.format(version.stable_semver()), 'authorization': 'Basic Y25ldDpob29wbGE=', 'plotly-authorization': 'Basic Zm9vOmJhcg==', 'content-type': 'application/json' diff --git a/plotly/version.py b/plotly/version.py index 6552ffa40d..b9f9ac043b 100644 --- a/plotly/version.py +++ b/plotly/version.py @@ -1,2 +1,13 @@ __version__ = '3.0.0-rc.11' __frontend_version__ = '^0.1.1' + + +def stable_semver(): + """ + Get the stable portion of the semantic version string (the first three + numbers), without any of the trailing labels + + '3.0.0-rc.11' -> '3.0.0' + """ + + return __version__.split('-')[0]