Skip to content

Commit fd8753b

Browse files
committed
Accept suggestions from new toolchain
1 parent 5c8d88d commit fd8753b

File tree

15 files changed

+88
-60
lines changed

15 files changed

+88
-60
lines changed

‎test/files.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pathlib import Path
2+
23
import stroll
4+
35
import wavemap
46

57
FILE_ROOT = Path(__file__).parent

‎test/test_convert.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from numpy.testing import assert_array_equal
2-
import numpy as np
31
import unittest
2+
3+
import numpy as np
4+
from numpy.testing import assert_array_equal
5+
46
import wavemap
57

68

‎test/test_docs.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
from wavemap import ReadMap
21
import inspect
32
import unittest
43

4+
from wavemap import ReadMap
5+
56

67
class TestDocs(unittest.TestCase):
78
def test_docs(self):
89
actual = inspect.getdoc(ReadMap.__new__)
910
expected = READMAP_DOC
1011
if expected != actual:
1112
print("expected", "------", "", *expected, sep="\n")
12-
print
13+
print()
1314
print("actual", "------", "", *actual, sep="\n")
1415
if True:
1516
assert expected == actual

‎test/test_expected.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
from . import files
1+
import unittest
22
from pathlib import Path
3+
34
import tdir
4-
import unittest
5+
56
import wavemap
67

8+
from . import files
9+
710

811
class TestExpected(unittest.TestCase):
912
@tdir

‎test/test_read.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
from . import files
21
import unittest
2+
33
import wavemap
44

5+
from . import files
6+
57

68
class TestWaveMap(unittest.TestCase):
79
def test_snare(self):

‎test/test_vs_ffmpeg.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
from . import files
2-
from numpy.testing import assert_array_equal
3-
from pathlib import Path
4-
import numpy as np
51
import os
62
import subprocess
7-
import tdir
83
import unittest
4+
from pathlib import Path
5+
6+
import numpy as np
7+
import tdir
8+
from numpy.testing import assert_array_equal
9+
910
import wavemap
1011

12+
from . import files
13+
1114
IS_TRAVIS = os.getenv("TRAVIS", "").lower().startswith("t")
1215
skip_if_travis = unittest.skipIf(IS_TRAVIS, "Test does not work in travis")
1316

‎test/test_write.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
from . import files
2-
from numpy.testing import assert_array_equal
3-
from pathlib import Path
41
import struct
5-
import tdir
62
import unittest
3+
from pathlib import Path
4+
5+
import tdir
6+
from numpy.testing import assert_array_equal
7+
78
import wavemap
89

10+
from . import files
11+
912

1013
class TestWaveWrite(unittest.TestCase):
1114
def test_write1(self):

‎wavemap/__init__.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727
# Each sample in the file is scaled by half.
2828
"""
2929

30+
from typing import Optional, Union
31+
from collections.abc import Callable
32+
33+
import numpy as np
34+
import xmod
35+
3036
from . import docs
3137
from .convert import convert
3238
from .raw import RawMap, warn
3339
from .read import ReadMap as ReadMap
3440
from .write import WriteMap as WriteMap
35-
from typing import Callable, Optional, Union
36-
import numpy as np
37-
import xmod
3841

3942
__all__ = (
4043
"wavemap",
@@ -61,19 +64,19 @@ def wavemap(
6164
# Read parameters
6265
#
6366
mode: str = "r",
64-
order: Optional[str] = None,
67+
order: str | None = None,
6568
always_2d: bool = False,
6669
#
6770
# Write parameters
6871
#
69-
dtype: Optional[np.dtype] = None,
70-
shape: Union[None, int, tuple] = None,
72+
dtype: np.dtype | None = None,
73+
shape: None | int | tuple = None,
7174
sample_rate: int = 0,
7275
roffset: int = 0,
7376
#
7477
# Read and write parameters
7578
#
76-
warn: Optional[Callable] = warn,
79+
warn: Callable | None = warn,
7780
):
7881
"""
7982
Memory map a WAVE file to a `numpy` array

‎wavemap/convert.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from numpy.lib.stride_tricks import as_strided
21
from typing import Optional
2+
33
import numpy as np
4+
from numpy.lib.stride_tricks import as_strided
45

56

6-
def convert(arr: np.ndarray, dtype: Optional[np.dtype], must_copy: bool = False):
7+
def convert(arr: np.ndarray, dtype: np.dtype | None, must_copy: bool = False):
78
"""
89
Returns a copy of a numpy array or matrix that represents audio data in
910
another type, scaling and shifting as necessary.

‎wavemap/memmap.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from numpy.compat import os_fspath, contextlib_nullcontext, is_pathlib_path
2-
from numpy.core.numeric import uint8, ndarray, dtype
3-
from numpy.core.overrides import set_module
41
import numpy as np
2+
from numpy.compat import contextlib_nullcontext, is_pathlib_path, os_fspath
3+
from numpy.core.numeric import dtype, ndarray, uint8
4+
from numpy.core.overrides import set_module
55

66
__all__ = ["memmap"]
77

@@ -332,7 +332,7 @@ def flush(self):
332332
self.base.flush()
333333

334334
def __array_wrap__(self, arr, context=None):
335-
arr = super(memmap, self).__array_wrap__(arr, context)
335+
arr = super().__array_wrap__(arr, context)
336336

337337
# Return a memmap if a memmap was given as the output of the
338338
# ufunc. Leave the arr class unchanged if self is not a memmap
@@ -347,7 +347,7 @@ def __array_wrap__(self, arr, context=None):
347347
return arr.view(np.ndarray)
348348

349349
def __getitem__(self, index):
350-
res = super(memmap, self).__getitem__(index)
350+
res = super().__getitem__(index)
351351
if type(res) is memmap and res._mmap is None:
352352
return res.view(type=ndarray)
353353
return res

0 commit comments

Comments
 (0)