Skip to content

Commit 4842a71

Browse files
authored
Merge pull request #27 from andhus/formatting-follow-up
Formatting follow up
2 parents 5109248 + 7b2aad3 commit 4842a71

File tree

9 files changed

+49
-47
lines changed

9 files changed

+49
-47
lines changed

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/test.yml renamed to .github/workflows/ci.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run tests
1+
name: CI
22

33
on:
44
push:
@@ -12,6 +12,15 @@ on:
1212
types: [published, edited]
1313

1414
jobs:
15+
pre-commit:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.8"
22+
- uses: pre-commit/action@v3.0.1
23+
1524
tests:
1625
runs-on: ubuntu-latest
1726
strategy:
@@ -40,14 +49,6 @@ jobs:
4049
key: ${{ runner.os }}-${{ matrix.python-version }}-tox-${{ hashFiles('setup.py') }}-${{ hashFiles('setup.cfg') }} }}
4150
- name: Test with tox
4251
run: tox
43-
- name: Commit and Push to Pull Request
44-
if: matrix.python-version == 3.8
45-
run: |
46-
if [ -n "$(git status -s)" ]; then
47-
git add .
48-
git commit -m "✨ ⭐ Automated commit has been added to your pull request to fix formatting! ⭐ ✨"
49-
git push origin ${{ github.head_ref }}
50-
fi
5152
- uses: codecov/codecov-action@v4
5253
with:
5354
token: ${{ secrets.CODECOV_TOKEN }}

.pre-commit-config.yaml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: 24.3.0
4-
hooks:
5-
- id: black
6-
args: ["--target-version", "py38"]
7-
- repo: https://github.com/PyCQA/isort
8-
rev: 5.13.2
9-
hooks:
10-
- id: isort
11-
args: ["--profile", "black"]
122
- repo: https://github.com/pre-commit/mirrors-prettier
133
rev: v3.1.0
144
hooks:
155
- id: prettier
16-
args: [--prose-wrap=preserve, --print-width=90]
17-
- repo: https://github.com/pycqa/flake8
18-
rev: 7.0.0
19-
hooks:
20-
- id: flake8
6+
args: [--prose-wrap=preserve, --print-width=88]
217
- repo: https://github.com/astral-sh/ruff-pre-commit
228
rev: v0.3.7
239
hooks:
2410
- id: ruff
11+
args:
12+
- --fix
2513
- id: ruff-format
26-
- repo: https://github.com/asottile/pyupgrade
27-
rev: v3.15.2
28-
hooks:
29-
- id: pyupgrade
30-
args: ["--py38-plus"]

benchmark/run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def time_shell(cmd, runs=1, repetitions=1, setup=None):
6565
time_cmd = f"{setup}; {time_cmd}"
6666

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

8686
return realtimes
@@ -167,7 +167,7 @@ def benchmark(dirpath, algorithm, **kwargs):
167167
"t_median",
168168
]
169169
]
170-
for (tc, alg), subdf in df.groupby(["test_case", "algorithm"]):
170+
for (_tc, _alg), subdf in df.groupby(["test_case", "algorithm"]):
171171
t_ref = subdf[subdf["implementation"] == "shell reference"][
172172
"t_median"
173173
].values[0]

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
[build-system]
22
requires = ["setuptools", "versioneer==0.29"]
33
build-backend = "setuptools.build_meta"
4+
5+
[tool.ruff]
6+
target-version = "py38"
7+
8+
[tool.ruff.lint]
9+
select = [
10+
"E", # pycodestyle errors
11+
"W", # pycodestyle warnings
12+
"F", # pyflakes
13+
"I", # isort
14+
"B", # flake8-bugbear
15+
"C4", # flake8-comprehensions
16+
"UP", # pyupgrade
17+
]
18+
19+
[tool.ruff.lint.isort]
20+
known-local-folder = ["dirhash"]

src/dirhash/_version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# Generated by versioneer-0.29
99
# https://github.com/python-versioneer/python-versioneer
1010

11+
# ruff: noqa
12+
1113
"""Git implementation of _version.py."""
1214

1315
import errno

src/dirhash/cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ def get_kwargs(args):
127127
dest="entry_properties",
128128
default=["data", "name"],
129129
help=(
130-
"List of file/directory properties to include in the hash. "
131-
f"Available properties are: {list(dirhash.Protocol.EntryProperties.options)} "
132-
"and at least one of name and data must be included. "
133-
"Default is [data name] which means that both the name/paths "
134-
"and content (actual data) of files and directories will be included"
130+
"List of file/directory properties to include in the hash. Available "
131+
f"properties are: {list(dirhash.Protocol.EntryProperties.options)} and at "
132+
"least one of name and data must be included. Default is [data name] which "
133+
"means that both the name/paths and content (actual data) of files and "
134+
"directories will be included"
135135
),
136136
metavar="",
137137
)

tests/test_dirhash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def test_empty_dir_inclusion_not_affected_by_match(self):
429429

430430
def dirhash_mp_comp(*args, **kwargs):
431431
res = dirhash(*args, **kwargs)
432-
res_mp = dirhash(jobs=2, *args, **kwargs)
432+
res_mp = dirhash(*args, **{**kwargs, "jobs": 2})
433433
assert res == res_mp
434434
return res
435435

tox.ini

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
[tox]
2-
envlist = py{38,39,310,311,312}
2+
envlist = pre-commit,py{38,39,310,311,312}
33

44
[testenv]
5-
allowlist_externals = bash
65
deps =
7-
pre-commit
86
pytest
97
pytest-cov
108
commands =
11-
bash -ec 'if [[ ${envpython} == *"py38"* ]]; then pre-commit run --all-files; fi' {posargs}
12-
pytest --cov=dirhash --cov-report=xml --cov-report=term-missing --cov-config=.coveragerc tests/ {posargs}
9+
pytest --cov=dirhash --cov-report=xml --cov-report=term-missing --cov-config=.coveragerc {posargs:tests}
10+
11+
[testenv:pre-commit]
12+
skip_install = true
13+
deps = pre-commit
14+
commands = pre-commit run --all-files --show-diff-on-failure
1315

1416
[gh-actions]
1517
python =

0 commit comments

Comments
 (0)