Skip to content

Commit d127e13

Browse files
committed
enable ruff up rules
1 parent bdb69cd commit d127e13

5 files changed

Lines changed: 10 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ extend-exclude = [
148148
'setup.py',
149149
]
150150
line-length = 88
151-
select = ["E", "F", "W"]
151+
select = ["E", "F", "W", "UP"]
152152
target-version = 'py39'
153+
ignore = [
154+
"UP007", # 'Use `X | Y` for type annotations', requires python 3.10
155+
]
153156

154157
[tool.ruff.format]
155158
docstring-code-format = true

template/utils/_checks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ def check_value(
160160
if len(allowed_values) == 1:
161161
options = "The only allowed value is %s" % repr(allowed_values[0])
162162
elif len(allowed_values) == 2:
163-
options = "Allowed values are %s and %s" % (
164-
repr(allowed_values[0]),
165-
repr(allowed_values[1]),
163+
options = (
164+
f"Allowed values are {repr(allowed_values[0])} "
165+
f"and {repr(allowed_values[1])}"
166166
)
167167
else:
168168
options = "Allowed values are "

template/utils/_fixes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
# https://github.com/sphinx-gallery/sphinx-gallery/issues/1112
13-
class WrapStdOut(object):
13+
class WrapStdOut:
1414
"""Dynamically wrap to sys.stdout.
1515
1616
This makes packages that monkey-patch sys.stdout (e.g.doctest, sphinx-gallery) work

template/utils/tests/test_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def test_docdict_order():
217217
# read the file as text, and get entries via regex
218218
docs_path = Path(__file__).parents[1] / "_docs.py"
219219
assert docs_path.is_file()
220-
with open(docs_path, "r", encoding="UTF-8") as fid:
220+
with open(docs_path, encoding="UTF-8") as fid:
221221
docs = fid.read()
222222
entries = re.findall(r'docdict\[(?:\n )?["\'](.+)["\']\n?\] = ', docs)
223223
# test length, uniqueness and order

template/utils/tests/test_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_file_handler(tmp_path):
133133

134134
logger.handlers[-1].close()
135135

136-
with open(fname, mode="r") as file:
136+
with open(fname) as file:
137137
lines = file.readlines()
138138

139139
assert len(lines) == 2

0 commit comments

Comments
 (0)