aboutsummaryrefslogtreecommitdiff
path: root/discord/opus.py
diff options
context:
space:
mode:
authorStocker <[email protected]>2021-08-19 20:23:35 -0400
committerGitHub <[email protected]>2021-08-19 20:23:35 -0400
commitb6590d7f56ae5f4b3b5f97786995453f912c47d2 (patch)
treefcad962587ced127e4beba6d82caea7945c5dd38 /discord/opus.py
parentFix missing typehint that causes an error for a type checker (diff)
downloaddiscord.py-b6590d7f56ae5f4b3b5f97786995453f912c47d2.tar.xz
discord.py-b6590d7f56ae5f4b3b5f97786995453f912c47d2.zip
Add a few typehints to opus.py
Diffstat (limited to 'discord/opus.py')
-rw-r--r--discord/opus.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/discord/opus.py b/discord/opus.py
index 88127f99..62628753 100644
--- a/discord/opus.py
+++ b/discord/opus.py
@@ -22,6 +22,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
+from typing import List, Tuple, TypedDict, Any
+
import array
import ctypes
import ctypes.util
@@ -33,13 +35,25 @@ import sys
from .errors import DiscordException
+class BandCtl(TypedDict):
+ narrow: int
+ medium: int
+ wide: int
+ superwide: int
+ full: int
+
+class SignalCtl(TypedDict):
+ auto: int
+ voice: int
+ music: int
+
__all__ = (
'Encoder',
'OpusError',
'OpusNotLoaded',
)
-log = logging.getLogger(__name__)
+log: logging.Logger = logging.getLogger(__name__)
c_int_ptr = ctypes.POINTER(ctypes.c_int)
c_int16_ptr = ctypes.POINTER(ctypes.c_int16)
@@ -76,7 +90,7 @@ CTL_SET_SIGNAL = 4024
CTL_SET_GAIN = 4034
CTL_LAST_PACKET_DURATION = 4039
-band_ctl = {
+band_ctl: BandCtl = {
'narrow': 1101,
'medium': 1102,
'wide': 1103,
@@ -84,7 +98,7 @@ band_ctl = {
'full': 1105,
}
-signal_ctl = {
+signal_ctl: SignalCtl = {
'auto': -1000,
'voice': 3001,
'music': 3002,
@@ -108,7 +122,7 @@ def _err_ne(result, func, args):
# The second one are the types of arguments it takes.
# The third is the result type.
# The fourth is the error handler.
-exported_functions = [
+exported_functions: List[Tuple[Any, ...]] = [
# Generic
('opus_get_version_string',
None, ctypes.c_char_p, None),