Skip to content

Use isort black profile to make compatible with black #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions end_to_end_tests/golden-record/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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"
profile = "black"
4 changes: 2 additions & 2 deletions openapi_python_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if use_poetry %}
[tool.poetry]
name = "{{ project_name }}"
version = "{{ package_version }}"
Expand All @@ -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']
Expand All @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ exclude = '''

[tool.isort]
line_length = 120
multi_line_output = 3
include_trailing_comma = true
profile = "black"
4 changes: 2 additions & 2 deletions tests/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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):
Expand Down