Skip to content

Commit eead79a

Browse files
authored
Only style configurations only when selected (#514)
* Only add isort or black configuration when selected * Revert test change * Add same check for ruff
1 parent b0a20bd commit eead79a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

python-project-template/pyproject.toml.jinja

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,22 @@ testpaths = [
6868
]
6969
addopts = "--doctest-modules --doctest-glob=*.rst"
7070

71+
{% if 'black' in enforce_style -%}
7172
[tool.black]
7273
line-length = 110
7374
target-version = ["py{{ py.min(python_versions) | replace(".", "") }}"]
74-
75+
{% endif -%}
76+
{% if 'isort' in enforce_style -%}
7577
[tool.isort]
7678
profile = "black"
7779
line_length = 110
78-
80+
{% endif -%}
81+
{% if 'ruff_lint' in enforce_style or 'ruff_format' in enforce_style -%}
7982
[tool.ruff]
8083
line-length = 110
8184
target-version = "py{{ py.min(python_versions) | replace(".", "") }}"
82-
85+
{% endif -%}
86+
{% if 'ruff_lint' in enforce_style -%}
8387
[tool.ruff.lint]
8488
select = [
8589
# pycodestyle
@@ -111,7 +115,6 @@ select = [
111115
# Numpy v2.0 compatibility
112116
"NPY201",
113117
]
114-
115118
ignore = [
116119
"UP006", # Allow non standard library generics in type hints
117120
"UP007", # Allow Union in type hints
@@ -121,6 +124,7 @@ ignore = [
121124
"UP015", # Allow redundant open parameters
122125
"UP028", # Allow yield in for loop
123126
]
127+
{% endif -%}
124128

125129
{%- if mypy_type_checking != 'none' %}
126130
[tool.setuptools.package-data]

0 commit comments

Comments
 (0)