Skip to content

Commit e71a056

Browse files
committed
refactor: Use a single pyproject template
1 parent dc71bfb commit e71a056

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Diff for: end_to_end_tests/golden-record/pyproject.toml

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ packages = [
1111
]
1212
include = ["CHANGELOG.md", "my_test_api_client/py.typed"]
1313

14-
1514
[tool.poetry.dependencies]
1615
python = "^3.6"
1716
httpx = ">=0.15.4,<0.21.0"
1817
attrs = ">=20.1.0,<22.0.0"
1918
python-dateutil = "^2.8.0"
2019

20+
[build-system]
21+
requires = ["poetry>=1.0"]
22+
build-backend = "poetry.masonry.api"
23+
2124
[tool.black]
2225
line-length = 120
2326
target_version = ['py36', 'py37', 'py38']
@@ -33,8 +36,4 @@ exclude = '''
3336

3437
[tool.isort]
3538
line_length = 120
36-
profile = "black"
37-
38-
[build-system]
39-
requires = ["poetry>=1.0"]
40-
build-backend = "poetry.masonry.api"
39+
profile = "black"

Diff for: openapi_python_client/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ def _build_metadata(self) -> None:
205205
git_ignore_path.write_text(git_ignore_template.render(), encoding=self.file_encoding)
206206

207207
def _build_pyproject_toml(self, *, use_poetry: bool) -> None:
208-
template = "pyproject.toml" if use_poetry else "pyproject_no_poetry.toml.jinja"
208+
template = "pyproject.toml.jinja"
209209
pyproject_template = self.env.get_template(template)
210210
pyproject_path = self.project_dir / "pyproject.toml"
211211
pyproject_path.write_text(
212-
pyproject_template.render(),
212+
pyproject_template.render(use_poetry=use_poetry),
213213
encoding=self.file_encoding,
214214
)
215215

Diff for: openapi_python_client/templates/pyproject.toml renamed to openapi_python_client/templates/pyproject.toml.jinja

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% if use_poetry %}
12
[tool.poetry]
23
name = "{{ project_name }}"
34
version = "{{ package_version }}"
@@ -11,13 +12,17 @@ packages = [
1112
]
1213
include = ["CHANGELOG.md", "{{ package_name }}/py.typed"]
1314

14-
1515
[tool.poetry.dependencies]
1616
python = "^3.6"
1717
httpx = ">=0.15.4,<0.21.0"
1818
attrs = ">=20.1.0,<22.0.0"
1919
python-dateutil = "^2.8.0"
2020
21+
[build-system]
22+
requires = ["poetry>=1.0"]
23+
build-backend = "poetry.masonry.api"
24+
25+
{% endif %}
2126
[tool.black]
2227
line-length = 120
2328
target_version = ['py36', 'py37', 'py38']
@@ -34,7 +39,3 @@ exclude = '''
3439
[tool.isort]
3540
line_length = 120
3641
profile = "black"
37-
38-
[build-system]
39-
requires = ["poetry>=1.0"]
40-
build-backend = "poetry.masonry.api"

Diff for: tests/test___init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def test__build_pyproject_toml(self, mocker, use_poetry):
510510

511511
pyproject_template = mocker.MagicMock(autospec=jinja2.Template)
512512
project.env = mocker.MagicMock(autospec=jinja2.Environment)
513-
template_path = "pyproject.toml" if use_poetry else "pyproject_no_poetry.toml.jinja"
513+
template_path = "pyproject.toml.jinja"
514514
templates = {
515515
template_path: pyproject_template,
516516
}
@@ -520,7 +520,7 @@ def test__build_pyproject_toml(self, mocker, use_poetry):
520520

521521
project.env.get_template.assert_called_once_with(template_path)
522522

523-
pyproject_template.render.assert_called_once_with()
523+
pyproject_template.render.assert_called_once_with(use_poetry=use_poetry)
524524
pyproject_path.write_text.assert_called_once_with(pyproject_template.render(), encoding="utf-8")
525525

526526
def test__build_setup_py(self, mocker):

0 commit comments

Comments
 (0)