Skip to content

Commit 35696bd

Browse files
committed
Update type checking imports
1 parent f901121 commit 35696bd

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

model_api/python/model_api/adapters/openvino_adapter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
from __future__ import annotations # TODO: remove when Python3.9 support is dropped
77

88
import logging as log
9-
from os import PathLike
109
from pathlib import Path
11-
from typing import Any
10+
from typing import TYPE_CHECKING, Any
1211

13-
from numpy import ndarray
12+
if TYPE_CHECKING:
13+
from os import PathLike
14+
15+
from numpy import ndarray
1416

1517
try:
1618
import openvino.runtime as ov

model_api/python/model_api/models/image_model.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
from __future__ import annotations # TODO: remove when Python3.9 support is dropped
77

8-
from typing import Any
8+
from typing import TYPE_CHECKING, Any
99

10-
import numpy as np
11-
12-
from model_api.adapters.inference_adapter import InferenceAdapter
1310
from model_api.adapters.utils import RESIZE_TYPES, InputTransform
1411
from model_api.models.model import Model
1512
from model_api.models.types import BooleanValue, ListValue, NumericalValue, StringValue
1613

14+
if TYPE_CHECKING:
15+
import numpy as np
16+
17+
from model_api.adapters.inference_adapter import InferenceAdapter
18+
1719

1820
class ImageModel(Model):
1921
"""An abstract wrapper for an image-based model

model_api/python/model_api/models/model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
import logging as log
99
import re
1010
from contextlib import contextmanager
11-
from os import PathLike
12-
from typing import Any, NoReturn, Type
11+
from typing import TYPE_CHECKING, Any, NoReturn, Type
1312

14-
from numpy import ndarray
15-
16-
from model_api.adapters.inference_adapter import InferenceAdapter
1713
from model_api.adapters.onnx_adapter import ONNXRuntimeAdapter
1814
from model_api.adapters.openvino_adapter import (
1915
OpenvinoAdapter,
@@ -22,6 +18,13 @@
2218
)
2319
from model_api.adapters.ovms_adapter import OVMSAdapter
2420

21+
if TYPE_CHECKING:
22+
from os import PathLike
23+
24+
from numpy import ndarray
25+
26+
from model_api.adapters.inference_adapter import InferenceAdapter
27+
2528

2629
class WrapperError(Exception):
2730
"""The class for errors occurred in Model API wrappers"""

model_api/python/model_api/models/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

6+
from __future__ import annotations # TODO: remove when Python3.9 support is dropped
67

78
from typing import Any
89

model_api/python/model_api/models/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def multiclass_nms(
167167
offsets = labels.astype(boxes.dtype) * (max_coordinate + 1)
168168
boxes_for_nms = boxes + offsets[:, None]
169169

170-
keep = nms(*boxes_for_nms.T, scores=scores, thresh=iou_threshold)
170+
keep = nms(*boxes_for_nms.T, scores=scores, thresh=iou_threshold) # type: ignore[misc]
171171
if max_num > 0:
172172
keep = keep[:max_num]
173173
keep = np.array(keep)

0 commit comments

Comments
 (0)