Allow "minimum"/"maximum" keys to be missing, as well as None

Some areas of the library check for both representations, and so doing
this here too means we are less likely to break existing code.

Despite this, flexibility introduces ambiguity, and so if typing gives
us confidence that such an input is unlikely, we could re-review this;
conditions with missing keys are not safe to use across the entire code-
base.
This commit is contained in:
Harry Dalton 2022-09-01 17:21:04 +01:00
parent fef9e9a071
commit 2da2653837

View File

@ -352,7 +352,7 @@ def _extractSubSpace(
def _conditionSetFrom(conditionSet: List[Dict[str, Any]]) -> ConditionSet:
c: Dict[str, Range] = {}
for condition in conditionSet:
minimum, maximum = condition["minimum"], condition["maximum"]
minimum, maximum = condition.get("minimum"), condition.get("maximum")
c[condition["name"]] = Range(
minimum if minimum is not None else -math.inf,
maximum if maximum is not None else math.inf,