Skip to content

Commit fe65ede

Browse files
enable more rules
Signed-off-by: Ashwin Vaidya <[email protected]>
1 parent 65b3a4a commit fe65ede

File tree

8 files changed

+25
-27
lines changed

8 files changed

+25
-27
lines changed

model_api/python/model_api/adapters/openvino_adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(
133133
self.is_onnx_file = False
134134
self.onnx_metadata = {}
135135

136-
if isinstance(self.model_path, (str, Path)):
136+
if isinstance(self.model_path, str | Path):
137137
if Path(self.model_path).suffix == ".onnx" and weights_path:
138138
log.warning(
139139
'For model in ONNX format should set only "model_path" parameter.'
@@ -301,7 +301,7 @@ def await_any(self) -> None:
301301
def _get_meta_from_ngraph(self, layers_info):
302302
for node in self.model.get_ordered_ops():
303303
layer_name = node.get_friendly_name()
304-
if layer_name not in layers_info.keys():
304+
if layer_name not in layers_info:
305305
continue
306306
layers_info[layer_name].meta = node.get_attributes()
307307
layers_info[layer_name].type = node.get_type_name()

model_api/python/model_api/adapters/ovms_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def _verify_model_available(client, model_name, model_version):
185185
def _prepare_inputs(dict_data, inputs_meta):
186186
inputs = {}
187187
for input_name, input_data in dict_data.items():
188-
if input_name not in inputs_meta.keys():
188+
if input_name not in inputs_meta:
189189
raise ValueError("Input data does not match model inputs")
190190
input_info = inputs_meta[input_name]
191191
model_precision = _tf2np_precision[input_info["dtype"]]

model_api/python/model_api/adapters/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from __future__ import annotations # TODO: remove when Python3.9 support is dropped
77

88
import math
9+
from collections.abc import Callable
910
from functools import partial
10-
from typing import Callable
1111

1212
import cv2
1313
import numpy as np

model_api/python/model_api/models/instance_segmentation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ def postprocess(self, outputs, meta):
207207
output_mask,
208208
),
209209
)
210-
if has_feature_vector_name:
211-
if confidence > self.confidence_threshold:
212-
saliency_maps[cls - 1].append(resized_mask)
210+
if has_feature_vector_name and confidence > self.confidence_threshold:
211+
saliency_maps[cls - 1].append(resized_mask)
213212
return InstanceSegmentationResult(
214213
objects,
215214
_average_and_normalize(saliency_maps),

model_api/python/model_api/models/types.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,12 @@ def validate(self, value):
6969
),
7070
)
7171
return errors
72-
if len(self.choices):
73-
if value not in self.choices:
74-
errors.append(
75-
ConfigurableValueError(
76-
f"Incorrect value {value}: out of allowable list - {self.choices}",
77-
),
78-
)
72+
if len(self.choices) and value not in self.choices:
73+
errors.append(
74+
ConfigurableValueError(
75+
f"Incorrect value {value}: out of allowable list - {self.choices}",
76+
),
77+
)
7978
if self.min is not None and value < self.min:
8079
errors.append(
8180
ConfigurableValueError(
@@ -188,7 +187,7 @@ def validate(self, value):
188187
errors = super().validate(value)
189188
if not value:
190189
return errors
191-
if not isinstance(value, (tuple, list)):
190+
if not isinstance(value, tuple | list):
192191
errors.append(
193192
ConfigurableValueError(
194193
f"Incorrect value type - {type(value)}: should be list or tuple",

model_api/python/model_api/models/yolo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def iou(box_1, box_2):
318318

319319
def _parse_outputs(self, outputs, meta):
320320
detections = []
321-
for layer_name in self.yolo_layer_params.keys():
321+
for layer_name in self.yolo_layer_params:
322322
out_blob = outputs[layer_name]
323323
layer_params = self.yolo_layer_params[layer_name]
324324
out_blob.shape = layer_params[0]

model_api/python/model_api/pipelines/async_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from time import perf_counter
77

8-
from ..performance_metrics import PerformanceMetrics
8+
from model_api.performance_metrics import PerformanceMetrics
99

1010

1111
class AsyncPipeline:

model_api/python/pyproject.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ preview = true
9292
lint.select = [
9393
# "F", # Pyflakes (`F`)
9494
"E", # pycodestyle error (`E`)
95-
# "W", # pycodestyle warning (`W`)
95+
"W", # pycodestyle warning (`W`)
9696
# "C90", # mccabe (`C90`)
9797
"I", # isort (`I`)
9898
# "N", # pep8-naming (`N`)
9999
# "D", # pydocstyle (`D`)
100-
# "UP", # pyupgrade (`UP`)
100+
"UP", # pyupgrade (`UP`)
101101
# "YTT", # flake8-2020 (`YTT`)
102102
# "ANN", # flake8-annotations (`ANN`)
103103
# "S", # flake8-bandit (`S`)
@@ -106,9 +106,9 @@ lint.select = [
106106
# "B", # flake8-bugbear (`B`)
107107
# "A", # flake8-builtins (`A`)
108108
# "COM", # flake8-commas (`COM`)
109-
# "CPY", # flake8-copyright (`CPY`)
109+
"CPY", # flake8-copyright (`CPY`)
110110
# "C4", # flake8-comprehensions (`C4`)
111-
# "DTZ", # flake8-datatimez (`DTZ`)
111+
"DTZ", # flake8-datatimez (`DTZ`)
112112
# "T10", # flake8-debugger (`T10`)
113113
# "EM", # flake8-errmsg (`EM`)
114114
# "FA", # flake8-future-annotations (`FA`)
@@ -118,22 +118,22 @@ lint.select = [
118118
# "PT", # flake8-pytest-style (`PT`)
119119
# "RSE", # flake8-raise (`RSE`)
120120
# "RET", # flake8-return (`RET`)
121-
# "SLF", # flake8-self (`SLF`)
122-
# "SIM", # flake8-simplify (`SIM`)
123-
# "TID", # flake8-tidy-imports (`TID`)
121+
"SLF", # flake8-self (`SLF`)
122+
"SIM", # flake8-simplify (`SIM`)
123+
"TID", # flake8-tidy-imports (`TID`)
124124
# "TCH", # flake8-type-checking (`TCH`)
125125
# "INT", # flake8-gettext (`INT`)
126126
# "ARG", # flake8-unsused-arguments (`ARG`)
127127
# "PTH", # flake8-use-pathlib (`PTH`)
128128
# "TD", # flake8-todos (`TD`)
129129
# "FIX", # flake8-fixme (`FIX`)
130130
# "ERA", # eradicate (`ERA`)
131-
# "PD", # pandas-vet (`PD`)
132-
# "PGH", # pygrep-hooks (`PGH`)
131+
"PD", # pandas-vet (`PD`)
132+
"PGH", # pygrep-hooks (`PGH`)
133133
# "PL", # pylint (`PL`)
134134
# "TRY", # tryceratos (`TRY`)
135135
# "FLY", # flynt (`FLY`)
136-
# "NPY", # NumPy-specific rules (`NPY`)
136+
"NPY", # NumPy-specific rules (`NPY`)
137137
# "PERF", # Perflint (`PERF`)
138138
# "RUF", # Ruff-specific rules (`RUF`)
139139
# "FURB", # refurb (`FURB`) - ERROR: Unknown rule selector: `FURB`

0 commit comments

Comments
 (0)