|
1 | | - |
2 | 1 | import asyncio |
3 | 2 | import errno |
4 | 3 | import select |
5 | 4 | import time |
| 5 | +from collections.abc import MutableMapping |
6 | 6 | from dataclasses import dataclass, field |
7 | 7 | from enum import IntEnum, IntFlag |
8 | 8 | from functools import partial |
9 | | -from typing import (Any, Callable, List, MutableMapping, NewType, Optional, Set, Tuple, Union, |
10 | | - overload) |
| 9 | +from typing import Any, Callable, NewType, Optional, Union, overload |
11 | 10 | from weakref import WeakValueDictionary |
12 | 11 |
|
13 | 12 | from ._ffi import alsa, ffi |
|
21 | 20 | from .util import _check_alsa_error |
22 | 21 |
|
23 | 22 | _snd_seq_t = NewType("_snd_seq_t", object) |
24 | | -_snd_seq_t_p = NewType("_snd_seq_t_p", Tuple[_snd_seq_t]) |
| 23 | +_snd_seq_t_p = NewType("_snd_seq_t_p", tuple[_snd_seq_t]) |
25 | 24 | _snd_midi_event_t = NewType("_snd_midi_event_t", object) |
26 | 25 |
|
27 | 26 |
|
@@ -90,7 +89,7 @@ class ClientInfo: |
90 | 89 | pid: Optional[int] = None |
91 | 90 | num_ports: int = 0 |
92 | 91 | event_lost: int = 0 |
93 | | - event_filter: Optional[Set[EventType]] = None |
| 92 | + event_filter: Optional[set[EventType]] = None |
94 | 93 |
|
95 | 94 | @classmethod |
96 | 95 | def _from_alsa(cls, info: _snd_seq_client_info_t): |
@@ -661,7 +660,7 @@ def drop_output_buffer(self): |
661 | 660 | err = alsa.snd_seq_drop_output_buffer(self.handle) |
662 | 661 | _check_alsa_error(err) |
663 | 662 |
|
664 | | - def _event_input(self, prefer_bytes: bool = False) -> Tuple[int, Optional[Event]]: |
| 663 | + def _event_input(self, prefer_bytes: bool = False) -> tuple[int, Optional[Event]]: |
665 | 664 | buf = ffi.new("snd_seq_event_t**", ffi.NULL) |
666 | 665 | result = alsa.snd_seq_event_input(self.handle, buf) |
667 | 666 | if result < 0: |
@@ -730,7 +729,7 @@ def _prepare_event(self, |
730 | 729 | queue: Union['Queue', int] = None, |
731 | 730 | port: Union['Port', int] = None, |
732 | 731 | dest: AddressType = None, |
733 | | - remainder: Optional[Any] = None) -> Tuple[_snd_seq_event_t, Any]: |
| 732 | + remainder: Optional[Any] = None) -> tuple[_snd_seq_event_t, Any]: |
734 | 733 | """Prepare ALSA :alsa:`snd_seq_event_t` for given `event` object for output. |
735 | 734 |
|
736 | 735 | For :class:`alsa_midi.MidiBytesEvent` may need to be called more than |
@@ -780,7 +779,7 @@ def _event_output(self, |
780 | 779 | queue: Union['Queue', int] = None, |
781 | 780 | port: Union['Port', int] = None, |
782 | 781 | dest: AddressType = None, |
783 | | - remainder: Optional[Any] = None) -> Tuple[int, Any]: |
| 782 | + remainder: Optional[Any] = None) -> tuple[int, Any]: |
784 | 783 | alsa_event, remainder = self._prepare_event(event, |
785 | 784 | queue=queue, port=port, dest=dest, |
786 | 785 | remainder=remainder) |
@@ -864,7 +863,7 @@ def _event_output_direct(self, |
864 | 863 | queue: Union['Queue', int] = None, |
865 | 864 | port: Union['Port', int] = None, |
866 | 865 | dest: AddressType = None, |
867 | | - remainder: Optional[Any] = None) -> Tuple[int, Any]: |
| 866 | + remainder: Optional[Any] = None) -> tuple[int, Any]: |
868 | 867 | alsa_event, remainder = self._prepare_event(event, |
869 | 868 | queue=queue, port=port, dest=dest, |
870 | 869 | remainder=remainder) |
@@ -1114,7 +1113,7 @@ def list_ports(self, *, |
1114 | 1113 | include_no_export: bool = True, |
1115 | 1114 | only_connectable: bool = True, |
1116 | 1115 | sort: Union[bool, Callable[[PortInfo], Any]] = True, |
1117 | | - ) -> List[PortInfo]: |
| 1116 | + ) -> list[PortInfo]: |
1118 | 1117 | """More friendly interface to list available ports. |
1119 | 1118 |
|
1120 | 1119 | Queries ALSA for all clients and ports and returns those matching the selected criteria. |
@@ -1327,7 +1326,7 @@ def query_port_subscribers(self, |
1327 | 1326 | def list_port_subscribers(self, |
1328 | 1327 | port: AddressType, |
1329 | 1328 | type: Optional[SubscriptionQueryType] = None, |
1330 | | - ) -> List[SubscriptionQuery]: |
| 1329 | + ) -> list[SubscriptionQuery]: |
1331 | 1330 | """Lists subscribers accessing a port. |
1332 | 1331 |
|
1333 | 1332 | Wraps :alsa:`snd_seq_query_port_subscribers`. |
|
0 commit comments