Use modern Python type syntax in new DTMF code
Replace `Optional[X]` with `X | None`, `List[X]` with `list[X]`, and `Dict[str, Any]` with `dict[str, Any]` in the DTMF frame definitions and Daily transport code added by this branch.
This commit is contained in:
@@ -752,8 +752,8 @@ class OutputDTMFFrame(DTMFFrame, DataFrame):
|
|||||||
:meth:`from_string` to build this from a string like ``"123#"``.
|
:meth:`from_string` to build this from a string like ``"123#"``.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
button: Optional[KeypadEntry] = None
|
button: KeypadEntry | None = None
|
||||||
buttons: Optional[List[KeypadEntry]] = None
|
buttons: list[KeypadEntry] | None = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
super().__post_init__()
|
super().__post_init__()
|
||||||
@@ -1296,8 +1296,8 @@ class OutputDTMFUrgentFrame(DTMFFrame, SystemFrame):
|
|||||||
:meth:`from_string` to build this from a string like ``"123#"``.
|
:meth:`from_string` to build this from a string like ``"123#"``.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
button: Optional[KeypadEntry] = None
|
button: KeypadEntry | None = None
|
||||||
buttons: Optional[List[KeypadEntry]] = None
|
buttons: list[KeypadEntry] | None = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
super().__post_init__()
|
super().__post_init__()
|
||||||
|
|||||||
@@ -171,9 +171,9 @@ class DailyOutputDTMFFrame(OutputDTMFFrame):
|
|||||||
or ``auto``). When ``None``, Daily's default method is used.
|
or ``auto``). When ``None``, Daily's default method is used.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
session_id: Optional[str] = None
|
session_id: str | None = None
|
||||||
digit_duration_ms: Optional[int] = None
|
digit_duration_ms: int | None = None
|
||||||
method: Optional[str] = None
|
method: str | None = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -194,9 +194,9 @@ class DailyOutputDTMFUrgentFrame(OutputDTMFUrgentFrame):
|
|||||||
or ``auto``). When ``None``, Daily's default method is used.
|
or ``auto``). When ``None``, Daily's default method is used.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
session_id: Optional[str] = None
|
session_id: str | None = None
|
||||||
digit_duration_ms: Optional[int] = None
|
digit_duration_ms: int | None = None
|
||||||
method: Optional[str] = None
|
method: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class WebRTCVADAnalyzer(VADAnalyzer):
|
class WebRTCVADAnalyzer(VADAnalyzer):
|
||||||
@@ -2192,7 +2192,7 @@ class DailyOutputTransport(BaseOutputTransport):
|
|||||||
if not frame.buttons:
|
if not frame.buttons:
|
||||||
return
|
return
|
||||||
|
|
||||||
settings: Dict[str, Any] = {"tones": frame.to_string()}
|
settings: dict[str, Any] = {"tones": frame.to_string()}
|
||||||
if isinstance(frame, (DailyOutputDTMFFrame, DailyOutputDTMFUrgentFrame)):
|
if isinstance(frame, (DailyOutputDTMFFrame, DailyOutputDTMFUrgentFrame)):
|
||||||
if frame.session_id is not None:
|
if frame.session_id is not None:
|
||||||
settings["sessionId"] = frame.session_id
|
settings["sessionId"] = frame.session_id
|
||||||
|
|||||||
Reference in New Issue
Block a user