Skip to content

Commit 90ef8e0

Browse files
committed
Add pre-commit.
1 parent e88c0bf commit 90ef8e0

13 files changed

Lines changed: 51 additions & 21 deletions

‎.pre-commit-config.yaml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: 'v4.4.0'
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- id: check-builtin-literals
8+
- id: check-executables-have-shebangs
9+
- id: check-json
10+
- id: check-yaml
11+
- id: debug-statements
12+
- id: requirements-txt-fixer
13+
- repo: https://github.com/asottile/pyupgrade
14+
rev: 'v3.10.1'
15+
hooks:
16+
- id: pyupgrade
17+
args:
18+
- --py39-plus
19+
- repo: https://github.com/PyCQA/isort
20+
rev: '5.12.0'
21+
hooks:
22+
- id: isort
23+
- repo: https://github.com/psf/black
24+
rev: '23.7.0'
25+
hooks:
26+
- id: black
27+
- repo: https://github.com/PyCQA/flake8
28+
rev: '6.1.0'
29+
hooks:
30+
- id: flake8
31+
args:
32+
- --show-source
33+
- --config=setup.cfg

‎microbenchmarks/contains.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import timeit
32

43
setup = """data_list = ['left', 'right', 'up', 'down']

‎microbenchmarks/context.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# From https://stackoverflow.com/questions/26152934/why-the-staggering-overhead-50x-of-contextlib-and-the-with-statement-in-python
1+
# From https://stackoverflow.com/questions/26152934/why-the-staggering-overhead-50x-of-contextlib-and-the-with-statement-in-python # noqa: E501
22
import contextlib
33
import timeit
44

@@ -52,7 +52,7 @@ def with_preinstantiated_manual_contextmanager(fn):
5252
fn()
5353

5454

55-
setup = "from __main__ import simple_catch, work_pass, work_fail, with_contextlib_contextmanager, with_manual_contextmanager, with_preinstantiated_manual_contextmanager"
55+
setup = "from __main__ import simple_catch, work_pass, work_fail, with_contextlib_contextmanager, with_manual_contextmanager, with_preinstantiated_manual_contextmanager" # noqa: E501
5656
tests = [
5757
"simple_catch(work_pass)",
5858
"simple_catch(work_fail)",

‎microbenchmarks/counting.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import timeit
32

43
"""Counting an iterator by consuming it."""

‎microbenchmarks/dict_lru.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import timeit
32
from collections import OrderedDict, UserDict
43
from textwrap import dedent

‎microbenchmarks/faces_to_edges.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import timeit
32
from textwrap import dedent
43

@@ -11,7 +10,7 @@
1110
# faces = coxeter.families.PlatonicFamily().get_shape("Dodecahedron").faces
1211
faces = [[13, 0, 8], [0, 13, 15], [11, 10, 1], [6, 2, 10], [6, 13, 2], [13, 6, 15], [18, 4, 10, 2], [1, 10, 4], [15, 14, 0], [5, 11, 1], [4, 12, 1], [16, 12, 4], [1, 12, 5], [7, 14, 15], [4, 18, 16], [18, 8, 16], [8, 18, 2, 13], [17, 19, 5], [5, 12, 17], [11, 3, 7], [11, 5, 19, 3], [19, 9, 14, 3], [3, 14, 7], [0, 9, 8], [14, 9, 0], [9, 19, 17], [10, 11, 7, 15, 6], [8, 9, 17, 12, 16]]
1312
faces = [np.array(f) for f in faces]
14-
"""
13+
""" # noqa: E501
1514

1615
tests = {
1716
"option1": """\

‎microbenchmarks/isinstance_multiple.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import timeit
32
from textwrap import dedent
43

‎microbenchmarks/list_unpack.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import timeit
32
from textwrap import dedent
43

‎microbenchmarks/locking2.py‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Based on snippet from https://bugs.python.org/issue3001
2-
from threading import Lock, RLock
32

43
REPEATS = 1000000
54

@@ -17,28 +16,28 @@ def RLockSpeed():
1716
for i in range(REPEATS):
1817
do_nothing()
1918
result["empty loop"] = time.time() - t
20-
l = threading.Lock()
19+
lock = threading.Lock()
2120
t = time.time()
2221
for i in range(REPEATS):
23-
l.acquire()
22+
lock.acquire()
2423
do_nothing()
25-
l.release()
24+
lock.release()
2625
result["Lock"] = time.time() - t
2726
t = time.time()
2827
for i in range(REPEATS):
29-
with l:
28+
with lock:
3029
do_nothing()
3130
result["Lock_context"] = time.time() - t
32-
l = threading.RLock()
31+
lock = threading.RLock()
3332
t = time.time()
3433
for i in range(REPEATS):
35-
l.acquire()
34+
lock.acquire()
3635
do_nothing()
37-
l.release()
36+
lock.release()
3837
result["RLock"] = time.time() - t
3938
t = time.time()
4039
for i in range(REPEATS):
41-
with l:
40+
with lock:
4241
do_nothing()
4342
result["RLock_context"] = time.time() - t
4443
return result

‎microbenchmarks/nested_access.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import timeit
32
from textwrap import dedent
43

0 commit comments

Comments
 (0)