Add type annotations to Edit class constructor and attributes for clarity

This commit is contained in:
Jamie Hardt
2025-12-16 18:13:16 -08:00
parent 58f28e3e2e
commit 5a093e10d2

View File

@@ -2,7 +2,16 @@
# (c) 2018-2025 Jamie Hardt # (c) 2018-2025 Jamie Hardt
from pycmx.cdl import AscSopComponents, FramecountTriple from pycmx.cdl import AscSopComponents, FramecountTriple
from pycmx.statements import StmtCdlSat, StmtCdlSop, StmtFrmc from pycmx.statements import (
StmtCdlSat,
StmtCdlSop,
StmtFrmc,
StmtEvent,
StmtAudioExt,
StmtClipName,
StmtSourceFile,
StmtEffectsName,
)
from .transition import Transition from .transition import Transition
from .channel_map import ChannelMap from .channel_map import ChannelMap
@@ -15,16 +24,23 @@ class Edit:
recorder timecode in and out, a transition and channels. recorder timecode in and out, a transition and channels.
""" """
def __init__(self, edit_statement, audio_ext_statement, def __init__(
clip_name_statement, source_file_statement, self,
trans_name_statement=None, asc_sop_statement=None, edit_statement: StmtEvent,
asc_sat_statement=None, frmc_statement=None): audio_ext_statement: Optional[StmtAudioExt],
clip_name_statement: Optional[StmtClipName],
self._edit_statement = edit_statement source_file_statement: Optional[StmtSourceFile],
self._audio_ext = audio_ext_statement trans_name_statement: Optional[StmtEffectsName] = None,
self._clip_name_statement = clip_name_statement asc_sop_statement: Optional[StmtCdlSop] = None,
self._source_file_statement = source_file_statement asc_sat_statement: Optional[StmtCdlSat] = None,
self._trans_name_statement = trans_name_statement frmc_statement: Optional[StmtFrmc] = None,
) -> None:
# Assigning types for the attributes explicitly
self._edit_statement: StmtEvent = edit_statement
self._audio_ext: Optional[StmtAudioExt] = audio_ext_statement
self._clip_name_statement: Optional[StmtClipName] = clip_name_statement
self._source_file_statement: Optional[StmtSourceFile] = source_file_statement
self._trans_name_statement: Optional[StmtEffectsName] = trans_name_statement
self._asc_sop_statement: Optional[StmtCdlSop] = asc_sop_statement self._asc_sop_statement: Optional[StmtCdlSop] = asc_sop_statement
self._asc_sat_statement: Optional[StmtCdlSat] = asc_sat_statement self._asc_sat_statement: Optional[StmtCdlSat] = asc_sat_statement
self._frmc_statement: Optional[StmtFrmc] = frmc_statement self._frmc_statement: Optional[StmtFrmc] = frmc_statement
@@ -55,12 +71,15 @@ class Edit:
Get the :obj:`Transition` that initiates this edit. Get the :obj:`Transition` that initiates this edit.
""" """
if self._trans_name_statement: if self._trans_name_statement:
return Transition(self._edit_statement.trans, return Transition(
self._edit_statement.trans_op, self._edit_statement.trans,
self._trans_name_statement.name) self._edit_statement.trans_op,
self._trans_name_statement.name,
)
else: else:
return Transition(self._edit_statement.trans, return Transition(
self._edit_statement.trans_op, None) self._edit_statement.trans, self._edit_statement.trans_op, None
)
@property @property
def source_in(self) -> str: def source_in(self) -> str:
@@ -166,6 +185,8 @@ class Edit:
if not self._frmc_statement: if not self._frmc_statement:
return None return None
return FramecountTriple(start=self._frmc_statement.start, return FramecountTriple(
end=self._frmc_statement.end, start=self._frmc_statement.start,
duration=self._frmc_statement.duration) end=self._frmc_statement.end,
duration=self._frmc_statement.duration,
)