diff --git a/colour_clf_io/elements.py b/colour_clf_io/elements.py index 3f127f5..5cda430 100644 --- a/colour_clf_io/elements.py +++ b/colour_clf_io/elements.py @@ -313,7 +313,7 @@ def from_xml( return SOPNode(slope=slope, offset=offset, power=power) @classmethod - def default(cls) -> Self: + def default(cls) -> SOPNode: """ Return the default SOPNode instance. Contains the default values that should be used per specification in case the actual value is not provided. @@ -395,7 +395,7 @@ def from_xml( return SatNode(saturation=saturation) @classmethod - def default(cls) -> Self: + def default(cls) -> SatNode: """ Return the default SatNode instance. Contains the default values that should be used per specification in case the actual value is not provided. @@ -504,7 +504,7 @@ def from_xml(xml: lxml.etree._Element | None, config: ParserConfig) -> Info | No }, ) calibration_info = CalibrationInfo.from_xml( - child_element(xml, "CalibrationInfo", config), # pyright: ignore + child_element(xml, "CalibrationInfo", config), config, ) @@ -640,7 +640,7 @@ def from_xml( return LogParams(channel=channel, **attributes) @classmethod - def default(cls) -> Self: + def default(cls) -> LogParams: """ Return the default LogParams instance. Contains the default values that should be used per specification in case the actual value is not provided. @@ -758,7 +758,7 @@ def from_xml( return ExponentParams(channel=channel, exponent=exponent, **attributes) @classmethod - def default(cls) -> Self: + def default(cls) -> ExponentParams: """ Return the default ExponentParams instance. Contains the default values that should be used per specification in case the actual value is not provided. diff --git a/colour_clf_io/parsing.py b/colour_clf_io/parsing.py index 60f567d..a0fb131 100644 --- a/colour_clf_io/parsing.py +++ b/colour_clf_io/parsing.py @@ -235,8 +235,8 @@ def check_none(value: T | None, message: str) -> TypeGuard[T]: def child_element( - xml, name, config: ParserConfig -) -> xml.etree.ElementTree.Element | None: + xml: lxml.etree._Element, name: str, config: ParserConfig +) -> lxml.etree._Element | None: """ Return a named child element of the given XML element. @@ -274,8 +274,8 @@ def child_element( def child_elements( - xml, name, config: ParserConfig -) -> list[xml.etree.ElementTree.Element]: + xml: lxml.etree._Element, name: str, config: ParserConfig +) -> list[lxml.etree._Element]: """ Return all child elements with a given name of an XML element. @@ -482,16 +482,15 @@ def three_floats(text: str | None) -> tuple[float, float, float]: :class:`tuple` of :class:`float` Three floating point values. """ + exception = f"Failed to parse three float values from {text}" if text is None: - exception = f"Failed to parse three float values from {text}" - raise ParsingError(exception) parts = text.split() if len(parts) != 3: - raise ParsingError(f"Failed to parse three float values from {s}") + raise ParsingError(exception) values = tuple(map(float, parts)) # Note: Repacking here to satisfy type check. return values[0], values[1], values[2] diff --git a/colour_clf_io/process_nodes.py b/colour_clf_io/process_nodes.py index e52cd4a..6a0353f 100644 --- a/colour_clf_io/process_nodes.py +++ b/colour_clf_io/process_nodes.py @@ -312,7 +312,7 @@ def from_xml(xml: lxml.etree._Element | None, config: ParserConfig) -> LUT1D | N return None super_args = ProcessNode.parse_attributes(xml, config) - array = Array.from_xml(child_element(xml, "Array", config), config) # pyright: ignore + array = Array.from_xml(child_element(xml, "Array", config), config) if array is None: exception = "LUT1D processing node does not have an Array element." @@ -380,7 +380,7 @@ def from_xml(xml: lxml.etree._Element | None, config: ParserConfig) -> LUT3D | N return None super_args = ProcessNode.parse_attributes(xml, config) - array = Array.from_xml(child_element(xml, "Array", config), config) # pyright: ignore + array = Array.from_xml(child_element(xml, "Array", config), config) if array is None: exception = "LUT3D processing node does not have an Array element." @@ -448,7 +448,7 @@ def from_xml( return None super_args = ProcessNode.parse_attributes(xml, config) - array = Array.from_xml(child_element(xml, "Array", config), config) # pyright: ignore + array = Array.from_xml(child_element(xml, "Array", config), config) if array is None: exception = "Matrix processing node does not have an Array element." @@ -584,7 +584,7 @@ def from_xml(xml: lxml.etree._Element | None, config: ParserConfig) -> Log | Non params = [ param for param in [ - LogParams.from_xml(param_element, config) # pyright: ignore + LogParams.from_xml(param_element, config) for param_element in param_elements ] if param is not None @@ -653,7 +653,7 @@ def from_xml( params = [ param for param in [ - ExponentParams.from_xml(param_element, config) # pyright: ignore + ExponentParams.from_xml(param_element, config) for param_element in param_elements ] if param is not None @@ -718,7 +718,7 @@ def from_xml( super_args = ProcessNode.parse_attributes(xml, config) style = ASC_CDLStyle(xml.get("style")) - sop_node = SOPNode.from_xml(child_element(xml, "SOPNode", config), config) # pyright: ignore - sat_node = SatNode.from_xml(child_element(xml, "SatNode", config), config) # pyright: ignore + sop_node = SOPNode.from_xml(child_element(xml, "SOPNode", config), config) + sat_node = SatNode.from_xml(child_element(xml, "SatNode", config), config) return ASC_CDL(style=style, sopnode=sop_node, sat_node=sat_node, **super_args)