From 786dda690757d5cc83a9cfbd118c02a84e6b78a8 Mon Sep 17 00:00:00 2001 From: Brad Rogers Date: Wed, 7 Oct 2020 13:18:28 -0700 Subject: [PATCH 1/2] Update Python Backend Docstring - Rather than emitting the doc directly run through process_doc - Fix for ([PR #252](https://github.com/dropbox/dropbox-sdk-python/pull/252)) --- stone/backends/python_types.py | 2 +- test/test_python_types.py | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/stone/backends/python_types.py b/stone/backends/python_types.py index fe0aef5e..83db416a 100644 --- a/stone/backends/python_types.py +++ b/stone/backends/python_types.py @@ -120,7 +120,7 @@ def _generate_base_namespace_module(self, api, namespace): if namespace.doc is not None: self.emit('"""') - self.emit_raw(namespace.doc) + self.emit_raw(self.process_doc(namespace.doc, self._docf)) self.emit('"""') self.emit() diff --git a/test/test_python_types.py b/test/test_python_types.py index 3f4eeabd..aa9ca8d2 100644 --- a/test/test_python_types.py +++ b/test/test_python_types.py @@ -41,6 +41,12 @@ def _evaluate_namespace(self, ns): backend._generate_routes(route_schema, ns) return backend.output_buffer_to_string() + def _evaluate_namespace_definition(self, api, ns): + # type: (ApiNamespace) -> typing.Text + backend = self._mock_backend() + backend._generate_base_namespace_module(api, ns) + return backend.output_buffer_to_string() + def _evaluate_struct(self, ns, struct): # type: (ApiNamespace, Struct) -> typing.Text backend = self._mock_backend() @@ -53,6 +59,44 @@ def _evaluate_annotation_type(self, ns, annotation_type): backend._generate_annotation_type_class(ns, annotation_type) return backend.output_buffer_to_string() + def test_namespace_comments(self): + # type: () -> None + ns = ApiNamespace('files') + ns.add_doc("Test Doc testing a :type:`Type`.") + + route_schema = self._mk_route_schema() + + class ApiHolder(object): + pass + + api = ApiHolder() + api.route_schema = route_schema + + result = self._evaluate_namespace_definition(api, ns) + + expected = textwrap.dedent("""\ + # -*- coding: utf-8 -*- + # Auto-generated by Stone, do not modify. + # @generated + # flake8: noqa + # pylint: skip-file + \"\"\" + Test Doc testing a :class:`Type`. + \"\"\" + + from __future__ import unicode_literals + from stone.backends.python_rsrc import stone_base as bb + from stone.backends.python_rsrc import stone_validators as bv + + ROUTES = { + } + + """) + + self.assertEqual(result, expected) + + + def test_route_with_version_number(self): # type: () -> None From cef202de00faf23228418c9250ca8f36a5a362ee Mon Sep 17 00:00:00 2001 From: Brad Rogers Date: Thu, 8 Oct 2020 13:08:07 -0700 Subject: [PATCH 2/2] Update CI to run entirely python3 --- .github/workflows/CI.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 46c72135..46e75ca5 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -23,14 +23,14 @@ jobs: python-version: ${{ matrix.python }} - name: Install Requirements run: | - python -m pip install --upgrade pip + python3 -m pip install --upgrade pip pip install flake8 pylint pytest pip install -r test/requirements.txt - python setup.py install + python3 setup.py install - name: Run Linter run: | - flake8 setup.py example stone test - pylint --rcfile=.pylintrc setup.py example stone test + python3 -m flake8 setup.py example stone test + python3 -m pylint --rcfile=.pylintrc setup.py example stone test - name: Run Unit Tests run: | - pytest \ No newline at end of file + python3 -m pytest