Skip to content

Commit 29942a2

Browse files
committed
AL-3578: Use explicit types
1 parent fe6407b commit 29942a2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

labelbox/schema/confidence_presence_checker.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from types import NoneType
12
from typing import Any, Dict, List, Union
23

34
from labelbox.data.annotation_types.annotation import (
@@ -34,13 +35,15 @@ def _check_annotation(cls, annotation: Union[ClassificationAnnotation,
3435
ScalarMetric,
3536
ConfusionMatrixMetric]):
3637

37-
if hasattr(annotation,
38-
'confidence') and annotation.confidence is not None:
38+
confidence: Union[float, NoneType] = getattr(annotation, 'confidence')
39+
if confidence is not None:
3940
return True
40-
if hasattr(annotation,
41-
'classifications') and annotation.classifications:
41+
42+
classifications: Union[List[ClassificationAnnotation], NoneType] = getattr(
43+
annotation, 'classifications')
44+
if classifications:
4245
return any([
43-
cls._check_classification(x) for x in annotation.classifications
46+
cls._check_classification(x) for x in classifications
4447
])
4548
return False
4649

0 commit comments

Comments
 (0)