Skip to content

Commit 22be0ee

Browse files
committed
template: Make isort exclude submodules from API projects
API repositories can include external git submodules under `submodules/`, and those submodules may not use isort or the repository's import-ordering rules. The isort migration workflow runs `isort .`, so without an explicit exclusion it can descend into external submodules and fail or modify code outside the generated project. Add `skip_glob = ["submodules/*"]` to the API-only branch of the generated `[tool.isort]` configuration. Regenerated the public and proprietary API golden fixtures. Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
1 parent a459500 commit 22be0ee

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

cookiecutter/{{cookiecutter.github_repo_name}}/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ profile = "black"
160160
line_length = 88
161161
{#- We don't include "py" here for API because we don't want to check generated files #}
162162
src_paths = ["benchmarks", "examples", "src", "tests"]
163+
{%- if cookiecutter.type == "api" %}
164+
# Submodules may contain external code that doesn't follow our import sorting rules.
165+
skip_glob = ["submodules/*"]
166+
{%- endif %}
163167

164168
[tool.flake8]
165169
# We give some flexibility to go over 88, there are cases like long URLs or

tests_golden/integration/test_cookiecutter_generation/api-proprietary/frequenz-api-test/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ extend-exclude = '^/submodules/'
116116
profile = "black"
117117
line_length = 88
118118
src_paths = ["benchmarks", "examples", "src", "tests"]
119+
# Submodules may contain external code that doesn't follow our import sorting rules.
120+
skip_glob = ["submodules/*"]
119121

120122
[tool.flake8]
121123
# We give some flexibility to go over 88, there are cases like long URLs or

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ extend-exclude = '^/submodules/'
116116
profile = "black"
117117
line_length = 88
118118
src_paths = ["benchmarks", "examples", "src", "tests"]
119+
# Submodules may contain external code that doesn't follow our import sorting rules.
120+
skip_glob = ["submodules/*"]
119121

120122
[tool.flake8]
121123
# We give some flexibility to go over 88, there are cases like long URLs or

0 commit comments

Comments
 (0)