Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Commit d816031

Browse files
authored
MAINT: run black on all files in CI (#64)
In #63 black was run on `setup.py`. Follow up by running black on all files in CI. Do an inital pass over the entire codebase so that the CI check will pass.
1 parent b230e32 commit d816031

File tree

13 files changed

+54
-53
lines changed

13 files changed

+54
-53
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ install:
1717

1818
script:
1919
- flake8
20-
- black --check numpy-stubs
20+
- black --check .
2121
- py.test
2222

2323
cache:

runtests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
def main():
1212
subprocess.run(
13-
[sys.executable, '-m', 'pip', 'install', STUBS_ROOT],
13+
[sys.executable, "-m", "pip", "install", STUBS_ROOT],
1414
capture_output=True,
1515
check=True,
1616
)
1717
sys.exit(pytest.main([STUBS_ROOT] + sys.argv[1:]))
1818

1919

20-
if __name__ == '__main__':
20+
if __name__ == "__main__":
2121
main()

scripts/find_ufuncs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ def main():
1010

1111
ufunc_stubs = []
1212
for ufunc in set(ufuncs):
13-
ufunc_stubs.append(f'{ufunc.__name__}: ufunc')
13+
ufunc_stubs.append(f"{ufunc.__name__}: ufunc")
1414
ufunc_stubs.sort()
1515

1616
for stub in ufunc_stubs:
1717
print(stub)
1818

1919

20-
if __name__ == '__main__':
20+
if __name__ == "__main__":
2121
main()

tests/fail/scalars.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
np.datetime64(0) # E: non-matching overload
3030

31-
dt_64 = np.datetime64(0, 'D')
32-
td_64 = np.timedelta64(1, 'h')
31+
dt_64 = np.datetime64(0, "D")
32+
td_64 = np.timedelta64(1, "h")
3333

3434
dt_64 + dt_64 # E: Unsupported operand types
3535

tests/fail/ufuncs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
22

3-
np.sin.nin + 'foo' # E: Unsupported operand types
4-
np.sin(1, foo='bar') # E: Unexpected keyword argument
5-
np.sin(1, extobj=['foo', 'foo', 'foo']) # E: incompatible type
3+
np.sin.nin + "foo" # E: Unsupported operand types
4+
np.sin(1, foo="bar") # E: Unexpected keyword argument
5+
np.sin(1, extobj=["foo", "foo", "foo"]) # E: incompatible type

tests/fail/warnings_and_errors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
np.AxisError(1.0) # E: Argument 1 to "AxisError" has incompatible type
44
np.AxisError(1, ndim=2.0) # E: Argument "ndim" to "AxisError" has incompatible type
5-
np.AxisError(2, msg_prefix=404) # E: Argument "msg_prefix" to "AxisError" has incompatible type
5+
np.AxisError(
6+
2, msg_prefix=404 # E: Argument "msg_prefix" to "AxisError" has incompatible type
7+
)

tests/pass/scalars.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,23 @@ def __float__(self):
5353

5454
# Time structures
5555
np.datetime64()
56-
np.datetime64(0, 'D')
57-
np.datetime64('2019')
58-
np.datetime64('2019', 'D')
56+
np.datetime64(0, "D")
57+
np.datetime64("2019")
58+
np.datetime64("2019", "D")
5959

6060
np.timedelta64()
6161
np.timedelta64(0)
62-
np.timedelta64(0, 'D')
62+
np.timedelta64(0, "D")
6363

64-
dt_64 = np.datetime64(0, 'D')
65-
td_64 = np.timedelta64(1, 'h')
64+
dt_64 = np.datetime64(0, "D")
65+
td_64 = np.timedelta64(1, "h")
6666

6767
dt_64 + td_64
6868
dt_64 - dt_64
6969
dt_64 - td_64
7070

7171
td_64 + td_64
7272
td_64 - td_64
73-
td_64 / 1.
73+
td_64 / 1.0
7474
td_64 / td_64
7575
td_64 % td_64

tests/pass/simple.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
# Basic checks
88
array = np.array([1, 2])
9+
10+
911
def ndarray_func(x):
1012
# type: (np.ndarray) -> np.ndarray
1113
return x
14+
15+
1216
ndarray_func(np.array([1, 2]))
1317
array == 1
1418
array.dtype == float
@@ -21,38 +25,40 @@ def ndarray_func(x):
2125
np.dtype(float)
2226
np.dtype(np.float64)
2327
np.dtype(None)
24-
np.dtype('float64')
28+
np.dtype("float64")
2529
np.dtype(np.dtype(float))
26-
np.dtype(('U', 10))
30+
np.dtype(("U", 10))
2731
np.dtype((np.int32, (2, 2)))
2832
# Define the arguments on the previous line to prevent bidirectional
2933
# type inference in mypy from broadening the types.
30-
two_tuples_dtype = [('R', 'u1'), ('G', 'u1'), ('B', 'u1')]
34+
two_tuples_dtype = [("R", "u1"), ("G", "u1"), ("B", "u1")]
3135
np.dtype(two_tuples_dtype)
3236

33-
three_tuples_dtype = [('R', 'u1', 1)]
37+
three_tuples_dtype = [("R", "u1", 1)]
3438
np.dtype(three_tuples_dtype)
3539

36-
mixed_tuples_dtype = [('R', 'u1'), ('G', np.unicode_, 1)]
40+
mixed_tuples_dtype = [("R", "u1"), ("G", np.unicode_, 1)]
3741
np.dtype(mixed_tuples_dtype)
3842

39-
shape_tuple_dtype = [('R', 'u1', (2, 2))]
43+
shape_tuple_dtype = [("R", "u1", (2, 2))]
4044
np.dtype(shape_tuple_dtype)
4145

42-
shape_like_dtype = [('R', 'u1', (2, 2)), ('G', np.unicode_, 1)]
46+
shape_like_dtype = [("R", "u1", (2, 2)), ("G", np.unicode_, 1)]
4347
np.dtype(shape_like_dtype)
4448

45-
object_dtype = [('field1', object)]
49+
object_dtype = [("field1", object)]
4650
np.dtype(object_dtype)
4751

48-
np.dtype({'col1': ('U10', 0), 'col2': ('float32', 10)})
49-
np.dtype((np.int32, {'real': (np.int16, 0), 'imag': (np.int16, 2)}))
52+
np.dtype({"col1": ("U10", 0), "col2": ("float32", 10)})
53+
np.dtype((np.int32, {"real": (np.int16, 0), "imag": (np.int16, 2)}))
5054
np.dtype((np.int32, (np.int8, 4)))
5155

5256
# Iteration and indexing
5357
def iterable_func(x):
5458
# type: (Iterable) -> Iterable
5559
return x
60+
61+
5662
iterable_func(array)
5763
[element for element in array]
5864
iter(array)

tests/pass/ufuncs.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
np.sin(1)
44
np.sin([1, 2, 3])
55
np.sin(1, out=np.empty(1))
6-
np.matmul(
7-
np.ones((2, 2, 2)),
8-
np.ones((2, 2, 2)),
9-
axes=[(0, 1), (0, 1), (0, 1)],
10-
)
11-
np.sin(1, signature='D')
6+
np.matmul(np.ones((2, 2, 2)), np.ones((2, 2, 2)), axes=[(0, 1), (0, 1), (0, 1)])
7+
np.sin(1, signature="D")
128
np.sin(1, extobj=[16, 1, lambda: None])
139
np.sin(1) + np.sin(1)
1410
np.sin.types[0]

tests/pass/warnings_and_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
np.AxisError(1)
44
np.AxisError(1, ndim=2)
55
np.AxisError(1, ndim=None)
6-
np.AxisError(1, ndim=2, msg_prefix='error')
6+
np.AxisError(1, ndim=2, msg_prefix="error")
77
np.AxisError(1, ndim=2, msg_prefix=None)

0 commit comments

Comments
 (0)