Skip to content

Commit e452efd

Browse files
authored
Merge pull request #450 from NLeSC/446-fix-ruff-test
Fix ruff test
2 parents 4a56496 + df0831e commit e452efd

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

template/pyproject.toml.jinja

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ extras = dev
102102
[tool.ruff]
103103
line-length = 120
104104
output-format = "concise"
105+
extend-exclude = ["docs"]
105106

106107
[tool.ruff.lint]
107108
# Allow unused variables when underscore-prefixed.
@@ -126,7 +127,15 @@ ignore = [
126127
]
127128
pydocstyle.convention = "google"
128129

129-
[tool.ruff.isort]
130+
[tool.ruff.lint.per-file-ignores]
131+
# Tests can ignore a few extra rules
132+
"tests/**.py" = [
133+
"ANN201", # Missing return type annotation for public function
134+
"PT011", # Missing `match` parameter in `pytest.raises()`
135+
"S101", # Use of assert is detected
136+
]
137+
138+
[tool.ruff.lint.isort]
130139
known-first-party = ["{{ package_name }}"]
131140
force-single-line = true
132141
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]

template/src/{{package_name}}/my_module.py.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ def hello(name: str) -> str:
2525

2626
"""
2727
if name == 'nobody':
28-
raise ValueError('Can not say hello to nobody')
28+
msg = 'Can not say hello to nobody'
29+
raise ValueError(msg)
2930
return f'Hello {name}!'

template/tests/test_my_module.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ def some_name():
2121
return 'Jane Smith'
2222

2323

24-
def test_hello_with_fixture(some_name):
24+
def test_hello_with_fixture(some_name: str):
2525
"""Example using a fixture."""
2626
assert hello(some_name) == 'Hello Jane Smith!'

0 commit comments

Comments
 (0)