Skip to content

Commit

Permalink
enable ruff up rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Scheltienne committed Jan 15, 2024
1 parent bdb69cd commit d127e13
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ extend-exclude = [
'setup.py',
]
line-length = 88
select = ["E", "F", "W"]
select = ["E", "F", "W", "UP"]
target-version = 'py39'
ignore = [
"UP007", # 'Use `X | Y` for type annotations', requires python 3.10
]

[tool.ruff.format]
docstring-code-format = true
Expand Down
6 changes: 3 additions & 3 deletions template/utils/_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def check_value(
if len(allowed_values) == 1:
options = "The only allowed value is %s" % repr(allowed_values[0])
elif len(allowed_values) == 2:
options = "Allowed values are %s and %s" % (
repr(allowed_values[0]),
repr(allowed_values[1]),
options = (
f"Allowed values are {repr(allowed_values[0])} "
f"and {repr(allowed_values[1])}"
)
else:
options = "Allowed values are "
Expand Down
2 changes: 1 addition & 1 deletion template/utils/_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


# https://github.com/sphinx-gallery/sphinx-gallery/issues/1112
class WrapStdOut(object):
class WrapStdOut:
"""Dynamically wrap to sys.stdout.
This makes packages that monkey-patch sys.stdout (e.g.doctest, sphinx-gallery) work
Expand Down
2 changes: 1 addition & 1 deletion template/utils/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_docdict_order():
# read the file as text, and get entries via regex
docs_path = Path(__file__).parents[1] / "_docs.py"
assert docs_path.is_file()
with open(docs_path, "r", encoding="UTF-8") as fid:
with open(docs_path, encoding="UTF-8") as fid:
docs = fid.read()
entries = re.findall(r'docdict\[(?:\n )?["\'](.+)["\']\n?\] = ', docs)
# test length, uniqueness and order
Expand Down
2 changes: 1 addition & 1 deletion template/utils/tests/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_file_handler(tmp_path):

logger.handlers[-1].close()

with open(fname, mode="r") as file:
with open(fname) as file:
lines = file.readlines()

assert len(lines) == 2
Expand Down

0 comments on commit d127e13

Please sign in to comment.