Copilot commented on code in PR #173:
URL: https://github.com/apache/otava/pull/173#discussion_r3817921267
##########
otava/change_point_divisive/base.py:
##########
@@ -495,9 +495,21 @@ def select_metrics(self, m: list[str] | str):
request efficient. This will loop over all ChangePointGroup s.
Use ChangePointsByMetric if you need this to be fast.
"""
+ if not isinstance(m, list):
+ if not isinstance(m, str):
+ raise TypeError(
+ "ChangePoints.select_metrics() takes as argument a str or
a list of str."
+ )
+ m = [m]
+ for metric in m:
+ if metric not in self:
+ raise KeyError(metric)
Review Comment:
Lists are accepted without validating their elements, so
`select_metrics([1])` raises `KeyError(1)` even though the API contract
identifies non-string metric arguments as a `TypeError`. Validate every list
element before checking whether the metric exists so invalid types and missing
string metrics remain distinguishable.
This issue also appears on line 704 of the same file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]