Skip to content

Commit

Permalink
Fix code and linting issues that appeared after rebasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMauderer committed Jan 29, 2025
1 parent 1309ac3 commit a54e39c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
10 changes: 5 additions & 5 deletions colour_clf_io/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 6 additions & 7 deletions colour_clf_io/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
14 changes: 7 additions & 7 deletions colour_clf_io/process_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit a54e39c

Please sign in to comment.