From 9d39b135f4f84239787b0901d06a4f370a82d4bb Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 4 Apr 2021 04:40:19 -0400 Subject: Modernize code to use f-strings This also removes the encoding on the top, since Python 3 does it by default. It also changes some methods to use `yield from`. --- discord/opus.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'discord/opus.py') diff --git a/discord/opus.py b/discord/opus.py index 94adf338..afc55175 100644 --- a/discord/opus.py +++ b/discord/opus.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - """ The MIT License (MIT) @@ -185,7 +183,7 @@ def _load_default(): _basedir = os.path.dirname(os.path.abspath(__file__)) _bitness = struct.calcsize('P') * 8 _target = 'x64' if _bitness > 32 else 'x86' - _filename = os.path.join(_basedir, 'bin', 'libopus-0.{}.dll'.format(_target)) + _filename = os.path.join(_basedir, 'bin', f'libopus-0.{_target}.dll') _lib = libopus_loader(_filename) else: _lib = libopus_loader(ctypes.util.find_library('opus')) @@ -310,14 +308,14 @@ class Encoder(_OpusStruct): def set_bandwidth(self, req): if req not in band_ctl: - raise KeyError('%r is not a valid bandwidth setting. Try one of: %s' % (req, ','.join(band_ctl))) + raise KeyError(f'{req!r} is not a valid bandwidth setting. Try one of: {",".join(band_ctl)}') k = band_ctl[req] _lib.opus_encoder_ctl(self._state, CTL_SET_BANDWIDTH, k) def set_signal_type(self, req): if req not in signal_ctl: - raise KeyError('%r is not a valid signal setting. Try one of: %s' % (req, ','.join(signal_ctl))) + raise KeyError(f'{req!r} is not a valid bandwidth setting. Try one of: {",".join(signal_ctl)}') k = signal_ctl[req] _lib.opus_encoder_ctl(self._state, CTL_SET_SIGNAL, k) -- cgit v1.2.3