diff --git a/end_to_end_tests/golden-record/pyproject.toml b/end_to_end_tests/golden-record/pyproject.toml index 67b718887..480a6d8a8 100644 --- a/end_to_end_tests/golden-record/pyproject.toml +++ b/end_to_end_tests/golden-record/pyproject.toml @@ -11,13 +11,16 @@ packages = [ ] include = ["CHANGELOG.md", "my_test_api_client/py.typed"] - [tool.poetry.dependencies] python = "^3.6" httpx = ">=0.15.4,<0.21.0" attrs = ">=20.1.0,<22.0.0" python-dateutil = "^2.8.0" +[build-system] +requires = ["poetry>=1.0"] +build-backend = "poetry.masonry.api" + [tool.black] line-length = 120 target_version = ['py36', 'py37', 'py38'] @@ -33,9 +36,4 @@ exclude = ''' [tool.isort] line_length = 120 -multi_line_output = 3 -include_trailing_comma = true - -[build-system] -requires = ["poetry>=1.0"] -build-backend = "poetry.masonry.api" \ No newline at end of file +profile = "black" \ No newline at end of file diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index af79badef..608af8dce 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -205,11 +205,11 @@ def _build_metadata(self) -> None: git_ignore_path.write_text(git_ignore_template.render(), encoding=self.file_encoding) def _build_pyproject_toml(self, *, use_poetry: bool) -> None: - template = "pyproject.toml" if use_poetry else "pyproject_no_poetry.toml.jinja" + template = "pyproject.toml.jinja" pyproject_template = self.env.get_template(template) pyproject_path = self.project_dir / "pyproject.toml" pyproject_path.write_text( - pyproject_template.render(), + pyproject_template.render(use_poetry=use_poetry), encoding=self.file_encoding, ) diff --git a/openapi_python_client/templates/pyproject.toml b/openapi_python_client/templates/pyproject.toml.jinja similarity index 92% rename from openapi_python_client/templates/pyproject.toml rename to openapi_python_client/templates/pyproject.toml.jinja index 728d412ba..e951ce6a9 100644 --- a/openapi_python_client/templates/pyproject.toml +++ b/openapi_python_client/templates/pyproject.toml.jinja @@ -1,3 +1,4 @@ +{% if use_poetry %} [tool.poetry] name = "{{ project_name }}" version = "{{ package_version }}" @@ -11,13 +12,17 @@ packages = [ ] include = ["CHANGELOG.md", "{{ package_name }}/py.typed"] - [tool.poetry.dependencies] python = "^3.6" httpx = ">=0.15.4,<0.21.0" attrs = ">=20.1.0,<22.0.0" python-dateutil = "^2.8.0" +[build-system] +requires = ["poetry>=1.0"] +build-backend = "poetry.masonry.api" + +{% endif %} [tool.black] line-length = 120 target_version = ['py36', 'py37', 'py38'] @@ -33,9 +38,4 @@ exclude = ''' [tool.isort] line_length = 120 -multi_line_output = 3 -include_trailing_comma = true - -[build-system] -requires = ["poetry>=1.0"] -build-backend = "poetry.masonry.api" +profile = "black" diff --git a/openapi_python_client/templates/pyproject_no_poetry.toml.jinja b/openapi_python_client/templates/pyproject_no_poetry.toml.jinja index 1bacf4d63..2d0685348 100644 --- a/openapi_python_client/templates/pyproject_no_poetry.toml.jinja +++ b/openapi_python_client/templates/pyproject_no_poetry.toml.jinja @@ -13,5 +13,4 @@ exclude = ''' [tool.isort] line_length = 120 -multi_line_output = 3 -include_trailing_comma = true +profile = "black" diff --git a/tests/test___init__.py b/tests/test___init__.py index 7e2de7409..b88c6fec3 100644 --- a/tests/test___init__.py +++ b/tests/test___init__.py @@ -510,7 +510,7 @@ def test__build_pyproject_toml(self, mocker, use_poetry): pyproject_template = mocker.MagicMock(autospec=jinja2.Template) project.env = mocker.MagicMock(autospec=jinja2.Environment) - template_path = "pyproject.toml" if use_poetry else "pyproject_no_poetry.toml.jinja" + template_path = "pyproject.toml.jinja" templates = { template_path: pyproject_template, } @@ -520,7 +520,7 @@ def test__build_pyproject_toml(self, mocker, use_poetry): project.env.get_template.assert_called_once_with(template_path) - pyproject_template.render.assert_called_once_with() + pyproject_template.render.assert_called_once_with(use_poetry=use_poetry) pyproject_path.write_text.assert_called_once_with(pyproject_template.render(), encoding="utf-8") def test__build_setup_py(self, mocker):