Skip to content

Commit be38463

Browse files
author
Val Brodsky
committed
Update pydantic types to Annotated
1 parent 65e27aa commit be38463

File tree

1 file changed

+8
-5
lines changed
  • libs/labelbox/src/labelbox/data/annotation_types/metrics

1 file changed

+8
-5
lines changed

libs/labelbox/src/labelbox/data/annotation_types/metrics/scalar.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from typing import Dict, Optional, Union
2+
from typing_extensions import Annotated
23
from enum import Enum
34

4-
from .base import ConfidenceValue, BaseMetric
5+
from pydantic import field_validator
6+
from pydantic.types import confloat
57

6-
from pydantic import confloat, field_validator, model_serializer
8+
from .base import ConfidenceValue, BaseMetric
79

8-
ScalarMetricValue = confloat(ge=0, le=100_000_000)
10+
ScalarMetricValue = Annotated[float, confloat(ge=0, le=100_000_000)]
911
ScalarMetricConfidenceValue = Dict[ConfidenceValue, ScalarMetricValue]
1012

1113

@@ -27,11 +29,12 @@ class ScalarMetric(BaseMetric):
2729
For backwards compatibility, metric_name is optional.
2830
The metric_name will be set to a default name in the editor if it is not set.
2931
This is not recommended and support for empty metric_name fields will be removed.
30-
aggregation will be ignored wihtout providing a metric name.
32+
aggregation will be ignored without providing a metric name.
3133
"""
3234
metric_name: Optional[str] = None
3335
value: Union[ScalarMetricValue, ScalarMetricConfidenceValue]
34-
aggregation: ScalarMetricAggregation = ScalarMetricAggregation.ARITHMETIC_MEAN
36+
aggregation: Optional[
37+
ScalarMetricAggregation] = ScalarMetricAggregation.ARITHMETIC_MEAN
3538

3639
@field_validator('metric_name')
3740
def validate_metric_name(cls, name: Union[str, None]):

0 commit comments

Comments
 (0)