Skip to content

Commit 13cdbff

Browse files
committed
style: add ruff and black to pre-commit (#1459)
Without squashing to simplify the history management.
2 parents 8fc3b4b + fd144c4 commit 13cdbff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5401
-4967
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# lint codebase with black and ruff
2+
4e348d6b80c96da461fd866576c971b8a659ba15

.pre-commit-config.yaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ default_stages: [commit, push]
55
default_language_version:
66
python: python3
77
repos:
8-
- repo: https://github.com/PyCQA/flake8
9-
rev: 6.0.0
8+
- repo: https://github.com/charliermarsh/ruff-pre-commit
9+
# Ruff version.
10+
rev: 'v0.0.224'
1011
hooks:
11-
- id: flake8
12-
args: [
13-
--max-line-length=100
14-
]
15-
exclude: ^(venv/|docs/)
16-
types: ['python']
12+
- id: ruff
13+
# Respect `exclude` and `extend-exclude` settings.
14+
args: ["--force-exclude"]
15+
- repo: https://github.com/psf/black
16+
rev: 22.12.0
17+
hooks:
18+
- id: black
19+
language_version: python3.8
1720
- repo: https://github.com/codespell-project/codespell
1821
rev: v2.2.5
1922
hooks:
2023
- id: codespell
21-
args: ["-L", "ba,ihs,kake,nd,noe,nwo,te,fo", "-S", "fixture"]
24+
args: ["-L", "ba,ihs,kake,nd,noe,nwo,te,fo,zar", "-S", "fixture"]
2225
- repo: https://github.com/pre-commit/pre-commit-hooks
2326
rev: v4.4.0
2427
hooks:

bench/compress_normal.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,39 @@
99

1010
if __name__ == "__main__":
1111

12-
sys.path.insert(0, '..')
12+
sys.path.insert(0, "..")
1313

1414
# setup
15-
a = np.random.normal(2000, 1000, size=200000000).astype('u2')
16-
z = zarr.empty_like(a, chunks=1000000,
17-
compression='blosc',
18-
compression_opts=dict(cname='lz4', clevel=5, shuffle=2))
15+
a = np.random.normal(2000, 1000, size=200000000).astype("u2")
16+
z = zarr.empty_like(
17+
a,
18+
chunks=1000000,
19+
compression="blosc",
20+
compression_opts=dict(cname="lz4", clevel=5, shuffle=2),
21+
)
1922
print(z)
2023

21-
print('*' * 79)
24+
print("*" * 79)
2225

2326
# time
24-
t = timeit.repeat('z[:] = a', repeat=10, number=1, globals=globals())
27+
t = timeit.repeat("z[:] = a", repeat=10, number=1, globals=globals())
2528
print(t)
2629
print(min(t))
2730
print(z)
2831

2932
# profile
3033
profile = line_profiler.LineProfiler(blosc.compress)
31-
profile.run('z[:] = a')
34+
profile.run("z[:] = a")
3235
profile.print_stats()
3336

34-
print('*' * 79)
37+
print("*" * 79)
3538

3639
# time
37-
t = timeit.repeat('z[:]', repeat=10, number=1, globals=globals())
40+
t = timeit.repeat("z[:]", repeat=10, number=1, globals=globals())
3841
print(t)
3942
print(min(t))
4043

4144
# profile
4245
profile = line_profiler.LineProfiler(blosc.decompress)
43-
profile.run('z[:]')
46+
profile.run("z[:]")
4447
profile.print_stats()

0 commit comments

Comments
 (0)