Skip to content

Commit

Permalink
replaces black, isort and flake8 with ruff and ruff-format
Browse files Browse the repository at this point in the history
  • Loading branch information
andhus committed Apr 16, 2024
1 parent 5109248 commit 276b36b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

23 changes: 3 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
repos:
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
args: ["--target-version", "py38"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
args: [--prose-wrap=preserve, --print-width=90]
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--prose-wrap=preserve, --print-width=88]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: ["--py38-plus"]
8 changes: 4 additions & 4 deletions benchmark/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def time_shell(cmd, runs=1, repetitions=1, setup=None):
time_cmd = f"{setup}; {time_cmd}"

realtimes = []
for i in range(runs):
for _run in range(runs):
process = subprocess.run(
time_cmd, capture_output=True, text=True, shell=True, check=True
)
Expand All @@ -77,10 +77,10 @@ def time_shell(cmd, runs=1, repetitions=1, setup=None):
min_str, sec_str = t_str.split("m")
sec = 60 * int(min_str) + float(sec_str[:-1])
sec_per_rep = sec / repetitions
except: # noqa: E722
except Exception as exc:
raise RuntimeError(
f"Failed to parse `time` stderr output: {process.stderr}"
)
) from exc
realtimes.append(sec_per_rep)

return realtimes
Expand Down Expand Up @@ -167,7 +167,7 @@ def benchmark(dirpath, algorithm, **kwargs):
"t_median",
]
]
for (tc, alg), subdf in df.groupby(["test_case", "algorithm"]):
for (_tc, _alg), subdf in df.groupby(["test_case", "algorithm"]):
t_ref = subdf[subdf["implementation"] == "shell reference"][
"t_median"
].values[0]
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
[build-system]
requires = ["setuptools", "versioneer==0.29"]
build-backend = "setuptools.build_meta"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
]

[tool.ruff.lint.isort]
known-local-folder = ["dirhash"]
2 changes: 2 additions & 0 deletions src/dirhash/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# Generated by versioneer-0.29
# https://github.com/python-versioneer/python-versioneer

# ruff: noqa

"""Git implementation of _version.py."""

import errno
Expand Down
10 changes: 5 additions & 5 deletions src/dirhash/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ def get_kwargs(args):
dest="entry_properties",
default=["data", "name"],
help=(
"List of file/directory properties to include in the hash. "
f"Available properties are: {list(dirhash.Protocol.EntryProperties.options)} "
"and at least one of name and data must be included. "
"Default is [data name] which means that both the name/paths "
"and content (actual data) of files and directories will be included"
"List of file/directory properties to include in the hash. Available "
f"properties are: {list(dirhash.Protocol.EntryProperties.options)} and at "
"least one of name and data must be included. Default is [data name] which "
"means that both the name/paths and content (actual data) of files and "
"directories will be included"
),
metavar="",
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dirhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def test_empty_dir_inclusion_not_affected_by_match(self):

def dirhash_mp_comp(*args, **kwargs):
res = dirhash(*args, **kwargs)
res_mp = dirhash(jobs=2, *args, **kwargs)
res_mp = dirhash(*args, **{**kwargs, "jobs": 2})
assert res == res_mp
return res

Expand Down

0 comments on commit 276b36b

Please sign in to comment.