Skip to content

Commit b7962d7

Browse files
committed
Run pyupgrade on codebase
https://github.com/asottile/pyupgrade `pyupgrade --py37-plus`
1 parent 8b10b8f commit b7962d7

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

doc/fake__sounddevice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def new_find_library(name):
1717
ctypes.util.find_library = new_find_library
1818

1919

20-
class ffi(object):
20+
class ffi:
2121

2222
NULL = NotImplemented
2323
I_AM_FAKE = True # This is used for the documentation of "default"
@@ -29,7 +29,7 @@ def dlopen(self, _):
2929
ffi = ffi()
3030

3131

32-
class FakeLibrary(object):
32+
class FakeLibrary:
3333

3434
# from portaudio.h:
3535

examples/plot_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def update_plot(frame):
100100
fig, ax = plt.subplots()
101101
lines = ax.plot(plotdata)
102102
if len(args.channels) > 1:
103-
ax.legend(['channel {}'.format(c) for c in args.channels],
103+
ax.legend([f'channel {c}' for c in args.channels],
104104
loc='lower left', ncol=len(args.channels))
105105
ax.axis((0, len(plotdata), -1, 1))
106106
ax.set_yticks([0])

examples/spectrogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def int_or_str(text):
6666
if char == '\t':
6767
bg, fg = fg, bg
6868
else:
69-
gradient.append('\x1b[{};{}m{}'.format(fg, bg + 10, char))
69+
gradient.append(f'\x1b[{fg};{bg + 10}m{char}')
7070

7171
try:
7272
samplerate = sd.query_devices(args.device, 'input')['default_samplerate']

sounddevice.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -554,14 +554,14 @@ def query_devices(device=None, kind=None):
554554
555555
"""
556556
if kind not in ('input', 'output', None):
557-
raise ValueError('Invalid kind: {!r}'.format(kind))
557+
raise ValueError(f'Invalid kind: {kind!r}')
558558
if device is None and kind is None:
559559
return DeviceList(query_devices(i)
560560
for i in range(_check(_lib.Pa_GetDeviceCount())))
561561
device = _get_device_id(device, kind, raise_on_error=True)
562562
info = _lib.Pa_GetDeviceInfo(device)
563563
if not info:
564-
raise PortAudioError('Error querying device {}'.format(device))
564+
raise PortAudioError(f'Error querying device {device}')
565565
assert info.structVersion == 2
566566
name_bytes = _ffi.string(info.name)
567567
try:
@@ -637,7 +637,7 @@ def query_hostapis(index=None):
637637
for i in range(_check(_lib.Pa_GetHostApiCount())))
638638
info = _lib.Pa_GetHostApiInfo(index)
639639
if not info:
640-
raise PortAudioError('Error querying host API {}'.format(index))
640+
raise PortAudioError(f'Error querying host API {index}')
641641
assert info.structVersion == 1
642642
return {
643643
'name': _ffi.string(info.name).decode(),
@@ -713,7 +713,7 @@ def get_portaudio_version():
713713
return _lib.Pa_GetVersion(), _ffi.string(_lib.Pa_GetVersionText()).decode()
714714

715715

716-
class _StreamBase(object):
716+
class _StreamBase:
717717
"""Direct or indirect base class for all stream classes."""
718718

719719
def __init__(self, kind, samplerate=None, blocksize=None, device=None,
@@ -892,7 +892,7 @@ def callback_ptr(iptr, optr, frames, time, status, _):
892892
_check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
893893
samplerate, blocksize, stream_flags,
894894
callback_ptr, userdata),
895-
'Error opening {}'.format(self.__class__.__name__))
895+
f'Error opening {self.__class__.__name__}')
896896

897897
# dereference PaStream** --> PaStream*
898898
self._ptr = self._ptr[0]
@@ -1819,7 +1819,7 @@ def __repr__(self):
18191819
digits = len(str(_lib.Pa_GetDeviceCount() - 1))
18201820
hostapi_names = [hostapi['name'] for hostapi in query_hostapis()]
18211821
text = '\n'.join(
1822-
u'{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)'.format(
1822+
'{mark} {idx:{dig}} {name}, {ha} ({ins} in, {outs} out)'.format(
18231823
mark=(' ', '>', '<', '*')[(idx == idev) + 2 * (idx == odev)],
18241824
idx=idx,
18251825
dig=digits,
@@ -1831,7 +1831,7 @@ def __repr__(self):
18311831
return text
18321832

18331833

1834-
class CallbackFlags(object):
1834+
class CallbackFlags:
18351835
"""Flag bits for the *status* argument to a stream *callback*.
18361836
18371837
If you experience under-/overflows, you can try to increase the
@@ -1881,7 +1881,7 @@ def __repr__(self):
18811881
flags = str(self)
18821882
if not flags:
18831883
flags = 'no flags set'
1884-
return '<sounddevice.CallbackFlags: {}>'.format(flags)
1884+
return f'<sounddevice.CallbackFlags: {flags}>'
18851885

18861886
def __str__(self):
18871887
return ', '.join(name.replace('_', ' ') for name in dir(self)
@@ -1999,7 +1999,7 @@ def _updateflag(self, flag, value):
19991999
self._flags &= ~flag
20002000

20012001

2002-
class _InputOutputPair(object):
2002+
class _InputOutputPair:
20032003
"""Parameter pairs for device, channels, dtype and latency."""
20042004

20052005
_indexmapping = {'input': 0, 'output': 1}
@@ -2024,7 +2024,7 @@ def __repr__(self):
20242024
return '[{0[0]!r}, {0[1]!r}]'.format(self)
20252025

20262026

2027-
class default(object):
2027+
class default:
20282028
"""Get/set defaults for the *sounddevice* module.
20292029
20302030
The attributes `device`, `channels`, `dtype`, `latency` and
@@ -2214,7 +2214,7 @@ class PortAudioError(Exception):
22142214
def __str__(self):
22152215
errormsg = self.args[0] if self.args else ''
22162216
if len(self.args) > 1:
2217-
errormsg = '{} [PaErrorCode {}]'.format(errormsg, self.args[1])
2217+
errormsg = f'{errormsg} [PaErrorCode {self.args[1]}]'
22182218
if len(self.args) > 2:
22192219
host_api, hosterror_code, hosterror_text = self.args[2]
22202220
hostname = query_hostapis(host_api)['name']
@@ -2250,7 +2250,7 @@ class CallbackAbort(Exception):
22502250
"""
22512251

22522252

2253-
class AsioSettings(object):
2253+
class AsioSettings:
22542254

22552255
def __init__(self, channel_selectors):
22562256
"""ASIO-specific input/output settings.
@@ -2302,7 +2302,7 @@ def __init__(self, channel_selectors):
23022302
channelSelectors=self._selectors))
23032303

23042304

2305-
class CoreAudioSettings(object):
2305+
class CoreAudioSettings:
23062306

23072307
def __init__(self, channel_map=None, change_device_parameters=False,
23082308
fail_if_conversion_required=False, conversion_quality='max'):
@@ -2394,7 +2394,7 @@ def __init__(self, channel_map=None, change_device_parameters=False,
23942394
len(self._channel_map))
23952395

23962396

2397-
class WasapiSettings(object):
2397+
class WasapiSettings:
23982398

23992399
def __init__(self, exclusive=False):
24002400
"""WASAPI-specific input/output settings.
@@ -2435,7 +2435,7 @@ def __init__(self, exclusive=False):
24352435
))
24362436

24372437

2438-
class _CallbackContext(object):
2438+
class _CallbackContext:
24392439
"""Helper class for re-use in play()/rec()/playrec() callbacks."""
24402440

24412441
blocksize = None
@@ -2725,7 +2725,7 @@ def _check(err, msg=''):
27252725

27262726
errormsg = _ffi.string(_lib.Pa_GetErrorText(err)).decode()
27272727
if msg:
2728-
errormsg = '{}: {}'.format(msg, errormsg)
2728+
errormsg = f'{msg}: {errormsg}'
27292729

27302730
if err == _lib.paUnanticipatedHostError:
27312731
# (gh82) We grab the host error info here rather than inside
@@ -2800,7 +2800,7 @@ def _get_device_id(id_or_query_string, kind, raise_on_error=False):
28002800
if raise_on_error:
28012801
raise ValueError('Multiple ' + kind + ' devices found for ' +
28022802
repr(id_or_query_string) + ':\n' +
2803-
'\n'.join('[{}] {}'.format(id, name)
2803+
'\n'.join(f'[{id}] {name}'
28042804
for id, name in matches))
28052805
else:
28062806
return -1

0 commit comments

Comments
 (0)