Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PyOV] Replace deprecated typing types (#30762)

Anastasia Kuporosova9e25ca366bbd
diff --git a/.github/actions/create_manifest/manifest_manager.py b/.github/actions/create_manifest/manifest_manager.py
index 9978f65c0d5..3d8d4a7cba4 100644
--- a/.github/actions/create_manifest/manifest_manager.py
+++ b/.github/actions/create_manifest/manifest_manager.py
@@ -6,7 +6,8 @@ from __future__ import annotations
import yaml
from pathlib import Path
from copy import deepcopy
-from typing import Optional, Dict, List, Union, Iterator, Any
+from typing import Optional, Union, Any
+from collections.abc import Iterator
class ManifestException(Exception):
@@ -43,7 +44,7 @@ class Manifest:
self._manifest_file = self._manifest_file / self.default_manifest_name
self._manifest_version = "1.0"
- self._components: Dict[str, Component] = {}
+ self._components: dict[str, Component] = {}
if manifest_path is not None:
self._prepare_manifest()
@@ -81,7 +82,7 @@ class Manifest:
return self._manifest_version
@property
- def components(self) -> List[Component]:
+ def components(self) -> list[Component]:
return list(self._components.values())
def get_component(self, component_name: str) -> Optional[Component]:
@@ -131,7 +132,7 @@ class Manifest:
except Exception as ex:
raise ManifestSavingError(ex) from ex
- def as_dict(self) -> Dict[str, Union[str, Dict]]:
+ def as_dict(self) -> dict[str, Union[str, dict]]:
"""Return manifest as dictionary"""
if not self._manifest_file.is_file():
raise ManifestDoesNotExist(f'Cannot find manifest "{self._manifest_file}"')
@@ -204,7 +205,7 @@ class Component:
:param name: Name of component
:param version: Version of component
- :param repositories: List of repositories
+ :param repositories: list of repositories
:param product_type: Unique key to describe a product type (can include OS, arch, build variant, etc)
:param target_arch: Target architecture
:param build_type: Type of build (release, debug)
@@ -303,7 +304,7 @@ class Component:
return self._build_event
@property
- def repositories(self) -> List[Repository]:
+ def repositories(self) -> list[Repository]:
return list(self._repositories.values())
@property
diff --git a/.github/actions/validate_pyi_files/compare_pyi_files.py b/.github/actions/validate_pyi_files/compare_pyi_files.py
index 4227767b5a1..a01b4c85a45 100644
--- a/.github/actions/validate_pyi_files/compare_pyi_files.py
+++ b/.github/actions/validate_pyi_files/compare_pyi_files.py
@@ -8,7 +8,6 @@ import os
import sys
import filecmp
import difflib
-from typing import List, Set
# Due to numerous issues with stub generation reproducibility we need some skips.
# The inconsistencies between generations most likely come from different environment/CMake setups.
@@ -21,9 +20,9 @@ SKIPS = [
"openvino/tools/ovc/moc_frontend/extractor.pyi"
]
-def find_pyi_files(directory: str) -> Set[str]:
+def find_pyi_files(directory: str) -> set[str]:
"""Recursively find all .pyi files in a directory."""
- pyi_files: List[str] = []
+ pyi_files: list[str] = []
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(".pyi"):
@@ -35,8 +34,8 @@ def find_pyi_files(directory: str) -> Set[str]:
def compare_pyi_files(generated_dir: str, committed_dir: str) -> None:
"""Compare .pyi files between two directories."""
# Find all .pyi files in both directories
- generated_files: Set[str] = find_pyi_files(generated_dir)
- committed_files: Set[str] = find_pyi_files(committed_dir)
+ generated_files: set[str] = find_pyi_files(generated_dir)
+ committed_files: set[str] = find_pyi_files(committed_dir)
# Assert that the number of .pyi files matches
if len(generated_files) != len(committed_files):
diff --git a/.github/github_org_control/github_api.py b/.github/github_org_control/github_api.py
index 581921f3943..ee59ae97996 100644
--- a/.github/github_org_control/github_api.py
+++ b/.github/github_org_control/github_api.py
@@ -9,9 +9,9 @@ GitHub API for controlling organization
import re
import sys
-import time
-import typing
+import time
from pathlib import Path
+from collections.abc import Iterable
from github import Github, GithubException, RateLimitExceededException, IncompletableObject
from github.PaginatedList import PaginatedList
@@ -317,7 +317,7 @@ class GithubOrgApi:
def invite_users(self, users):
"""Invites users to GitHub organization and prints status"""
- if not isinstance(users, typing.Iterable):
+ if not isinstance(users, Iterable):
users = [users]
print(f"\nInvite {len(users)} users:")
@@ -341,7 +341,7 @@ class GithubOrgApi:
def remove_users(self, users):
"""Removes users from GitHub organization"""
- if not isinstance(users, typing.Iterable):
+ if not isinstance(users, Iterable):
users = [users]
print(f"\nRemove {len(users)} users:")
diff --git a/docs/openvino_sphinx_theme/openvino_sphinx_theme/directives/code.py b/docs/openvino_sphinx_theme/openvino_sphinx_theme/directives/code.py
index 814517289ce..40127c7c401 100644
--- a/docs/openvino_sphinx_theme/openvino_sphinx_theme/directives/code.py
+++ b/docs/openvino_sphinx_theme/openvino_sphinx_theme/directives/code.py
@@ -1,16 +1,10 @@
import os.path
-from pathlib import Path
-import sys
from sphinx.directives.code import LiteralInclude, LiteralIncludeReader, container_wrapper
from sphinx.util import logging
from docutils.parsers.rst import Directive, directives
-from typing import List, Tuple
from docutils.nodes import Node
from docutils import nodes
from sphinx.util import parselinenos
-import requests
-import re
-import json
import html
import csv
@@ -21,7 +15,7 @@ class DoxygenSnippet(LiteralInclude):
option_spec = dict({'fragment': directives.unchanged_required}, **LiteralInclude.option_spec)
- def run(self) -> List[Node]:
+ def run(self) -> list[Node]:
if 'fragment' in self.options:
self.options['start-after'] = self.options['fragment']
self.options['end-before'] = self.options['fragment']
@@ -152,7 +146,7 @@ class DataTable(Directive):
'data-order': directives.unchanged
}
- def run(self) -> List[Node]:
+ def run(self) -> list[Node]:
current_directory = os.path.dirname(os.path.abspath(self.state.document.current_source))
csv_file = os.path.normpath(os.path.join(current_directory, self.options['file']))
if os.path.isfile(csv_file) is False:
diff --git a/samples/python/model_creation_sample/model_creation_sample.py b/samples/python/model_creation_sample/model_creation_sample.py
index 44aa06c11ad..2bfd2f92783 100755
--- a/samples/python/model_creation_sample/model_creation_sample.py
+++ b/samples/python/model_creation_sample/model_creation_sample.py
@@ -4,7 +4,6 @@
# SPDX-License-Identifier: Apache-2.0
import logging as log
import sys
-import typing
from functools import reduce
import numpy as np
@@ -17,7 +16,7 @@ from data import digits
def create_model(model_path: str) -> ov.Model:
"""Create a model on the fly from the source code using openvino."""
- def shape_and_length(shape: list) -> typing.Tuple[list, int]:
+ def shape_and_length(shape: list) -> tuple[list, int]:
length = reduce(lambda x, y: x * y, shape)
return shape, length
diff --git a/src/bindings/python/docs/code_examples.md b/src/bindings/python/docs/code_examples.md
index b09a84662de..7581d5c87d9 100644
--- a/src/bindings/python/docs/code_examples.md
+++ b/src/bindings/python/docs/code_examples.md
@@ -181,7 +181,7 @@ cls.def(py::init([](std::vector<float>& list) {
R"(
MyTensor's constructor.
- :param list: List to create new `MyTensor` from.
+ :param list: list to create new `MyTensor` from.
:type list: list
)");
diff --git a/src/bindings/python/src/openvino/_op_base.py b/src/bindings/python/src/openvino/_op_base.py
index ad49b59c856..d7fda51bff0 100644
--- a/src/bindings/python/src/openvino/_op_base.py
+++ b/src/bindings/python/src/openvino/_op_base.py
@@ -2,14 +2,14 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import Union, Optional, Tuple, List
+from typing import Union, Optional
from openvino._pyopenvino import Op as OpBase
from openvino._pyopenvino import Node, Output
class Op(OpBase):
- def __init__(self, py_obj: "Op", inputs: Optional[Union[List[Union[Node, Output]], Tuple[Union[Node, Output, List[Union[Node, Output]]]]]] = None) -> None:
+ def __init__(self, py_obj: "Op", inputs: Optional[Union[list[Union[Node, Output]], tuple[Union[Node, Output, list[Union[Node, Output]]]]]] = None) -> None:
super().__init__(py_obj)
self._update_type_info()
if isinstance(inputs, tuple):
diff --git a/src/bindings/python/src/openvino/_ov_api.py b/src/bindings/python/src/openvino/_ov_api.py
index 0a2f4396c05..7ab9d2521d2 100644
--- a/src/bindings/python/src/openvino/_ov_api.py
+++ b/src/bindings/python/src/openvino/_ov_api.py
@@ -4,8 +4,8 @@
import io
from types import TracebackType
-from typing import Any, Iterator, Union, Optional, Dict
-from typing import Type as TypingType
+from typing import Any, Union, Optional
+from collections.abc import Iterator
from pathlib import Path
import traceback # noqa: F811
@@ -67,7 +67,7 @@ class Model(object, metaclass=ModelMeta):
def __copy__(self) -> "Model":
raise TypeError("Cannot copy 'openvino.Model'. Please, use deepcopy instead.")
- def __deepcopy__(self, memo: Dict) -> "Model":
+ def __deepcopy__(self, memo: dict) -> "Model":
"""Returns a deepcopy of Model.
:return: A copy of Model.
@@ -78,7 +78,7 @@ class Model(object, metaclass=ModelMeta):
def __enter__(self) -> "Model":
return self
- def __exit__(self, exc_type: TypingType[BaseException], exc_value: BaseException, traceback: TracebackType) -> None: # noqa: F811
+ def __exit__(self, exc_type: type[BaseException], exc_value: BaseException, traceback: TracebackType) -> None: # noqa: F811
del self.__model
self.__model = None
@@ -252,7 +252,7 @@ class InferRequest(_InferRequestWrapper):
"""Gets all outputs tensors of this InferRequest.
:return: Dictionary of results from output tensors with ports as keys.
- :rtype: Dict[openvino.ConstOutput, numpy.array]
+ :rtype: dict[openvino.ConstOutput, numpy.array]
"""
return OVDict(super().results)
@@ -286,8 +286,8 @@ class CompiledModel(CompiledModelBase):
def query_state(self) -> None:
"""Gets state control interface for the underlaying infer request.
- :return: List of VariableState objects.
- :rtype: List[openvino.VariableState]
+ :return: list of VariableState objects.
+ :rtype: list[openvino.VariableState]
"""
if self._infer_request is None:
self._infer_request = self.create_infer_request()
@@ -450,7 +450,7 @@ class AsyncInferQueue(AsyncInferQueueBase):
will put the parent AsyncInferQueue object in an invalid state.
:return: a generator that yields InferRequests.
- :rtype: Iterable[openvino.InferRequest]
+ :rtype: collections.abc.Iterable[openvino.InferRequest]
"""
return (InferRequest(x) for x in super().__iter__())
@@ -540,7 +540,7 @@ class Core(CoreBase):
self,
model: Union[str, bytes, object, io.BytesIO],
weights: Union[object, str, bytes, Tensor, io.BytesIO] = None,
- config: Optional[Dict[str, Any]] = None
+ config: Optional[dict[str, Any]] = None
) -> Model:
config = {} if config is None else config
if isinstance(model, Model):
@@ -559,7 +559,7 @@ class Core(CoreBase):
self,
model: Union[Model, str, Path],
device_name: Optional[str] = None,
- config: Optional[Dict[str, Any]] = None,
+ config: Optional[dict[str, Any]] = None,
*,
weights: Optional[bytes] = None,
) -> CompiledModel:
@@ -613,7 +613,7 @@ class Core(CoreBase):
self,
model: Model,
device_name: str,
- config: Optional[Dict[str, Any]] = None,
+ config: Optional[dict[str, Any]] = None,
) -> dict:
return super().query_model(model._Model__model,
device_name,
@@ -623,7 +623,7 @@ class Core(CoreBase):
self,
model_stream: bytes,
device_name: str,
- config: Optional[Dict[str, Any]] = None,
+ config: Optional[dict[str, Any]] = None,
) -> CompiledModel:
"""Imports a compiled model from a previously exported one.
@@ -676,7 +676,7 @@ class Core(CoreBase):
def compile_model(
model: Union[Model, str, Path],
device_name: Optional[str] = "AUTO",
- config: Optional[Dict[str, Any]] = None,
+ config: Optional[dict[str, Any]] = None,
) -> CompiledModel:
"""Compact method to compile model with AUTO plugin.
diff --git a/src/bindings/python/src/openvino/frontend/jax/jaxpr_decoder.py b/src/bindings/python/src/openvino/frontend/jax/jaxpr_decoder.py
index 3e69207e2f0..ceb1aa3ecc7 100644
--- a/src/bindings/python/src/openvino/frontend/jax/jaxpr_decoder.py
+++ b/src/bindings/python/src/openvino/frontend/jax/jaxpr_decoder.py
@@ -21,7 +21,6 @@ from openvino.frontend.jax.utils import jax_array_to_ov_const, get_ov_type_for_v
import numpy as np
-from typing import List
import logging
logger = logging.getLogger(__name__)
@@ -85,7 +84,7 @@ class JaxprPythonDecoder(Decoder):
# TODO: this implementation may lead to memory increasing. Any better solution?
self.m_decoders = []
- def inputs(self) -> List[int]:
+ def inputs(self) -> list[int]:
if isinstance(self.jaxpr, jex.core.JaxprEqn):
idx = 0
res = []
@@ -176,7 +175,7 @@ class JaxprPythonDecoder(Decoder):
else:
return "root"
- def outputs(self) -> List[int]:
+ def outputs(self) -> list[int]:
return [id(v) for v in self.jaxpr.outvars]
def output(self, idx: int) -> int:
@@ -239,7 +238,7 @@ class _JaxprPythonConstantDecoder(Decoder):
self.constant = constant
self.output_id = id(self.constant) if output_id is None else output_id
- def inputs(self) -> List[int]:
+ def inputs(self) -> list[int]:
return []
def input(self, idx: int) -> int:
@@ -288,7 +287,7 @@ class _JaxprPythonConstantDecoder(Decoder):
def get_op_type(self) -> str:
return "constant"
- def outputs(self) -> List[int]:
+ def outputs(self) -> list[int]:
return [self.output_id]
def output(self, idx: int) -> int:
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/inlined_extension.py b/src/bindings/python/src/openvino/frontend/pytorch/inlined_extension.py
index 0df31ac2629..c452402d73d 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/inlined_extension.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/inlined_extension.py
@@ -2,7 +2,8 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import Any, Callable, Union, Optional
+from typing import Any, Union, Optional
+from collections.abc import Callable
import torch
import numpy as np
import openvino as ov
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/module_extension.py b/src/bindings/python/src/openvino/frontend/pytorch/module_extension.py
index a698d0bdd5a..d7a06b41fb4 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/module_extension.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/module_extension.py
@@ -2,7 +2,8 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import Callable, Optional, Type, Union
+from typing import Optional, Union
+from collections.abc import Callable
import torch
@@ -14,7 +15,7 @@ class ModuleExtension:
"""
def __init__(self,
- module: Union[str, torch.nn.Module, Type[torch.nn.Module]],
+ module: Union[str, torch.nn.Module, type[torch.nn.Module]],
target_op: str,
evaluate: Optional[Callable] = None,
convert: Optional[Callable] = None,
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/patch_functions.py b/src/bindings/python/src/openvino/frontend/pytorch/patch_functions.py
index 527e18e3cd2..b26de303443 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/patch_functions.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/patch_functions.py
@@ -4,14 +4,14 @@
import builtins
import torch
-from typing import Any, Tuple, Optional, Type
+from typing import Any, Optional
originals_map = {
"divmod": builtins.divmod
}
-def patched_divmod(lhs: Any, rhs: Any) -> Tuple[Any, Any]:
+def patched_divmod(lhs: Any, rhs: Any) -> tuple[Any, Any]:
# TorchScript tracing outputs torch.Tensor for `x.shape[-1]` instead of scalar.
# For example, it leads to TypeError issue during tracing of `divmod(x.shape[-1], 5)`
# since builtin `divmod()` expects both scalar inputs.
@@ -38,7 +38,7 @@ class FunctionsPatcher:
setattr(builtins, name, new_fn)
def __exit__(self,
- exc_type: Optional[Type[BaseException]],
+ exc_type: Optional[type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[Any]
) -> None:
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/decompositions.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/decompositions.py
index 8117960252f..c3d5b46dd37 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/decompositions.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/decompositions.py
@@ -121,7 +121,7 @@ def get_inf_decomposition_list():
def get_export_decomposition_list():
- # List of decompositions from torch._decomp.core_aten_decompositions
+ # list of decompositions from torch._decomp.core_aten_decompositions
# removed _backward ops and ops supported without decomposition
decomp = [
torch.ops.aten.addcdiv,
@@ -299,7 +299,7 @@ def get_export_decomposition_list():
def ops_to_not_decompose():
- # List of operations that shouldn't be decomposed
+ # list of operations that shouldn't be decomposed
return [
torch.ops.aten.col2im.default,
torch.ops.aten.linear.default,
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py
index 4f207ed03cb..62121a94f5f 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py
@@ -23,7 +23,7 @@ from openvino.frontend.pytorch.torchdynamo.compile import openvino_compile
from openvino import Core, Type, PartialShape
from openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_aot_autograd
-from typing import Callable, Optional, Any
+from typing import Optional, Any
from torch.fx.experimental.proxy_tensor import make_fx, wrapper_and_args_for_make_fx
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py
index 11576cac8e4..771be2a2155 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py
@@ -4,8 +4,8 @@
# mypy: ignore-errors
-import typing as t
import logging
+from collections.abc import Mapping
from torch.nn import Module
from torch._ops import OpOverload
@@ -283,7 +283,7 @@ class OperatorSupport(OpSupport):
def enable_by_name(self, node: Node):
self.enabled_op_names.append(node.name)
- def is_node_supported(self, submodules: t.Mapping[str, Module], node: Node) -> bool:
+ def is_node_supported(self, submodules: Mapping[str, Module], node: Node) -> bool:
# OpenVINO FX subgraph should be purely functional
if node.op not in CALLABLE_NODE_OPS:
return False
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py
index b848f53a4f8..1464a94598d 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py
@@ -4,7 +4,6 @@
# mypy: ignore-errors
-from typing import Dict
import torch
from torch.nn import Module
@@ -39,10 +38,10 @@ class Partitioner:
fx_gm = make_fx(graph_module)(*args)
return fx_gm
- def add_get_attr_inputs(self, partitions: t.List[Partition]):
+ def add_get_attr_inputs(self, partitions: list[Partition]):
# TODO: Find a more efficient way to include input
# "get_attr" nodes to the partitions.
- getattr_to_merge: Dict[Node, Node] = {}
+ getattr_to_merge: dict[Node, Node] = {}
for partition in partitions:
for pnode in partition.nodes:
for pnode_input in pnode.all_input_nodes:
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py
index 8a0c0bfb79c..fb615da9243 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py
@@ -220,7 +220,7 @@ class TorchScriptPythonDecoder(Decoder):
raw_input = self._raw_input(index)
return self.get_shape_for_value(raw_input)
- def get_input_strides(self, index: int) -> typing.List[int]:
+ def get_input_strides(self, index: int) -> list[int]:
raw_input = self._raw_input(index)
if isinstance(raw_input, torch.Value):
inp_type = raw_input.type()
@@ -581,7 +581,7 @@ class TorchScriptPythonDecoder(Decoder):
@staticmethod
def _transform_tensor_list_constants_to_listconstruct(graph: torch.Graph):
- # Function replaces prim::Constant containing List of Tensors with
+ # Function replaces prim::Constant containing list of Tensors with
# prim::ListConstruct containing prim::Constant Tensors.
assert isinstance(
graph, torch.Graph), "Function can be called only with parameters of type torch.Graph."
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/utils.py b/src/bindings/python/src/openvino/frontend/pytorch/utils.py
index f6d9566c49f..a126db3e8c5 100644
--- a/src/bindings/python/src/openvino/frontend/pytorch/utils.py
+++ b/src/bindings/python/src/openvino/frontend/pytorch/utils.py
@@ -267,7 +267,7 @@ def prepare_example_inputs_and_model(inputs, input_params, model):
inputs, input_params, model)
return examples, ordered, wrapped, input_is_list
if isinstance(inputs, list) and len(inputs) == 1 and isinstance(inputs[0], torch.Tensor):
- if "typing.List" in str(input_params[input_signature[0]].annotation):
+ if "list" in str(input_params[input_signature[0]].annotation):
inputs = inputs[0].unsqueeze(0)
input_is_list = True
@@ -318,7 +318,7 @@ def process_individual_input(arg, arg_name):
arg_name: The name of the input.
Returns:
- Tuple: (signature, param string, example entry, wrap flag).
+ tuple: (signature, param string, example entry, wrap flag).
"""
sign = None
param = None
diff --git a/src/bindings/python/src/openvino/frontend/tensorflow/utils.py b/src/bindings/python/src/openvino/frontend/tensorflow/utils.py
index 18f1250715d..0ee5daa097a 100644
--- a/src/bindings/python/src/openvino/frontend/tensorflow/utils.py
+++ b/src/bindings/python/src/openvino/frontend/tensorflow/utils.py
@@ -10,7 +10,7 @@ import numpy as np
import sys
from openvino import PartialShape, Dimension, Type
from packaging.version import parse, Version
-from typing import List, Dict, Union
+from typing import Union
# TODO: reuse this method in ovc and remove duplication
@@ -292,7 +292,7 @@ def trace_tf_model(model, input_shapes, input_types, example_input):
input_needs_packing = True
- def are_shapes_defined(shape: Union[List, Dict]):
+ def are_shapes_defined(shape: Union[list, dict]):
if shape is None:
return False
assert hasattr(shape, '__len__')
diff --git a/src/bindings/python/src/openvino/opset1/ops.py b/src/bindings/python/src/openvino/opset1/ops.py
index 1b4345c9a34..e89d6871a07 100644
--- a/src/bindings/python/src/openvino/opset1/ops.py
+++ b/src/bindings/python/src/openvino/opset1/ops.py
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for all openvino ops."""
-from typing import List, Optional, Union, get_args
+from typing import Optional, Union, get_args
import numpy as np
from functools import partial
@@ -108,7 +108,7 @@ def atan(node: NodeInput, name: Optional[str] = None) -> Node:
@nameable_op
def avg_pool(
data_batch: NodeInput,
- strides: List[int],
+ strides: list[int],
pads_begin: TensorShape,
pads_end: TensorShape,
kernel_shape: TensorShape,
@@ -180,10 +180,10 @@ def batch_norm_inference(
def binary_convolution(
data: NodeInput,
filters: NodeInput,
- strides: List[int],
- pads_begin: List[int],
- pads_end: List[int],
- dilations: List[int],
+ strides: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
+ dilations: list[int],
mode: str,
pad_value: float,
auto_pad: str = "EXPLICIT",
@@ -320,7 +320,7 @@ def clamp(
@nameable_op
-def concat(nodes: List[NodeInput], axis: int, name: Optional[str] = None) -> Node:
+def concat(nodes: list[NodeInput], axis: int, name: Optional[str] = None) -> Node:
"""Concatenate input nodes into single new node along specified axis.
:param nodes: The nodes we want concatenate into single new node.
@@ -390,10 +390,10 @@ def convert_like(data: NodeInput, like: NodeInput, name: Optional[str] = None) -
def convolution(
data: NodeInput,
filters: NodeInput,
- strides: List[int],
- pads_begin: List[int],
- pads_end: List[int],
- dilations: List[int],
+ strides: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
+ dilations: list[int],
auto_pad: str = "EXPLICIT",
name: Optional[str] = None,
) -> Node:
@@ -426,13 +426,13 @@ def convolution(
def convolution_backprop_data(
data: NodeInput,
filters: NodeInput,
- strides: List[int],
+ strides: list[int],
output_shape: Optional[NodeInput] = None,
- pads_begin: Optional[List[int]] = None,
- pads_end: Optional[List[int]] = None,
- dilations: Optional[List[int]] = None,
+ pads_begin: Optional[list[int]] = None,
+ pads_end: Optional[list[int]] = None,
+ dilations: Optional[list[int]] = None,
auto_pad: Optional[str] = None,
- output_padding: Optional[List[int]] = None,
+ output_padding: Optional[list[int]] = None,
name: Optional[str] = None,
) -> Node:
"""Create node performing a batched-convolution backprop data operation.
@@ -506,10 +506,10 @@ def deformable_convolution(
data: NodeInput,
deformable_values: NodeInput,
filters: NodeInput,
- strides: List[int],
- pads_begin: List[int],
- pads_end: List[int],
- dilations: List[int],
+ strides: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
+ dilations: list[int],
auto_pad: str = "EXPLICIT",
group: int = 1,
deformable_group: int = 1,
@@ -1082,10 +1082,10 @@ def grn(data: Node, bias: float, name: Optional[str] = None) -> Node:
def group_convolution(
data: NodeInput,
filters: NodeInput,
- strides: List[int],
- pads_begin: List[int],
- pads_end: List[int],
- dilations: List[int],
+ strides: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
+ dilations: list[int],
auto_pad: str = "EXPLICIT",
name: Optional[str] = None,
) -> Node:
@@ -1129,13 +1129,13 @@ def group_convolution(
def group_convolution_backprop_data(
data: NodeInput,
filters: NodeInput,
- strides: List[int],
+ strides: list[int],
output_shape: Optional[NodeInput] = None,
- pads_begin: Optional[List[int]] = None,
- pads_end: Optional[List[int]] = None,
- dilations: Optional[List[int]] = None,
+ pads_begin: Optional[list[int]] = None,
+ pads_end: Optional[list[int]] = None,
+ dilations: Optional[list[int]] = None,
auto_pad: str = "EXPLICIT",
- output_padding: Optional[List[int]] = None,
+ output_padding: Optional[list[int]] = None,
name: Optional[str] = None,
) -> Node:
"""Perform Group Convolution operation on data from input node.
@@ -1235,7 +1235,7 @@ def interpolate(
Available attributes are:
* axes Specify spatial dimension indices where interpolation is applied.
- Type: List of non-negative integer numbers.
+ Type: list of non-negative integer numbers.
Required: yes.
* mode Specifies type of interpolation.
@@ -1469,9 +1469,9 @@ def lstm_cell(
R: NodeInput,
B: NodeInput,
hidden_size: int,
- activations: Optional[List[str]] = None,
- activations_alpha: Optional[List[float]] = None,
- activations_beta: Optional[List[float]] = None,
+ activations: Optional[list[str]] = None,
+ activations_alpha: Optional[list[float]] = None,
+ activations_beta: Optional[list[float]] = None,
clip: float = 0.0,
name: Optional[str] = None,
) -> Node:
@@ -1558,9 +1558,9 @@ def matmul(
@nameable_op
def max_pool(
data: NodeInput,
- strides: List[int],
- pads_begin: List[int],
- pads_end: List[int],
+ strides: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
kernel_shape: TensorShape,
rounding_type: str = "floor",
auto_pad: Optional[str] = None,
@@ -2486,10 +2486,10 @@ def region_yolo(
classes: int,
num: int,
do_softmax: bool,
- mask: List[int],
+ mask: list[int],
axis: int,
end_axis: int,
- anchors: Optional[List[float]] = None,
+ anchors: Optional[list[float]] = None,
name: Optional[str] = None,
) -> Node:
"""Return a node which produces the RegionYolo operation.
@@ -2780,7 +2780,7 @@ def squeeze(data: NodeInput, axes: NodeInput, name: Optional[str] = None) -> Nod
"""Perform squeeze operation on input tensor.
:param data: The node with data tensor.
- :param axes: List of non-negative integers, indicate the dimensions to squeeze.
+ :param axes: list of non-negative integers, indicate the dimensions to squeeze.
One of: input node or array.
:param name: Optional new name for output node.
:return: The new node performing a squeeze operation on input tensor.
@@ -2806,11 +2806,11 @@ def strided_slice(
begin: NodeInput,
end: NodeInput,
strides: NodeInput,
- begin_mask: List[int],
- end_mask: List[int],
- new_axis_mask: Optional[List[int]] = None,
- shrink_axis_mask: Optional[List[int]] = None,
- ellipsis_mask: Optional[List[int]] = None,
+ begin_mask: list[int],
+ end_mask: list[int],
+ new_axis_mask: Optional[list[int]] = None,
+ shrink_axis_mask: Optional[list[int]] = None,
+ ellipsis_mask: Optional[list[int]] = None,
name: Optional[str] = None,
) -> Node:
"""Return a node which dynamically repeats(replicates) the input data tensor.
@@ -2952,7 +2952,7 @@ def unsqueeze(data: NodeInput, axes: NodeInput, name: Optional[str] = None) -> N
Result: tensor with shape [1, 3, 4, 5, 1]
:param data: The node with data tensor.
- :param axes: List of non-negative integers, indicate the dimensions to be inserted.
+ :param axes: list of non-negative integers, indicate the dimensions to be inserted.
One of: input node or array.
:return: The new node performing an unsqueeze operation on input tensor.
"""
diff --git a/src/bindings/python/src/openvino/opset10/ops.py b/src/bindings/python/src/openvino/opset10/ops.py
index 6ac00b2ddc3..2dfc11222e7 100644
--- a/src/bindings/python/src/openvino/opset10/ops.py
+++ b/src/bindings/python/src/openvino/opset10/ops.py
@@ -4,7 +4,7 @@
"""Factory functions for all openvino ops."""
from functools import partial
-from typing import List, Optional
+from typing import Optional
from openvino import Node
from openvino.utils.node_factory import _get_node_factory
@@ -29,8 +29,8 @@ def interpolate(
scales: NodeInput,
mode: str,
shape_calculation_mode: str,
- pads_begin: Optional[List[int]] = None,
- pads_end: Optional[List[int]] = None,
+ pads_begin: Optional[list[int]] = None,
+ pads_end: Optional[list[int]] = None,
coordinate_transformation_mode: str = "half_pixel",
nearest_mode: str = "round_prefer_floor",
antialias: bool = False,
diff --git a/src/bindings/python/src/openvino/opset11/ops.py b/src/bindings/python/src/openvino/opset11/ops.py
index 75da0713789..e8038200559 100644
--- a/src/bindings/python/src/openvino/opset11/ops.py
+++ b/src/bindings/python/src/openvino/opset11/ops.py
@@ -4,7 +4,7 @@
"""Factory functions for all openvino ops."""
from functools import partial
-from typing import List, Optional
+from typing import Optional
from openvino import Node
from openvino.utils.node_factory import _get_node_factory
@@ -25,8 +25,8 @@ def interpolate(
scales_or_sizes: NodeInput,
mode: str,
shape_calculation_mode: str,
- pads_begin: Optional[List[int]] = None,
- pads_end: Optional[List[int]] = None,
+ pads_begin: Optional[list[int]] = None,
+ pads_end: Optional[list[int]] = None,
coordinate_transformation_mode: str = "half_pixel",
nearest_mode: str = "round_prefer_floor",
antialias: bool = False,
diff --git a/src/bindings/python/src/openvino/opset14/ops.py b/src/bindings/python/src/openvino/opset14/ops.py
index d5844fa07a5..a2f3d5cec8b 100644
--- a/src/bindings/python/src/openvino/opset14/ops.py
+++ b/src/bindings/python/src/openvino/opset14/ops.py
@@ -5,7 +5,7 @@
"""Factory functions for ops added to openvino opset14."""
from functools import partial
-from typing import Union, Optional, List
+from typing import Union, Optional
from openvino import Node, Type
from openvino.utils.node_factory import _get_node_factory
@@ -74,10 +74,10 @@ def inverse(
@nameable_op
def max_pool(
data: NodeInput,
- strides: List[int],
- dilations: List[int],
- pads_begin: List[int],
- pads_end: List[int],
+ strides: list[int],
+ dilations: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
kernel_shape: TensorShape,
rounding_type: str = "floor",
auto_pad: Optional[str] = None,
@@ -129,7 +129,7 @@ def max_pool(
@nameable_op
def avg_pool(
data_batch: NodeInput,
- strides: List[int],
+ strides: list[int],
pads_begin: TensorShape,
pads_end: TensorShape,
kernel_shape: TensorShape,
diff --git a/src/bindings/python/src/openvino/opset15/ops.py b/src/bindings/python/src/openvino/opset15/ops.py
index 69916cab8a7..d6cc8b2d251 100644
--- a/src/bindings/python/src/openvino/opset15/ops.py
+++ b/src/bindings/python/src/openvino/opset15/ops.py
@@ -4,7 +4,7 @@
"""Factory functions for ops added to openvino opset15."""
from functools import partial
-from typing import List, Literal, Optional
+from typing import Literal, Optional
import numpy as np
from openvino import Node, Type
@@ -49,10 +49,10 @@ def col2im(
data: NodeInput,
output_size: NodeInput,
kernel_size: NodeInput,
- strides: Optional[List[int]] = None,
- dilations: Optional[List[int]] = None,
- pads_begin: Optional[List[int]] = None,
- pads_end: Optional[List[int]] = None,
+ strides: Optional[list[int]] = None,
+ dilations: Optional[list[int]] = None,
+ pads_begin: Optional[list[int]] = None,
+ pads_end: Optional[list[int]] = None,
name: Optional[str] = None,
) -> Node:
"""Perform data movement operation which combines sliding blocks into an image tensor.
diff --git a/src/bindings/python/src/openvino/opset2/ops.py b/src/bindings/python/src/openvino/opset2/ops.py
index ec9418e020e..5337b2e7d76 100644
--- a/src/bindings/python/src/openvino/opset2/ops.py
+++ b/src/bindings/python/src/openvino/opset2/ops.py
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for all openvino ops."""
-from typing import Callable, Iterable, List, Optional, Set, Union
+from typing import Optional, Union
import numpy as np
from functools import partial
@@ -114,7 +114,7 @@ def mvn(
@nameable_op
-def reorg_yolo(input: Node, stride: List[int], name: Optional[str] = None) -> Node:
+def reorg_yolo(input: Node, stride: list[int], name: Optional[str] = None) -> Node:
"""Return a node which produces the ReorgYolo operation.
:param input: Input data.
diff --git a/src/bindings/python/src/openvino/opset3/ops.py b/src/bindings/python/src/openvino/opset3/ops.py
index fd4e5ca7619..f15acd6d9a1 100644
--- a/src/bindings/python/src/openvino/opset3/ops.py
+++ b/src/bindings/python/src/openvino/opset3/ops.py
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for all openvino ops."""
-from typing import Callable, Iterable, List, Optional, Set, Union
+from typing import Optional, Union
import numpy as np
from functools import partial
@@ -226,7 +226,7 @@ def embedding_segments_sum(
def extract_image_patches(
image: NodeInput,
sizes: TensorShape,
- strides: List[int],
+ strides: list[int],
rates: TensorShape,
auto_pad: str,
name: Optional[str] = None,
@@ -256,9 +256,9 @@ def gru_cell(
R: NodeInput,
B: NodeInput,
hidden_size: int,
- activations: Optional[List[str]] = None,
- activations_alpha: Optional[List[float]] = None,
- activations_beta: Optional[List[float]] = None,
+ activations: Optional[list[str]] = None,
+ activations_alpha: Optional[list[float]] = None,
+ activations_beta: Optional[list[float]] = None,
clip: float = 0.0,
linear_before_reset: bool = False,
name: Optional[str] = None,
@@ -396,9 +396,9 @@ def rnn_cell(
R: NodeInput,
B: NodeInput,
hidden_size: int,
- activations: List[str],
- activations_alpha: List[float],
- activations_beta: List[float],
+ activations: list[str],
+ activations_alpha: list[float],
+ activations_beta: list[float],
clip: float = 0.0,
name: Optional[str] = None,
) -> Node:
diff --git a/src/bindings/python/src/openvino/opset4/ops.py b/src/bindings/python/src/openvino/opset4/ops.py
index fb68cc01122..b30e49b9d0d 100644
--- a/src/bindings/python/src/openvino/opset4/ops.py
+++ b/src/bindings/python/src/openvino/opset4/ops.py
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for all openvino ops."""
-from typing import Callable, Iterable, List, Optional, Set, Union
+from typing import Optional, Union
import numpy as np
from functools import partial
@@ -375,9 +375,9 @@ def lstm_cell(
R: NodeInput,
B: NodeInput,
hidden_size: int,
- activations: Optional[List[str]] = None,
- activations_alpha: Optional[List[float]] = None,
- activations_beta: Optional[List[float]] = None,
+ activations: Optional[list[str]] = None,
+ activations_alpha: Optional[list[float]] = None,
+ activations_beta: Optional[list[float]] = None,
clip: float = 0.0,
name: Optional[str] = None,
) -> Node:
diff --git a/src/bindings/python/src/openvino/opset5/ops.py b/src/bindings/python/src/openvino/opset5/ops.py
index f4645b78d65..cba6100e07a 100644
--- a/src/bindings/python/src/openvino/opset5/ops.py
+++ b/src/bindings/python/src/openvino/opset5/ops.py
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
"""Factory functions for all openvino ops."""
-from typing import Callable, Iterable, List, Optional, Set, Union
+from typing import Optional, Union
import numpy as np
from functools import partial
@@ -185,9 +185,9 @@ def lstm_sequence(
B: NodeInput,
hidden_size: int,
direction: str,
- activations: Optional[List[str]] = None,
- activations_alpha: Optional[List[float]] = None,
- activations_beta: Optional[List[float]] = None,
+ activations: Optional[list[str]] = None,
+ activations_alpha: Optional[list[float]] = None,
+ activations_beta: Optional[list[float]] = None,
clip: float = 0.0,
name: Optional[str] = None,
) -> Node:
@@ -257,9 +257,9 @@ def gru_sequence(
B: NodeInput,
hidden_size: int,
direction: str,
- activations: Optional[List[str]] = None,
- activations_alpha: Optional[List[float]] = None,
- activations_beta: Optional[List[float]] = None,
+ activations: Optional[list[str]] = None,
+ activations_alpha: Optional[list[float]] = None,
+ activations_beta: Optional[list[float]] = None,
clip: float = 0.0,
linear_before_reset: bool = False,
name: Optional[str] = None,
@@ -321,9 +321,9 @@ def rnn_sequence(
B: NodeInput,
hidden_size: int,
direction: str,
- activations: Optional[List[str]] = None,
- activations_alpha: Optional[List[float]] = None,
- activations_beta: Optional[List[float]] = None,
+ activations: Optional[list[str]] = None,
+ activations_alpha: Optional[list[float]] = None,
+ activations_beta: Optional[list[float]] = None,
clip: float = 0.0,
name: Optional[str] = None,
) -> Node:
diff --git a/src/bindings/python/src/openvino/opset7/ops.py b/src/bindings/python/src/openvino/opset7/ops.py
index 6cfac6a6763..e836297e0c0 100644
--- a/src/bindings/python/src/openvino/opset7/ops.py
+++ b/src/bindings/python/src/openvino/opset7/ops.py
@@ -4,7 +4,7 @@
"""Factory functions for all openvino ops."""
from functools import partial
-from typing import Callable, Iterable, List, Optional, Set, Union
+from typing import Optional, Union
import numpy as np
from openvino import Node, Shape
@@ -39,7 +39,7 @@ _get_node_factory_opset7 = partial(_get_node_factory, "opset7")
@nameable_op
def einsum(
- inputs: List[Node],
+ inputs: list[Node],
equation: str,
name: Optional[str] = None,
) -> Node:
diff --git a/src/bindings/python/src/openvino/opset8/ops.py b/src/bindings/python/src/openvino/opset8/ops.py
index 08110a23c07..133f3efd1e1 100644
--- a/src/bindings/python/src/openvino/opset8/ops.py
+++ b/src/bindings/python/src/openvino/opset8/ops.py
@@ -4,7 +4,7 @@
"""Factory functions for all openvino ops."""
from functools import partial
-from typing import List, Optional, Tuple
+from typing import Optional
import numpy as np
from openvino.exceptions import UserInputError
@@ -35,10 +35,10 @@ def deformable_convolution(
data: NodeInput,
offsets: NodeInput,
filters: NodeInput,
- strides: List[int],
- pads_begin: List[int],
- pads_end: List[int],
- dilations: List[int],
+ strides: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
+ dilations: list[int],
mask: Optional[NodeInput] = None,
auto_pad: str = "EXPLICIT",
group: int = 1,
@@ -276,10 +276,10 @@ def gather(
@nameable_op
def max_pool(
data: NodeInput,
- strides: List[int],
- dilations: List[int],
- pads_begin: List[int],
- pads_end: List[int],
+ strides: list[int],
+ dilations: list[int],
+ pads_begin: list[int],
+ pads_end: list[int],
kernel_shape: TensorShape,
rounding_type: str = "floor",
auto_pad: Optional[str] = None,
diff --git a/src/bindings/python/src/openvino/package_utils.py b/src/bindings/python/src/openvino/package_utils.py
index fabb0cec2a6..30bfe79dc10 100644
--- a/src/bindings/python/src/openvino/package_utils.py
+++ b/src/bindings/python/src/openvino/package_utils.py
@@ -5,11 +5,16 @@
import os
import sys
from functools import wraps
-from typing import Callable, Any, Optional
+from typing import Any, Optional
from pathlib import Path
import importlib.util
from types import ModuleType
+if sys.version_info >= (3, 9):
+ from collections.abc import Callable
+else:
+ from typing import Callable
+
def _add_openvino_libs_to_search_path() -> None:
"""Add OpenVINO libraries to the DLL search path on Windows."""
diff --git a/src/bindings/python/src/openvino/preprocess/torchvision/preprocess_converter.py b/src/bindings/python/src/openvino/preprocess/torchvision/preprocess_converter.py
index 0273c9d552f..4f66f3a75a6 100644
--- a/src/bindings/python/src/openvino/preprocess/torchvision/preprocess_converter.py
+++ b/src/bindings/python/src/openvino/preprocess/torchvision/preprocess_converter.py
@@ -2,7 +2,8 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import Callable, Any, Union
+from typing import Any, Union
+from collections.abc import Callable
import logging
from openvino import Model
diff --git a/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.py b/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.py
index f56dec47a75..f452a817420 100644
--- a/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.py
+++ b/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.py
@@ -8,12 +8,10 @@ import numbers
import logging
import copy
import numpy as np
-from typing import List, Dict
from abc import ABCMeta, abstractmethod
from functools import singledispatch
-from typing import Callable, Any, Union, Tuple
-from typing import Sequence as SequenceType
-from collections.abc import Sequence
+from typing import Any, Union
+from collections.abc import Callable, Sequence
from PIL import Image
import torch
@@ -48,17 +46,17 @@ TORCHTYPE_TO_OVTYPE = {
@singledispatch
-def _setup_size(size: Any, error_msg: str) -> SequenceType[int]:
+def _setup_size(size: Any, error_msg: str) -> Sequence[int]:
raise ValueError(error_msg)
@_setup_size.register
-def _setup_size_number(size: numbers.Number, error_msg: str) -> SequenceType[int]:
+def _setup_size_number(size: numbers.Number, error_msg: str) -> Sequence[int]:
return int(size), int(size) # type: ignore
@_setup_size.register
-def _setup_size_sequence(size: Sequence, error_msg: str) -> SequenceType[int]:
+def _setup_size_sequence(size: Sequence, error_msg: str) -> Sequence[int]:
if len(size) == 1:
return size[0], size[0]
elif len(size) == 2:
@@ -66,7 +64,7 @@ def _setup_size_sequence(size: Sequence, error_msg: str) -> SequenceType[int]:
raise ValueError(error_msg)
-def _NHWC_to_NCHW(input_shape: List) -> List: # noqa N802
+def _NHWC_to_NCHW(input_shape: list) -> list: # noqa N802
new_shape = copy.deepcopy(input_shape)
new_shape[1] = input_shape[3]
new_shape[2] = input_shape[1]
@@ -75,21 +73,21 @@ def _NHWC_to_NCHW(input_shape: List) -> List: # noqa N802
@singledispatch
-def _to_list(transform: Callable) -> List:
+def _to_list(transform: Callable) -> list:
raise TypeError(f"Unsupported transform type: {type(transform)}")
@_to_list.register
-def _to_list_torch_sequential(transform: torch.nn.Sequential) -> List:
+def _to_list_torch_sequential(transform: torch.nn.Sequential) -> list:
return list(transform)
@_to_list.register
-def _to_list_transforms_compose(transform: transforms.Compose) -> List:
+def _to_list_transforms_compose(transform: transforms.Compose) -> list:
return transform.transforms
-def _get_shape_layout_from_data(input_example: Union[torch.Tensor, np.ndarray, Image.Image]) -> Tuple[List, Layout]:
+def _get_shape_layout_from_data(input_example: Union[torch.Tensor, np.ndarray, Image.Image]) -> tuple[list, Layout]:
if isinstance(input_example, (torch.Tensor, np.ndarray, Image.Image)): # PyTorch, OpenCV, numpy, PILLOW
shape = list(np.array(input_example, copy=False).shape)
layout = Layout("NCHW") if isinstance(input_example, torch.Tensor) else Layout("NHWC")
@@ -110,13 +108,13 @@ class TransformConverterBase(metaclass=ABCMeta):
pass
@abstractmethod
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
pass
class TransformConverterFactory:
- registry: Dict[str, Callable] = {}
+ registry: dict[str, Callable] = {}
@classmethod
def register(cls: Callable, target_type: Union[Callable, None] = None) -> Callable:
@@ -141,7 +139,7 @@ class TransformConverterFactory:
@TransformConverterFactory.register(transforms.Normalize)
class _(TransformConverterBase):
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
if transform.inplace:
raise ValueError("Inplace Normaliziation is not supported.")
ppp.input(input_idx).preprocess().mean(transform.mean).scale(transform.std)
@@ -149,13 +147,13 @@ class _(TransformConverterBase):
@TransformConverterFactory.register(transforms.ConvertImageDtype)
class _(TransformConverterBase):
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
ppp.input(input_idx).preprocess().convert_element_type(TORCHTYPE_TO_OVTYPE[transform.dtype])
@TransformConverterFactory.register(transforms.Grayscale)
class _(TransformConverterBase):
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
input_shape = meta["input_shape"]
layout = meta["layout"]
@@ -178,7 +176,7 @@ class _(TransformConverterBase):
@TransformConverterFactory.register(transforms.Pad)
class _(TransformConverterBase):
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
image_dimensions = list(meta["image_dimensions"])
layout = meta["layout"]
torch_padding = transform.padding
@@ -237,7 +235,7 @@ class _(TransformConverterBase):
@TransformConverterFactory.register(transforms.ToTensor)
class _(TransformConverterBase):
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
input_shape = meta["input_shape"]
layout = meta["layout"]
@@ -256,7 +254,7 @@ class _(TransformConverterBase):
@TransformConverterFactory.register(transforms.CenterCrop)
class _(TransformConverterBase):
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
input_shape = meta["input_shape"]
source_size = meta["image_dimensions"]
target_size = _setup_size(transform.size, "Incorrect size type for CenterCrop operation")
@@ -281,7 +279,7 @@ class _(TransformConverterBase):
@TransformConverterFactory.register(transforms.Resize)
class _(TransformConverterBase):
- def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: Dict) -> None:
+ def convert(self, input_idx: int, ppp: PrePostProcessor, transform: Callable, meta: dict) -> None:
resize_mode_map = {
InterpolationMode.NEAREST: ResizeAlgorithm.RESIZE_NEAREST,
InterpolationMode.BILINEAR: ResizeAlgorithm.RESIZE_BILINEAR_PILLOW,
diff --git a/src/bindings/python/src/openvino/properties/_properties.py b/src/bindings/python/src/openvino/properties/_properties.py
index b6693efbb0a..e0c31a5111a 100644
--- a/src/bindings/python/src/openvino/properties/_properties.py
+++ b/src/bindings/python/src/openvino/properties/_properties.py
@@ -4,7 +4,8 @@
import sys
from types import BuiltinFunctionType, ModuleType
-from typing import Callable, Any, Union
+from typing import Any, Union
+from collections.abc import Callable
class Property(str):
diff --git a/src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py b/src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py
index cf9bb66b826..fe2610f0a37 100644
--- a/src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py
+++ b/src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
from functools import singledispatch
-from typing import Any, Dict, Union, Optional
+from typing import Any, Union, Optional
import numpy as np
@@ -359,7 +359,7 @@ def update_inputs(inputs: dict, request: _InferRequestWrapper) -> dict:
# Create new temporary dictionary.
# new_inputs will be used to transfer data to inference calls,
# ensuring that original inputs are not overwritten with Tensors.
- new_inputs: Dict[ValidKeys, Tensor] = {}
+ new_inputs: dict[ValidKeys, Tensor] = {}
for key, value in inputs.items():
if not isinstance(key, (str, int, ConstOutput)):
raise TypeError(f"Incompatible key type for input: {key}")
diff --git a/src/bindings/python/src/openvino/utils/data_helpers/wrappers.py b/src/bindings/python/src/openvino/utils/data_helpers/wrappers.py
index 02c6cfa473d..6bac25ed7f0 100644
--- a/src/bindings/python/src/openvino/utils/data_helpers/wrappers.py
+++ b/src/bindings/python/src/openvino/utils/data_helpers/wrappers.py
@@ -5,9 +5,8 @@
import numpy as np
from functools import singledispatchmethod
-from collections.abc import Mapping
-from typing import Dict, Set, Tuple, Union, Iterator, Optional
-from typing import KeysView, ItemsView, ValuesView
+from collections.abc import Iterator, Mapping, KeysView, ItemsView, ValuesView
+from typing import Union, Optional
from openvino._pyopenvino import Tensor, ConstOutput
from openvino._pyopenvino import InferRequest as InferRequestBase
@@ -67,9 +66,9 @@ class OVDict(Mapping):
# or alternatively:
out1, out2, out3, _ = request.infer(inputs).to_tuple()
"""
- def __init__(self, _dict: Dict[ConstOutput, np.ndarray]) -> None:
+ def __init__(self, _dict: dict[ConstOutput, np.ndarray]) -> None:
self._dict = _dict
- self._names: Optional[Dict[ConstOutput, Set[str]]] = None
+ self._names: Optional[dict[ConstOutput, set[str]]] = None
def __iter__(self) -> Iterator:
return self._dict.__iter__()
@@ -80,7 +79,7 @@ class OVDict(Mapping):
def __repr__(self) -> str:
return self._dict.__repr__()
- def __get_names(self) -> Dict[ConstOutput, Set[str]]:
+ def __get_names(self) -> dict[ConstOutput, set[str]]:
"""Return names of every output key.
Insert empty set if key has no name.
@@ -126,7 +125,7 @@ class OVDict(Mapping):
def items(self) -> ItemsView[ConstOutput, np.ndarray]:
return self._dict.items()
- def names(self) -> Tuple[Set[str], ...]:
+ def names(self) -> tuple[set[str], ...]:
"""Return names of every output key.
Insert empty set if key has no name.
@@ -135,7 +134,7 @@ class OVDict(Mapping):
self._names = self.__get_names()
return tuple(self._names.values())
- def to_dict(self) -> Dict[ConstOutput, np.ndarray]:
+ def to_dict(self) -> dict[ConstOutput, np.ndarray]:
"""Return underlaying native dictionary.
Function performs shallow copy, thus any modifications to
diff --git a/src/bindings/python/src/openvino/utils/decorators.py b/src/bindings/python/src/openvino/utils/decorators.py
index 309cfb3d263..ab530f14a91 100644
--- a/src/bindings/python/src/openvino/utils/decorators.py
+++ b/src/bindings/python/src/openvino/utils/decorators.py
@@ -4,7 +4,8 @@
from functools import wraps
from inspect import signature
-from typing import Any, Callable, Dict, Optional, Union, get_origin, get_args
+from typing import Any, Optional, Union, get_origin, get_args
+from collections.abc import Callable
from openvino import Node, Output
from openvino.utils.types import NodeInput, as_node, as_nodes
@@ -73,11 +74,15 @@ def custom_preprocess_function(custom_function: Callable) -> Callable:
class MultiMethod(object):
def __init__(self, name: str):
self.name = name
- self.typemap: Dict[tuple, Callable] = {}
+ self.typemap: dict[tuple, Callable] = {}
# Checks if actual_type is a subclass of any type in the union
def matches_union(self, union_type, actual_type) -> bool: # type: ignore
for type_arg in get_args(union_type):
+ origin = get_origin(type_arg)
+ if origin is not None:
+ type_arg = origin
+
if isinstance(type_arg, type) and issubclass(actual_type, type_arg):
return True
elif get_origin(type_arg) == list:
@@ -142,7 +147,7 @@ class MultiMethod(object):
self.typemap[types] = function
-registry: Dict[str, MultiMethod] = {}
+registry: dict[str, MultiMethod] = {}
def overloading(*types: tuple) -> Callable:
diff --git a/src/bindings/python/src/openvino/utils/input_validation.py b/src/bindings/python/src/openvino/utils/input_validation.py
index d85e5d35362..804cea9e5c4 100644
--- a/src/bindings/python/src/openvino/utils/input_validation.py
+++ b/src/bindings/python/src/openvino/utils/input_validation.py
@@ -5,7 +5,8 @@
"""Helper functions for validating user input."""
import logging
-from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type
+from typing import Any, Optional
+from collections.abc import Callable, Iterable
import numpy as np
@@ -26,7 +27,7 @@ def assert_list_of_ints(value_list: Iterable[int], message: str) -> None:
def _check_value(op_name, attr_key, value, val_type, cond=None):
- # type: (str, str, Any, Type, Optional[Callable[[Any], bool]]) -> bool
+ # type: (str, str, Any, type, Optional[Callable[[Any], bool]]) -> bool
"""Check whether provided value satisfies specified criteria.
:param op_name: The operator name which attributes are checked.
@@ -51,7 +52,7 @@ def _check_value(op_name, attr_key, value, val_type, cond=None):
def check_valid_attribute(op_name, attr_dict, attr_key, val_type, cond=None, required=False):
- # type: (str, dict, str, Type, Optional[Callable[[Any], bool]], Optional[bool]) -> bool
+ # type: (str, dict, str, type, Optional[Callable[[Any], bool]], Optional[bool]) -> bool
"""Check whether specified attribute satisfies given criteria.
:param op_name: The operator name which attributes are checked.
@@ -89,8 +90,8 @@ def check_valid_attribute(op_name, attr_dict, attr_key, val_type, cond=None, req
def check_valid_attributes(
op_name, # type: str
- attributes, # type: Dict[str, Any]
- requirements, # type: List[Tuple[str, bool, Type, Optional[Callable]]]
+ attributes, # type: dict[str, Any]
+ requirements, # type: list[tuple[str, bool, type, Optional[Callable]]]
):
# type: (...) -> bool
"""Perform attributes validation according to specified type, value criteria.
@@ -101,7 +102,7 @@ def check_valid_attributes(
contain following values:
(attr_name: str,
is_required: bool,
- value_type: Type,
+ value_type: type,
value_condition: Callable)
:raises UserInputError:
diff --git a/src/bindings/python/src/openvino/utils/node_factory.py b/src/bindings/python/src/openvino/utils/node_factory.py
index f01dc783b18..ee869e3b60c 100644
--- a/src/bindings/python/src/openvino/utils/node_factory.py
+++ b/src/bindings/python/src/openvino/utils/node_factory.py
@@ -4,7 +4,7 @@
from functools import singledispatchmethod
-from typing import Any, Dict, List, Optional, Union
+from typing import Any, Optional, Union
from pathlib import Path
from openvino._pyopenvino import NodeFactory as _NodeFactory
@@ -29,8 +29,8 @@ class NodeFactory(object):
def create(
self,
op_type_name: str,
- arguments: Optional[List[Union[Node, Output]]] = None,
- attributes: Optional[Dict[str, Any]] = None,
+ arguments: Optional[list[Union[Node, Output]]] = None,
+ attributes: Optional[dict[str, Any]] = None,
) -> Node:
"""Create node object from provided description.
@@ -60,7 +60,7 @@ class NodeFactory(object):
return node
@singledispatchmethod
- def add_extension(self, extension: Union[Path, str, Extension, List[Extension]]) -> None:
+ def add_extension(self, extension: Union[Path, str, Extension, list[Extension]]) -> None:
raise TypeError(f"Unknown argument type: {type(extension)}")
@add_extension.register(Path)
@@ -91,7 +91,7 @@ class NodeFactory(object):
@add_extension.register(Extension)
@add_extension.register(list)
- def _(self, extension: Union[Extension, List[Extension]]) -> None:
+ def _(self, extension: Union[Extension, list[Extension]]) -> None:
"""Add custom operations from extension library.
Extends operation types available for creation by operations
@@ -116,7 +116,7 @@ class NodeFactory(object):
self.factory.add_extension(extension)
@staticmethod
- def _arguments_as_outputs(arguments: List[Union[Node, Output]]) -> List[Output]:
+ def _arguments_as_outputs(arguments: list[Union[Node, Output]]) -> list[Output]:
outputs = []
for argument in arguments:
if issubclass(type(argument), Output):
diff --git a/src/bindings/python/src/openvino/utils/postponed_constant.py b/src/bindings/python/src/openvino/utils/postponed_constant.py
index 3c0dc280286..d1041d5fc8c 100644
--- a/src/bindings/python/src/openvino/utils/postponed_constant.py
+++ b/src/bindings/python/src/openvino/utils/postponed_constant.py
@@ -3,7 +3,8 @@
# SPDX-License-Identifier: Apache-2.0
-from typing import Callable, List, Optional
+from typing import Optional
+from collections.abc import Callable
from openvino import Op, Type, Shape, Tensor, PartialShape
@@ -19,14 +20,14 @@ class PostponedConstant(Op):
self.friendly_name = name
self.constructor_validate_and_infer_types()
- def evaluate(self, outputs: List[Tensor], _: List[Tensor]) -> bool: # type: ignore
+ def evaluate(self, outputs: list[Tensor], _: list[Tensor]) -> bool: # type: ignore
self.m_maker(outputs[0])
return True
def validate_and_infer_types(self) -> None:
self.set_output_type(0, self.m_element_type, PartialShape(self.m_shape))
- def clone_with_new_inputs(self, new_inputs: List[Tensor]) -> Op:
+ def clone_with_new_inputs(self, new_inputs: list[Tensor]) -> Op:
return PostponedConstant(self.m_element_type, self.m_shape, self.m_maker, self.friendly_name)
def has_evaluate(self) -> bool:
diff --git a/src/bindings/python/src/openvino/utils/reduction.py b/src/bindings/python/src/openvino/utils/reduction.py
index 62fd8167d7a..459003bdec4 100644
--- a/src/bindings/python/src/openvino/utils/reduction.py
+++ b/src/bindings/python/src/openvino/utils/reduction.py
@@ -2,7 +2,8 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import Iterable, Optional
+from typing import Optional
+from collections.abc import Iterable
from openvino import Node
@@ -15,7 +16,7 @@ def get_reduction_axes(node: Node, reduction_axes: Optional[Iterable[int]]) -> I
:param node: The node we fill reduction axes for.
:param reduction_axes: The collection of indices of axes to reduce. May be None.
- returns: Set filled with indices of axes we want to reduce.
+ returns: set filled with indices of axes we want to reduce.
"""
if reduction_axes is None:
reduction_axes = set(range(len(node.shape)))
diff --git a/src/bindings/python/src/openvino/utils/types.py b/src/bindings/python/src/openvino/utils/types.py
index 3db86f1ab8a..f184ef4c555 100644
--- a/src/bindings/python/src/openvino/utils/types.py
+++ b/src/bindings/python/src/openvino/utils/types.py
@@ -5,7 +5,7 @@
"""Functions related to converting between Python and numpy types and openvino types."""
import logging
-from typing import List, Union, Optional
+from typing import Union, Optional
import numpy as np
@@ -15,7 +15,7 @@ from openvino.op import Constant
log = logging.getLogger(__name__)
-TensorShape = List[int]
+TensorShape = list[int]
NumericData = Union[int, float, np.ndarray]
NumericType = Union[type, np.dtype]
ScalarData = Union[int, float]
@@ -170,6 +170,6 @@ def as_node(input_value: NodeInput, name: Optional[str] = None) -> Union[Node, O
return make_constant_node(input_value, name=name)
-def as_nodes(*input_values: NodeInput, name: Optional[str] = None) -> List[Node]:
+def as_nodes(*input_values: NodeInput, name: Optional[str] = None) -> list[Node]:
"""Return input values as nodes. Scalars will be converted to Constant nodes."""
return [as_node(input_value, name=name) for input_value in input_values]
diff --git a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp
index 2894e07f1d5..eea9a00ab77 100644
--- a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp
+++ b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp
@@ -357,8 +357,8 @@ void regclass_AsyncInferQueue(py::module m) {
return self.m_user_ids;
},
R"(
- :return: List of all passed userdata. List is filled with `None` if the data wasn't passed yet.
- :rtype: List[Any]
+ :return: list of all passed userdata. list is filled with `None` if the data wasn't passed yet.
+ :rtype: list[Any]
)");
cls.def("__repr__", [](const AsyncInferQueue& self) {
diff --git a/src/bindings/python/src/pyopenvino/core/compiled_model.cpp b/src/bindings/python/src/pyopenvino/core/compiled_model.cpp
index 9dd4073f3b6..63baa42b306 100644
--- a/src/bindings/python/src/pyopenvino/core/compiled_model.cpp
+++ b/src/bindings/python/src/pyopenvino/core/compiled_model.cpp
@@ -135,7 +135,7 @@ void regclass_CompiledModel(py::module m) {
R"(
Sets properties for current compiled model.
- :param properties: Dict of pairs: (property name, property value)
+ :param properties: dict of pairs: (property name, property value)
:type properties: dict
:rtype: None
)");
@@ -151,7 +151,7 @@ void regclass_CompiledModel(py::module m) {
R"(
Sets properties for current compiled model.
- :param property: Tuple of (property name, matching property value).
+ :param property: tuple of (property name, matching property value).
:type property: tuple
)");
@@ -200,7 +200,7 @@ void regclass_CompiledModel(py::module m) {
Gets all inputs of a compiled model.
:return: Inputs of a compiled model.
- :rtype: List[openvino.ConstOutput]
+ :rtype: list[openvino.ConstOutput]
)");
cls.def("input",
@@ -246,7 +246,7 @@ void regclass_CompiledModel(py::module m) {
Gets all outputs of a compiled model.
:return: Outputs of a compiled model.
- :rtype: List[openvino.ConstOutput]
+ :rtype: list[openvino.ConstOutput]
)");
cls.def("output",
diff --git a/src/bindings/python/src/pyopenvino/core/core.cpp b/src/bindings/python/src/pyopenvino/core/core.cpp
index b211024569f..1e547dfbbe8 100644
--- a/src/bindings/python/src/pyopenvino/core/core.cpp
+++ b/src/bindings/python/src/pyopenvino/core/core.cpp
@@ -38,8 +38,8 @@ void regclass_Core(py::module m) {
R"(
Sets properties.
- :param properties: Dict of pairs: (property name, property value).
- :type properties: typing.Dict[str, typing.Any]
+ :param properties: dict of pairs: (property name, property value).
+ :type properties: dict[str, typing.Any]
)");
// Overload for single tuple
@@ -53,8 +53,8 @@ void regclass_Core(py::module m) {
R"(
Sets properties for the device.
- :param property: Tuple of (property name, matching property value).
- :type property: typing.Tuple[str, typing.Any]
+ :param property: tuple of (property name, matching property value).
+ :type property: tuple[str, typing.Any]
)");
cls.def(
@@ -69,8 +69,8 @@ void regclass_Core(py::module m) {
:param device_name: Name of the device.
:type device_name: str
- :param properties: Dict of pairs: (property name, property value).
- :type properties: typing.Dict[str, typing.Any]
+ :param properties: dict of pairs: (property name, property value).
+ :type properties: dict[str, typing.Any]
)");
// Overload for single tuple
@@ -87,8 +87,8 @@ void regclass_Core(py::module m) {
:param device_name: Name of the device.
:type device_name: str
- :param property: Tuple of (property name, matching property value).
- :type property: typing.Tuple[str, typing.Any]
+ :param property: tuple of (property name, matching property value).
+ :type property: tuple[str, typing.Any]
)");
cls.def(
@@ -174,7 +174,7 @@ void regclass_Core(py::module m) {
:param device_name: Name of the device which will load the model.
:type device_name: str
:param properties: Optional dict of pairs: (property name, property value) relevant only for this load operation.
- :type properties: typing.Dict[str, typing.Any]
+ :type properties: dict[str, typing.Any]
:return: A compiled model.
:rtype: openvino.CompiledModel
)");
@@ -200,7 +200,7 @@ void regclass_Core(py::module m) {
:param model: Model acquired from read_model function.
:type model: openvino.Model
:param properties: Optional dict of pairs: (property name, property value) relevant only for this load operation.
- :type properties: typing.Dict[str, typing.Any]
+ :type properties: dict[str, typing.Any]
:return: A compiled model.
:rtype: openvino.CompiledModel
)");
@@ -231,7 +231,7 @@ void regclass_Core(py::module m) {
:param device_name: Name of the device to load the model to.
:type device_name: str
:param properties: Optional dict of pairs: (property name, property value) relevant only for this load operation.
- :type properties: typing.Dict[str, typing.Any]
+ :type properties: dict[str, typing.Any]
:return: A compiled model.
:rtype: openvino.CompiledModel
)");
@@ -304,7 +304,7 @@ void regclass_Core(py::module m) {
:param model_path: A path to a model in IR / ONNX / PDPD / TF and TFLite format.
:type model_path: typing.Union[str, pathlib.Path]
:param properties: Optional dict of pairs: (property name, property value) relevant only for this load operation.
- :type properties: typing.Dict[str, typing.Any]
+ :type properties: dict[str, typing.Any]
:return: A compiled model.
:rtype: openvino.CompiledModel
)");
@@ -332,7 +332,7 @@ void regclass_Core(py::module m) {
:param context: RemoteContext instance.
:type context: openvino.RemoteContext
:param properties: dict of pairs: (property name, property value) relevant only for this load operation.
- :type properties: typing.Dict[str, typing.Any]
+ :type properties: dict[str, typing.Any]
:return: A compiled model.
:rtype: openvino.CompiledModel
)");
@@ -352,7 +352,7 @@ void regclass_Core(py::module m) {
:param device_name: Name of a device to create a new shared context on.
:type device_name: str
:param properties: dict of device-specific shared context remote properties.
- :type properties: typing.Dict[str, typing.Any]
+ :type properties: dict[str, typing.Any]
:return: Remote context instance.
:rtype: openvino.RemoteContext
)");
@@ -381,7 +381,7 @@ void regclass_Core(py::module m) {
:param device_name: Device name to identify a plugin.
:type device_name: str
:return: Plugin version information.
- :rtype: typing.Dict[str, openvino.Version]
+ :rtype: dict[str, openvino.Version]
)");
cls.def(
@@ -444,7 +444,7 @@ void regclass_Core(py::module m) {
For TFLite format (*.tflite) weights parameter is not used.
:type weights: str
:param config: Optional map of pairs: (property name, property value) relevant only for this read operation.
- :type config: typing.Dict[str, typing.Any], optional
+ :type config: dict[str, typing.Any], optional
:return: A model.
:rtype: openvino.Model
)");
@@ -527,7 +527,7 @@ void regclass_Core(py::module m) {
For TFLite format (*.tflite) weights parameter is not used.
:type weights: typing.Union[pathlib.Path, io.BytesIO]
:param config: Optional map of pairs: (property name, property value) relevant only for this read operation.
- :type config: typing.Dict[str, typing.Any], optional
+ :type config: dict[str, typing.Any], optional
:return: A model.
:rtype: openvino.Model
)");
@@ -578,7 +578,7 @@ void regclass_Core(py::module m) {
Note: if device_name is not used to compile the original model, an exception is thrown.
:type device_name: str
:param properties: Optional map of pairs: (property name, property value) relevant only for this load operation.
- :type properties: typing.Dict[str, typing.Any], optional
+ :type properties: dict[str, typing.Any], optional
:return: A compiled model.
:rtype: openvino.CompiledModel
@@ -638,7 +638,7 @@ void regclass_Core(py::module m) {
:param device_name: A device name to register plugin for.
:type device_name: str
:param config: Plugin default configuration
- :type config: typing.Dict[str, typing.Any], optional
+ :type config: dict[str, typing.Any], optional
)");
cls.def("register_plugins",
@@ -687,9 +687,9 @@ void regclass_Core(py::module m) {
:param device_name: A name of a device to query.
:type device_name: str
:param properties: Optional dict of pairs: (property name, property value)
- :type properties: typing.Dict[str, typing.Any]
+ :type properties: dict[str, typing.Any]
:return: Pairs a operation name -> a device name supporting this operation.
- :rtype: typing.Dict[str, str]
+ :rtype: dict[str, str]
)");
cls.def("add_extension",
@@ -719,8 +719,8 @@ void regclass_Core(py::module m) {
R"(
Registers extensions to a Core object.
- :param extensions: List of Extension objects.
- :type extensions: typing.List[openvino.Extension]
+ :param extensions: list of Extension objects.
+ :type extensions: list[openvino.Extension]
)");
cls.def(
@@ -733,7 +733,7 @@ void regclass_Core(py::module m) {
Registers custom Op to a Core object.
:param custom_op: type of custom Op
- :type custom_op: typing.Type[openvino.Op]
+ :type custom_op: type[openvino.Op]
)");
cls.def("get_available_devices",
@@ -748,7 +748,7 @@ void regclass_Core(py::module m) {
If there more than one device of specific type, they are enumerated with .# suffix.
Such enumerated device can later be used as a device name in all Core methods like:
compile_model, query_model, set_property and so on.
- :rtype: typing.List[str]
+ :rtype: list[str]
)");
cls.def_property_readonly("available_devices",
@@ -763,7 +763,7 @@ void regclass_Core(py::module m) {
If there more than one device of specific type, they are enumerated with .# suffix.
Such enumerated device can later be used as a device name in all Core methods like:
compile_model, query_model, set_property and so on.
- :rtype: typing.List[str]
+ :rtype: list[str]
)");
cls.def("__repr__", [](const ov::Core& self) {
diff --git a/src/bindings/python/src/pyopenvino/core/infer_request.cpp b/src/bindings/python/src/pyopenvino/core/infer_request.cpp
index 157b4b8c6f8..2f99ff875b6 100644
--- a/src/bindings/python/src/pyopenvino/core/infer_request.cpp
+++ b/src/bindings/python/src/pyopenvino/core/infer_request.cpp
@@ -46,7 +46,7 @@ void regclass_InferRequest(py::module m) {
Set tensors using given keys.
:param inputs: Data to set on tensors.
- :type inputs: Dict[Union[int, str, openvino.ConstOutput], openvino.Tensor]
+ :type inputs: dict[Union[int, str, openvino.ConstOutput], openvino.Tensor]
)");
cls.def(
@@ -68,7 +68,7 @@ void regclass_InferRequest(py::module m) {
:param tensors: Input tensors for batched infer request. The type of each tensor
must match the model input element type and shape (except batch dimension).
Total size of tensors needs to match with input's size.
- :type tensors: List[openvino.Tensor]
+ :type tensors: list[openvino.Tensor]
)");
cls.def(
@@ -91,7 +91,7 @@ void regclass_InferRequest(py::module m) {
:param tensors: Input tensors for batched infer request. The type of each tensor
must match the model input element type and shape (except batch dimension).
Total size of tensors needs to match with input's size.
- :type tensors: List[openvino.Tensor]
+ :type tensors: list[openvino.Tensor]
:rtype: None
)");
@@ -109,7 +109,7 @@ void regclass_InferRequest(py::module m) {
Set output tensors using given indexes.
:param outputs: Data to set on output tensors.
- :type outputs: Dict[int, openvino.Tensor]
+ :type outputs: dict[int, openvino.Tensor]
)");
// Python API exclusive function
@@ -126,7 +126,7 @@ void regclass_InferRequest(py::module m) {
Set input tensors using given indexes.
:param inputs: Data to set on output tensors.
- :type inputs: Dict[int, openvino.Tensor]
+ :type inputs: dict[int, openvino.Tensor]
)");
cls.def(
@@ -143,7 +143,7 @@ void regclass_InferRequest(py::module m) {
:param tensors: Input tensors for batched infer request. The type of each tensor
must match the model input element type and shape (except batch dimension).
Total size of tensors needs to match with input's size.
- :type tensors: List[openvino.Tensor]
+ :type tensors: list[openvino.Tensor]
)");
cls.def(
@@ -185,7 +185,7 @@ void regclass_InferRequest(py::module m) {
:param inputs: Data to set on single input tensor.
:type inputs: openvino.Tensor
:return: Dictionary of results from output tensors with ports as keys.
- :rtype: Dict[openvino.ConstOutput, numpy.array]
+ :rtype: dict[openvino.ConstOutput, numpy.array]
)");
// Overload for general case, it accepts dict of inputs that are pairs of (key, value).
@@ -213,9 +213,9 @@ void regclass_InferRequest(py::module m) {
GIL is released while running the inference.
:param inputs: Data to set on input tensors.
- :type inputs: Dict[Union[int, str, openvino.ConstOutput], openvino.Tensor]
+ :type inputs: dict[Union[int, str, openvino.ConstOutput], openvino.Tensor]
:return: Dictionary of results from output tensors with ports as keys.
- :rtype: Dict[openvino.ConstOutput, numpy.array]
+ :rtype: dict[openvino.ConstOutput, numpy.array]
)");
// Overload for single input, it will throw error if a model has more than one input.
@@ -286,7 +286,7 @@ void regclass_InferRequest(py::module m) {
running will lead to throwing exceptions.
:param inputs: Data to set on input tensors.
- :type inputs: Dict[Union[int, str, openvino.ConstOutput], openvino.Tensor]
+ :type inputs: dict[Union[int, str, openvino.ConstOutput], openvino.Tensor]
:param userdata: Any data that will be passed inside callback call.
:type userdata: Any
)");
@@ -617,8 +617,8 @@ void regclass_InferRequest(py::module m) {
GIL is released while running this function.
- :return: List of profiling information for operations in model.
- :rtype: List[openvino.ProfilingInfo]
+ :return: list of profiling information for operations in model.
+ :rtype: list[openvino.ProfilingInfo]
)");
cls.def(
@@ -632,8 +632,8 @@ void regclass_InferRequest(py::module m) {
GIL is released while running this function.
- :return: List of VariableState objects.
- :rtype: List[openvino.VariableState]
+ :return: list of VariableState objects.
+ :rtype: list[openvino.VariableState]
)");
cls.def(
@@ -677,7 +677,7 @@ void regclass_InferRequest(py::module m) {
R"(
Gets all inputs of a compiled model which was used to create this InferRequest.
- :rtype: List[openvino.ConstOutput]
+ :rtype: list[openvino.ConstOutput]
)");
cls.def_property_readonly(
@@ -688,7 +688,7 @@ void regclass_InferRequest(py::module m) {
R"(
Gets all outputs of a compiled model which was used to create this InferRequest.
- :rtype: List[openvino.ConstOutput]
+ :rtype: list[openvino.ConstOutput]
)");
cls.def_property_readonly("input_tensors",
@@ -696,7 +696,7 @@ void regclass_InferRequest(py::module m) {
R"(
Gets all input tensors of this InferRequest.
- :rtype: List[openvino.Tensor]
+ :rtype: list[openvino.Tensor]
)");
cls.def_property_readonly("output_tensors",
@@ -705,7 +705,7 @@ void regclass_InferRequest(py::module m) {
Gets all output tensors of this InferRequest.
- :rtype: List[openvino.Tensor]
+ :rtype: list[openvino.Tensor]
)");
cls.def_property_readonly(
@@ -732,7 +732,7 @@ void regclass_InferRequest(py::module m) {
GIL is released while running this function.
:return: Inference time.
- :rtype: List[openvino.ProfilingInfo]
+ :rtype: list[openvino.ProfilingInfo]
)");
cls.def_property_readonly(
@@ -746,7 +746,7 @@ void regclass_InferRequest(py::module m) {
Note: All string-based data is decoded by default.
:return: Dictionary of results from output tensors with ports as keys.
- :rtype: Dict[openvino.ConstOutput, numpy.array]
+ :rtype: dict[openvino.ConstOutput, numpy.array]
)");
cls.def("__repr__", [](const InferRequestWrapper& self) {
diff --git a/src/bindings/python/src/pyopenvino/core/remote_context.cpp b/src/bindings/python/src/pyopenvino/core/remote_context.cpp
index 6ddccf1ddff..8e2ff5482c2 100644
--- a/src/bindings/python/src/pyopenvino/core/remote_context.cpp
+++ b/src/bindings/python/src/pyopenvino/core/remote_context.cpp
@@ -159,7 +159,7 @@ void regclass_VAContext(py::module m) {
:param nv12_surface: NV12 `VASurfaceID` to create NV12 from.
:type nv12_surface: int
:return: A pair of remote tensors for each plane.
- :rtype: Tuple[openvino.VASurfaceTensor, openvino.VASurfaceTensor]
+ :rtype: tuple[openvino.VASurfaceTensor, openvino.VASurfaceTensor]
)");
cls.def(
diff --git a/src/bindings/python/src/pyopenvino/core/tensor.cpp b/src/bindings/python/src/pyopenvino/core/tensor.cpp
index 30d1e789cbb..a82121287f6 100644
--- a/src/bindings/python/src/pyopenvino/core/tensor.cpp
+++ b/src/bindings/python/src/pyopenvino/core/tensor.cpp
@@ -118,8 +118,8 @@ void regclass_Tensor(py::module m) {
Creates a Tensor from a given Python list.
Warning: It is always a copy of list's data!
- :param array: List to create the tensor from.
- :type array: List[int, float, str]
+ :param array: list to create the tensor from.
+ :type array: list[int, float, str]
)");
cls.def(py::init<const ov::element::Type, const ov::Shape>(), py::arg("type"), py::arg("shape"));
@@ -218,7 +218,7 @@ void regclass_Tensor(py::module m) {
cls.def(py::init([](py::object& image) {
if (!py::isinstance(image, py::module::import("PIL.Image").attr("Image"))) {
throw py::type_error(
- "Input argument must be a PIL.Image.Image/numpy.array/List[int, float, str] object");
+ "Input argument must be a PIL.Image.Image/numpy.array/list[int, float, str] object");
}
auto numpy = py::module::import("numpy");
py::array np_array = numpy.attr("array")(image);
diff --git a/src/bindings/python/src/pyopenvino/experimental/experimental.cpp b/src/bindings/python/src/pyopenvino/experimental/experimental.cpp
index d3de09e3d2f..b5bf15772fc 100644
--- a/src/bindings/python/src/pyopenvino/experimental/experimental.cpp
+++ b/src/bindings/python/src/pyopenvino/experimental/experimental.cpp
@@ -39,7 +39,7 @@ void regmodule_experimental(py::module m) {
:param output: Node output pointing to the tensor for estimation.
:type output: openvino.Output
:return: Tensors representing the lower and upper bound value estimations.
- :rtype: Tuple[openvino.Tensor, openvino.Tensor]
+ :rtype: tuple[openvino.Tensor, openvino.Tensor]
)");
m_dev.def("set_element_type",
&ov::descriptor::set_element_type,
diff --git a/src/bindings/python/src/pyopenvino/frontend/frontend.cpp b/src/bindings/python/src/pyopenvino/frontend/frontend.cpp
index daede38a557..5182b829dd1 100644
--- a/src/bindings/python/src/pyopenvino/frontend/frontend.cpp
+++ b/src/bindings/python/src/pyopenvino/frontend/frontend.cpp
@@ -197,7 +197,7 @@ void regclass_frontend_FrontEnd(py::module m) {
used in order to extend capabilities of Frontend.
:param extension: Provided extension objects.
- :type extension: List[Extension]
+ :type extension: list[Extension]
)");
fem.def(
diff --git a/src/bindings/python/src/pyopenvino/frontend/input_model.cpp b/src/bindings/python/src/pyopenvino/frontend/input_model.cpp
index 4140a097a28..bc4f2d24ec0 100644
--- a/src/bindings/python/src/pyopenvino/frontend/input_model.cpp
+++ b/src/bindings/python/src/pyopenvino/frontend/input_model.cpp
@@ -246,7 +246,7 @@ void regclass_frontend_InputModel(py::module m) {
Returns all inputs for a model.
:return: A list of input places.
- :rtype: List[openvino.frontend.Place]
+ :rtype: list[openvino.frontend.Place]
)");
im.def("get_outputs",
@@ -255,7 +255,7 @@ void regclass_frontend_InputModel(py::module m) {
Returns all outputs for a model. An output is a terminal place in a graph where data escapes the flow.
:return: A list of output places.
- :rtype: List[openvino.frontend.Place]
+ :rtype: list[openvino.frontend.Place]
)");
im.def("extract_subgraph",
@@ -266,9 +266,9 @@ void regclass_frontend_InputModel(py::module m) {
Leaves only subgraph that are defined by new inputs and new outputs.
:param inputs: Array of new input places.
- :type inputs: List[openvino.frontend.Place]
+ :type inputs: list[openvino.frontend.Place]
:param outputs: Array of new output places.
- :type outputs: List[openvino.frontend.Place]
+ :type outputs: list[openvino.frontend.Place]
)");
im.def("override_all_inputs",
@@ -279,7 +279,7 @@ void regclass_frontend_InputModel(py::module m) {
should completely satisfy all existing outputs.
:param inputs: Array of new input places.
- :type inputs: List[openvino.frontend.Place]
+ :type inputs: list[openvino.frontend.Place]
)");
im.def("override_all_outputs",
@@ -290,7 +290,7 @@ void regclass_frontend_InputModel(py::module m) {
is not required for new outputs.
:param outputs: Vector with places that will become new outputs; may intersect existing outputs.
- :type outputs: List[openvino.frontend.Place]
+ :type outputs: list[openvino.frontend.Place]
)");
im.def("set_element_type",
diff --git a/src/bindings/python/src/pyopenvino/frontend/manager.cpp b/src/bindings/python/src/pyopenvino/frontend/manager.cpp
index 2a2a8a0515d..33e79f10d9b 100644
--- a/src/bindings/python/src/pyopenvino/frontend/manager.cpp
+++ b/src/bindings/python/src/pyopenvino/frontend/manager.cpp
@@ -37,8 +37,8 @@ void regclass_frontend_FrontEndManager(py::module m) {
R"(
Gets list of registered frontends.
- :return: List of available frontend names.
- :rtype: List[str]
+ :return: list of available frontend names.
+ :rtype: list[str]
)");
fem.def(
diff --git a/src/bindings/python/src/pyopenvino/frontend/place.cpp b/src/bindings/python/src/pyopenvino/frontend/place.cpp
index 1ec9ea5db71..37fbb4478a4 100644
--- a/src/bindings/python/src/pyopenvino/frontend/place.cpp
+++ b/src/bindings/python/src/pyopenvino/frontend/place.cpp
@@ -43,7 +43,7 @@ void regclass_frontend_Place(py::module m) {
:return: A vector of strings each representing a name that identifies this place in the graph.
Can be empty if there are no names associated with this place or name cannot be attached.
- :rtype: List[str]
+ :rtype: list[str]
)");
place.def("is_equal",
@@ -102,7 +102,7 @@ void regclass_frontend_Place(py::module m) {
May not be set if node has only one output port.
:type output_port_index: int
:return: A list with all operation node references that consumes data from this place
- :rtype: List[openvino.frontend.Place]
+ :rtype: list[openvino.frontend.Place]
)");
place.def(
@@ -244,7 +244,7 @@ void regclass_frontend_Place(py::module m) {
Returns all input ports that consume data flows through this place.
:return: Input ports that consume data flows through this place.
- :rtype: List[openvino.frontend.Place]
+ :rtype: list[openvino.frontend.Place]
)");
place.def(
diff --git a/src/bindings/python/src/pyopenvino/graph/any.cpp b/src/bindings/python/src/pyopenvino/graph/any.cpp
index 5e1689ddffe..ff9a7b28e7c 100644
--- a/src/bindings/python/src/pyopenvino/graph/any.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/any.cpp
@@ -132,7 +132,7 @@ void regclass_graph_Any(py::module m) {
:type dtype: Union[bool, int, str, float]
:return: A runtime attribute as a list.
- :rtype: Union[List[float], List[int], List[str], List[bool]]
+ :rtype: Union[list[float], list[int], list[str], list[bool]]
)");
ov_any.def(
"get",
diff --git a/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp b/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp
index be0e1e8e2dc..445be5d9f52 100644
--- a/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/descriptors/tensor.cpp
@@ -85,7 +85,7 @@ void regclass_graph_descriptor_Tensor(py::module m) {
R"(
Set names for tensor.
- :param names: Set of names.
+ :param names: set of names.
:type names: set
)");
@@ -149,10 +149,10 @@ void regclass_graph_descriptor_Tensor(py::module m) {
tensor.def("get_value_symbol",
&ov::descriptor::Tensor::get_value_symbol,
R"(
- Returns the List of symbols.
+ Returns the list of symbols.
- :return: List of Symbols.
- :rtype: List[openvino.Symbol]
+ :return: list of Symbols.
+ :rtype: list[openvino.Symbol]
)");
tensor.def("set_value_symbol",
@@ -161,8 +161,8 @@ void regclass_graph_descriptor_Tensor(py::module m) {
R"(
Sets the value symbol of the tensor.
- :param value_symbol: List of Symbols
- :type value_symbol: List[openvino.Symbol]
+ :param value_symbol: list of Symbols
+ :type value_symbol: list[openvino.Symbol]
)");
tensor.def_property_readonly("shape", &ov::descriptor::Tensor::get_shape);
diff --git a/src/bindings/python/src/pyopenvino/graph/model.cpp b/src/bindings/python/src/pyopenvino/graph/model.cpp
index b8431c0e290..e65ac9a80c5 100644
--- a/src/bindings/python/src/pyopenvino/graph/model.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/model.cpp
@@ -175,12 +175,12 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model.
- :param results: List of results.
- :type results: List[op.Result]
- :param sinks: List of Nodes to be used as Sinks (e.g. Assign ops).
- :type sinks: List[openvino.Node]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of results.
+ :type results: list[op.Result]
+ :param sinks: list of Nodes to be used as Sinks (e.g. Assign ops).
+ :type sinks: list[openvino.Node]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -195,10 +195,10 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model.
- :param results: List of results.
- :type results: List[op.Result]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of results.
+ :type results: list[op.Result]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -213,10 +213,10 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model.
- :param results: List of Nodes to be used as results.
- :type results: List[openvino.Node]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of Nodes to be used as results.
+ :type results: list[openvino.Node]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -234,8 +234,8 @@ void regclass_graph_Model(py::module m) {
:param result: Node to be used as result.
:type result: openvino.Node
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -250,10 +250,10 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of outputs.
- :type results: List[openvino.Output]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of outputs.
+ :type results: list[openvino.Output]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -274,12 +274,12 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of outputs.
- :type results: List[openvino.Output]
- :param sinks: List of Nodes to be used as Sinks (e.g. Assign ops).
- :type sinks: List[openvino.Node]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of outputs.
+ :type results: list[openvino.Output]
+ :param sinks: list of Nodes to be used as Sinks (e.g. Assign ops).
+ :type sinks: list[openvino.Node]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -300,12 +300,12 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of outputs.
- :type results: List[openvino.Output]
- :param sinks: List of Output sink node handles.
- :type sinks: List[openvino.Output]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of outputs.
+ :type results: list[openvino.Output]
+ :param sinks: list of Output sink node handles.
+ :type sinks: list[openvino.Output]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -325,14 +325,14 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of outputs.
- :type results: List[openvino.Output]
- :param sinks: List of Output sink node handles.
- :type sinks: List[openvino.Output]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
- :param variables: List of variables.
- :type variables: List[op.util.Variable]
+ :param results: list of outputs.
+ :type results: list[openvino.Output]
+ :param sinks: list of Output sink node handles.
+ :type sinks: list[openvino.Output]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
+ :param variables: list of variables.
+ :type variables: list[op.util.Variable]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -353,12 +353,12 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of results.
- :type results: List[op.Result]
- :param sinks: List of Output sink node handles.
- :type sinks: List[openvino.Output]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of results.
+ :type results: list[op.Result]
+ :param sinks: list of Output sink node handles.
+ :type sinks: list[openvino.Output]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -378,14 +378,14 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of results.
- :type results: List[op.Result]
- :param sinks: List of Output sink node handles.
- :type sinks: List[openvino.Output]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
- :param variables: List of variables.
- :type variables: List[op.util.Variable]
+ :param results: list of results.
+ :type results: list[op.Result]
+ :param sinks: list of Output sink node handles.
+ :type sinks: list[openvino.Output]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
+ :param variables: list of variables.
+ :type variables: list[op.util.Variable]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -405,14 +405,14 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of results.
- :type results: List[op.Result]
- :param sinks: List of Nodes to be used as Sinks (e.g. Assign ops).
- :type sinks: List[openvino.Node]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
- :param variables: List of variables.
- :type variables: List[op.util.Variable]
+ :param results: list of results.
+ :type results: list[op.Result]
+ :param sinks: list of Nodes to be used as Sinks (e.g. Assign ops).
+ :type sinks: list[openvino.Node]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
+ :param variables: list of variables.
+ :type variables: list[op.util.Variable]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -432,12 +432,12 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of results.
- :type results: List[openvino.Output]
- :param sinks: List of Nodes to be used as Sinks (e.g. Assign ops).
- :type sinks: List[openvino.Node]
- :param variables: List of variables.
- :type variables: List[op.util.Variable]
+ :param results: list of results.
+ :type results: list[openvino.Output]
+ :param sinks: list of Nodes to be used as Sinks (e.g. Assign ops).
+ :type sinks: list[openvino.Node]
+ :param variables: list of variables.
+ :type variables: list[op.util.Variable]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -455,12 +455,12 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of results.
- :type results: List[op.Result]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
- :param variables: List of variables.
- :type variables: List[op.util.Variable]
+ :param results: list of results.
+ :type results: list[op.Result]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
+ :param variables: list of variables.
+ :type variables: list[op.util.Variable]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -478,10 +478,10 @@ void regclass_graph_Model(py::module m) {
R"(
Create user-defined Model which is a representation of a model
- :param results: List of results.
- :type results: List[openvino.Output]
- :param parameters: List of parameters.
- :type parameters: List[op.Parameter]
+ :param results: list of results.
+ :type results: list[openvino.Output]
+ :param parameters: list of parameters.
+ :type parameters: list[op.Parameter]
:param name: String to set as model's friendly name.
:type name: str
)");
@@ -525,7 +525,7 @@ void regclass_graph_Model(py::module m) {
:param partial_shape: New shape.
:type partial_shape: openvino.PartialShape
:param variables_shapes: New shapes for variables
- :type variables_shapes: Dict[keys, values]
+ :type variables_shapes: dict[keys, values]
:return : void
)");
@@ -567,7 +567,7 @@ void regclass_graph_Model(py::module m) {
:param partial_shape: New shape.
:type partial_shape: list
:param variables_shapes: New shapes for variables
- :type variables_shapes: Dict[keys, values]
+ :type variables_shapes: dict[keys, values]
:return : void
)");
@@ -609,7 +609,7 @@ void regclass_graph_Model(py::module m) {
:param partial_shape: New shape.
:type partial_shape: tuple
:param variables_shapes: New shapes for variables
- :type variables_shapes: Dict[keys, values]
+ :type variables_shapes: dict[keys, values]
:return : void
)");
@@ -651,7 +651,7 @@ void regclass_graph_Model(py::module m) {
:param partial_shape: New shape.
:type partial_shape: str
:param variables_shapes: New shapes for variables
- :type variables_shapes: Dict[keys, values]
+ :type variables_shapes: dict[keys, values]
:return : void
)");
@@ -723,9 +723,9 @@ void regclass_graph_Model(py::module m) {
GIL is released while running this function.
:param partial_shapes: New shapes.
- :type partial_shapes: Dict[keys, values]
+ :type partial_shapes: dict[keys, values]
:param variables_shapes: New shapes for variables
- :type variables_shapes: Dict[keys, values]
+ :type variables_shapes: dict[keys, values]
)");
model.def("get_output_size",
@@ -741,16 +741,16 @@ void regclass_graph_Model(py::module m) {
R"(
Return ops used in the model.
- :return: List of Nodes representing ops used in model.
- :rtype: List[openvino.Node]
+ :return: list of Nodes representing ops used in model.
+ :rtype: list[openvino.Node]
)");
model.def("get_ordered_ops",
&ov::Model::get_ordered_ops,
R"(
Return ops used in the model in topological order.
- :return: List of sorted Nodes representing ops used in model.
- :rtype: List[openvino.Node]
+ :return: list of sorted Nodes representing ops used in model.
+ :rtype: list[openvino.Node]
)");
model.def("get_output_op",
&ov::Model::get_output_op,
@@ -802,7 +802,7 @@ void regclass_graph_Model(py::module m) {
Return the model parameters.
:return: a list of model's parameters.
- :rtype: List[op.Parameter]
+ :rtype: list[op.Parameter]
)");
model.def_property_readonly("parameters",
&ov::Model::get_parameters,
@@ -810,7 +810,7 @@ void regclass_graph_Model(py::module m) {
Return the model parameters.
:return: a list of model's parameters.
- :rtype: List[op.Parameter]
+ :rtype: list[op.Parameter]
)");
model.def("get_results",
&ov::Model::get_results,
@@ -818,7 +818,7 @@ void regclass_graph_Model(py::module m) {
Return a list of model outputs.
:return: a list of model's result nodes.
- :rtype: List[op.Result]
+ :rtype: list[op.Result]
)");
model.def_property_readonly("results",
&ov::Model::get_results,
@@ -826,7 +826,7 @@ void regclass_graph_Model(py::module m) {
Return a list of model outputs.
:return: a list of model's result nodes.
- :rtype: List[op.Result]
+ :rtype: list[op.Result]
)");
model.def("get_result",
&ov::Model::get_result,
@@ -1182,7 +1182,7 @@ void regclass_graph_Model(py::module m) {
* call graph validation to check correctness of changes
:param parameter: new Parameter nodes.
- :type parameter: List[op.Parameter]
+ :type parameter: list[op.Parameter]
)");
model.def("add_results",
@@ -1194,7 +1194,7 @@ void regclass_graph_Model(py::module m) {
Method doesn't validate graph, it should be done manually after all changes.
:param results: new Result nodes.
- :type results: List[op.Result]
+ :type results: list[op.Result]
)");
model.def(
@@ -1216,7 +1216,7 @@ void regclass_graph_Model(py::module m) {
Method doesn't validate graph, it should be done manually after all changes.
:param sinks: new sink nodes.
- :type sinks: List[openvino.Node]
+ :type sinks: list[openvino.Node]
)");
model.def("add_variables",
@@ -1228,7 +1228,7 @@ void regclass_graph_Model(py::module m) {
Method doesn't validate graph, it should be done manually after all changes.
:param variables: new variables to add.
- :type variables: List[op.util.Variable]
+ :type variables: list[op.util.Variable]
)");
model.def("get_variables",
@@ -1237,7 +1237,7 @@ void regclass_graph_Model(py::module m) {
Return a list of model's variables.
:return: a list of model's variables.
- :rtype: List[op.util.Variable]
+ :rtype: list[op.util.Variable]
)");
model.def_property_readonly("variables",
@@ -1246,7 +1246,7 @@ void regclass_graph_Model(py::module m) {
Return a list of model's variables.
:return: a list of model's variables.
- :rtype: List[op.util.Variable]
+ :rtype: list[op.util.Variable]
)");
model.def("get_variable_by_id",
@@ -1270,7 +1270,7 @@ void regclass_graph_Model(py::module m) {
Return a list of model's sinks.
:return: a list of model's sinks.
- :rtype: List[openvino.Node]
+ :rtype: list[openvino.Node]
)");
model.def_property_readonly(
@@ -1283,7 +1283,7 @@ void regclass_graph_Model(py::module m) {
Return a list of model's sinks.
:return: a list of model's sinks.
- :rtype: List[openvino.Node]
+ :rtype: list[openvino.Node]
)");
model.def(
@@ -1301,9 +1301,9 @@ void regclass_graph_Model(py::module m) {
Evaluate the model on inputs, putting results in outputs
:param output_tensors: Tensors for the outputs to compute. One for each result
- :type output_tensors: List[openvino.Tensor]
+ :type output_tensors: list[openvino.Tensor]
:param input_tensors: Tensors for the inputs. One for each inputs.
- :type input_tensors: List[openvino.Tensor]
+ :type input_tensors: list[openvino.Tensor]
:param evaluation_context: Storage of additional settings and attributes that can be used
when evaluating the model. This additional information can be
shared across nodes.
@@ -1351,8 +1351,8 @@ void regclass_graph_Model(py::module m) {
R"(
Returns runtime attribute as a OVAny object.
- :param path: List of strings which defines a path to runtime info.
- :type path: List[str]
+ :param path: list of strings which defines a path to runtime info.
+ :type path: list[str]
:return: A runtime attribute.
:rtype: openvino.OVAny
@@ -1366,7 +1366,7 @@ void regclass_graph_Model(py::module m) {
R"(
Returns runtime attribute as a OVAny object.
- :param path: List of strings which defines a path to runtime info.
+ :param path: list of strings which defines a path to runtime info.
:type path: str
:return: A runtime attribute.
@@ -1385,8 +1385,8 @@ void regclass_graph_Model(py::module m) {
R"(
Checks if given path exists in runtime info of the model.
- :param path: List of strings which defines a path to runtime info.
- :type path: List[str]
+ :param path: list of strings which defines a path to runtime info.
+ :type path: list[str]
:return: `True` if path exists, otherwise `False`.
:rtype: bool
@@ -1400,7 +1400,7 @@ void regclass_graph_Model(py::module m) {
R"(
Checks if given path exists in runtime info of the model.
- :param path: List of strings which defines a path to runtime info.
+ :param path: list of strings which defines a path to runtime info.
:type path: str
:return: `True` if path exists, otherwise `False`.
@@ -1422,8 +1422,8 @@ void regclass_graph_Model(py::module m) {
:param obj: value for the runtime info
:type obj: py:object
- :param path: List of strings which defines a path to runtime info.
- :type path: List[str]
+ :param path: list of strings which defines a path to runtime info.
+ :type path: list[str]
)");
model.def(
"set_rt_info",
diff --git a/src/bindings/python/src/pyopenvino/graph/node.cpp b/src/bindings/python/src/pyopenvino/graph/node.cpp
index 481028bd280..5b4ba58bb66 100644
--- a/src/bindings/python/src/pyopenvino/graph/node.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/node.cpp
@@ -230,9 +230,9 @@ void regclass_graph_Node(py::module m) {
Evaluate the node on inputs, putting results in outputs
:param output_tensors: Tensors for the outputs to compute. One for each result.
- :type output_tensors: List[openvino.Tensor]
+ :type output_tensors: list[openvino.Tensor]
:param input_tensors: Tensors for the inputs. One for each inputs.
- :type input_tensors: List[openvino.Tensor]
+ :type input_tensors: list[openvino.Tensor]
:param evaluation_context: Storage of additional settings and attributes that can be used
when evaluating the function. This additional information can be shared across nodes.
:type evaluation_context: openvino.RTMap
@@ -249,9 +249,9 @@ void regclass_graph_Node(py::module m) {
Evaluate the function on inputs, putting results in outputs
:param output_tensors: Tensors for the outputs to compute. One for each result.
- :type output_tensors: List[openvino.Tensor]
+ :type output_tensors: list[openvino.Tensor]
:param input_tensors: Tensors for the inputs. One for each inputs.
- :type input_tensors: List[openvino.Tensor]
+ :type input_tensors: list[openvino.Tensor]
:rtype: bool
)");
node.def("get_instance_id",
@@ -289,8 +289,8 @@ void regclass_graph_Node(py::module m) {
R"(
Returns list of node's inputs, in order.
- :return: List of node's inputs
- :rtype: List[openvino.Input]
+ :return: list of node's inputs
+ :rtype: list[openvino.Input]
)");
node.def("input_value",
&ov::Node::input_value,
@@ -475,8 +475,8 @@ void regclass_graph_Node(py::module m) {
R"(
A list containing a handle for each of this node's inputs, in order.
- :return: List of node's inputs.
- :rtype: List[openvino.Input]
+ :return: list of node's inputs.
+ :rtype: list[openvino.Input]
)");
node.def("output",
(ov::Output<ov::Node>(ov::Node::*)(size_t)) & ov::Node::output,
@@ -494,8 +494,8 @@ void regclass_graph_Node(py::module m) {
R"(
A list containing a handle for each of this node's outputs, in order.
- :return: List of node's outputs.
- :rtype: List[openvino.Output]
+ :return: list of node's outputs.
+ :rtype: list[openvino.Output]
)");
node.def("get_rt_info",
(PyRTMap & (ov::Node::*)()) & ov::Node::get_rt_info,
diff --git a/src/bindings/python/src/pyopenvino/graph/node_output.cpp b/src/bindings/python/src/pyopenvino/graph/node_output.cpp
index 8b1f7567e0b..185a56879a4 100644
--- a/src/bindings/python/src/pyopenvino/graph/node_output.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/node_output.cpp
@@ -31,8 +31,8 @@ void def_type_dependent_functions<ov::Node>(
R"(
Set tensor names associated with this output.
- :param names: Set of tensor names.
- :type names: Set[str]
+ :param names: set of tensor names.
+ :type names: set[str]
)");
output.def("add_names",
&ov::Output<ov::Node>::add_names,
@@ -40,8 +40,8 @@ void def_type_dependent_functions<ov::Node>(
R"(
Add tensor names associated with this output.
- :param names: Set of tensor names.
- :type names: Set[str]
+ :param names: set of tensor names.
+ :type names: set[str]
)");
output.def("remove_target_input",
&ov::Output<ov::Node>::remove_target_input,
diff --git a/src/bindings/python/src/pyopenvino/graph/node_output.hpp b/src/bindings/python/src/pyopenvino/graph/node_output.hpp
index f67c821093e..890b7b62b44 100644
--- a/src/bindings/python/src/pyopenvino/graph/node_output.hpp
+++ b/src/bindings/python/src/pyopenvino/graph/node_output.hpp
@@ -92,8 +92,8 @@ void regclass_graph_Output(py::module m, std::string typestring)
R"(
The tensor names associated with this output.
- :return: Set of tensor names.
- :rtype: Set[str]
+ :return: set of tensor names.
+ :rtype: set[str]
)");
output.def("get_element_type",
&ov::Output<VT>::get_element_type,
@@ -127,8 +127,8 @@ void regclass_graph_Output(py::module m, std::string typestring)
A set containing handles for all inputs, targeted by the output,
referenced by this output handle.
- :return: Set of Inputs.
- :rtype: Set[openvino.Input]
+ :return: set of Inputs.
+ :rtype: set[openvino.Input]
)");
output.def("_from_node", [](const std::shared_ptr<ov::Node>& node) {
return ov::Output<ov::Node>(node);
diff --git a/src/bindings/python/src/pyopenvino/graph/passes/matcher_pass.cpp b/src/bindings/python/src/pyopenvino/graph/passes/matcher_pass.cpp
index 726731b3a49..60ad19555c3 100644
--- a/src/bindings/python/src/pyopenvino/graph/passes/matcher_pass.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/passes/matcher_pass.cpp
@@ -86,7 +86,7 @@ void regclass_passes_Matcher(py::module m) {
Get NodeVector of matched nodes. Should be used after match() method is called.
:return: matched nodes vector.
- :rtype: List[openvino.Node]
+ :rtype: list[openvino.Node]
)");
matcher.def("get_match_values",
@@ -96,7 +96,7 @@ void regclass_passes_Matcher(py::module m) {
Get OutputVector of matched outputs. Should be used after match() method is called.
:return: matched outputs vector.
- :rtype: List[openvino.Output]
+ :rtype: list[openvino.Output]
)");
matcher.def("get_pattern_value_map",
diff --git a/src/bindings/python/src/pyopenvino/graph/passes/pattern_ops.cpp b/src/bindings/python/src/pyopenvino/graph/passes/pattern_ops.cpp
index 3cc58935bfa..6e2953746e4 100644
--- a/src/bindings/python/src/pyopenvino/graph/passes/pattern_ops.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/passes/pattern_ops.cpp
@@ -237,7 +237,7 @@ static void reg_pattern_wrap_type(py::module m) {
:type type_name: str
:param inputs: Node outputs.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
)");
wrap_type.def(py::init([](const std::string& type_name, const ov::NodeVector& inputs) {
@@ -254,7 +254,7 @@ static void reg_pattern_wrap_type(py::module m) {
:type type_name: str
:param inputs: Input nodes.
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
)");
wrap_type.def(
@@ -271,7 +271,7 @@ static void reg_pattern_wrap_type(py::module m) {
:type type_name: str
:param inputs: Node outputs.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -290,7 +290,7 @@ static void reg_pattern_wrap_type(py::module m) {
:type type_name: str
:param inputs: Node outputs.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -311,7 +311,7 @@ static void reg_pattern_wrap_type(py::module m) {
:type type_name: str
:param inputs: Input nodes.
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -332,7 +332,7 @@ static void reg_pattern_wrap_type(py::module m) {
:type type_name: str
:param inputs: Input nodes.
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -346,7 +346,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
)");
wrap_type.def(py::init([](const std::vector<std::string>& type_names, const ValuePredicate& pred) {
@@ -358,7 +358,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -373,7 +373,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -390,7 +390,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types and input.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: Node output.
:type input: openvino.Output
@@ -407,7 +407,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types and input.
:param type_name: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_name: List[str]
+ :type type_name: list[str]
:param input: Input node.
:type input: openvino.Node
@@ -427,7 +427,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, input and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: Node output.
:type input: openvino.Output
@@ -450,7 +450,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, input and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: Node output.
:type input: openvino.Output
@@ -473,7 +473,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, input and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: Input node.
:type input: openvino.Node
@@ -496,7 +496,7 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, input and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: Input node.
:type input: openvino.Node
@@ -514,10 +514,10 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types and input.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: Nodes outputs.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
)");
wrap_type.def(py::init([](const std::vector<std::string>& type_names, const ov::NodeVector& inputs) {
@@ -531,10 +531,10 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types and inputs.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: Input nodes.
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
)");
wrap_type.def(
@@ -549,10 +549,10 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, inputs and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: Nodes outputs.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -569,10 +569,10 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, inputs and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: Nodes outputs.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -592,10 +592,10 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, inputs and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: Input nodes.
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -614,10 +614,10 @@ static void reg_pattern_wrap_type(py::module m) {
Create WrapType with given node types, inputs and predicate.
:param type_names: node types. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: Input nodes.
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -640,7 +640,7 @@ static void reg_pattern_or(py::module m) {
Create pattern Or operation which is used to match any of given inputs.
:param inputs: Operation inputs.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
)");
or_type.def(py::init([](const ov::NodeVector& inputs) {
@@ -651,7 +651,7 @@ static void reg_pattern_or(py::module m) {
Create pattern Or operation which is used to match any of given inputs.
:param inputs: Operation inputs.
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
)");
or_type.def("__repr__", [](const ov::pass::pattern::op::Or& self) {
@@ -716,7 +716,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
)");
optional_type.def(py::init([](const std::vector<std::string>& type_names, const ov::Output<ov::Node>& input) {
@@ -730,7 +730,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type and input node.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: input node's output.
:type input: openvino.Output
@@ -747,7 +747,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: input node.
:type input: openvino.Node
@@ -763,10 +763,10 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type and input node.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: input node's output list.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
)");
optional_type.def(py::init([](const std::vector<std::string>& type_names, const ov::NodeVector& inputs) {
@@ -780,10 +780,10 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type and input node.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: input node list
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
)");
optional_type.def(py::init([](const std::vector<std::string>& type_names, const ValuePredicate& predicate) {
@@ -797,7 +797,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -814,7 +814,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -834,7 +834,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: input node's output.
:type input: openvino.Output
@@ -857,7 +857,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: input node's output.
:type input: openvino.Output
@@ -880,7 +880,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: input node
:type input: openvino.Node
@@ -903,7 +903,7 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param input: input node
:type input: openvino.Node
@@ -925,10 +925,10 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: input node's output list.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -945,10 +945,10 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: input node's output list.
- :type inputs: List[openvino.Output]
+ :type inputs: list[openvino.Output]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -968,10 +968,10 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: input node list
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
@@ -990,10 +990,10 @@ static void reg_pattern_optional(py::module m) {
Create Optional with the given node type, input node and predicate.
:param type_names: node type. For example: ["opset8.Abs", "opset8.Relu"]
- :type type_names: List[str]
+ :type type_names: list[str]
:param inputs: input node list
- :type inputs: List[openvino.Node]
+ :type inputs: list[openvino.Node]
:param predicate: Function that performs additional checks for matching.
:type predicate: Callable
diff --git a/src/bindings/python/src/pyopenvino/graph/passes/predicate.cpp b/src/bindings/python/src/pyopenvino/graph/passes/predicate.cpp
index 434d17bd53e..9fb6bf42c9e 100644
--- a/src/bindings/python/src/pyopenvino/graph/passes/predicate.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/passes/predicate.cpp
@@ -97,7 +97,7 @@ static void reg_pattern_symbol_value(py::module m) {
Create PatternSymbolValue with the given value.
:param value: list of values representing a group of pattern values
- :type value: List[PatternSymbolValue]
+ :type value: list[PatternSymbolValue]
)");
value.def("is_dynamic", &ov::pass::pattern::PatternSymbolValue::is_dynamic);
diff --git a/src/bindings/python/src/pyopenvino/graph/passes/transformations.cpp b/src/bindings/python/src/pyopenvino/graph/passes/transformations.cpp
index c307db341a5..8ccd8f64b77 100644
--- a/src/bindings/python/src/pyopenvino/graph/passes/transformations.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/passes/transformations.cpp
@@ -113,7 +113,7 @@ void regclass_transformations(py::module m) {
R"( The transformation replaces the provided pairs Parameter and Result with openvino Memory operations ReadValue and Assign.
:param pairs_to_replace:
- :type pairs_to_replace: List[Tuple[op.Parameter, op.Result]
+ :type pairs_to_replace: list[tuple[op.Parameter, op.Result]
)");
make_stateful.def(py::init<const std::map<std::string, std::string>&>(),
py::arg("pairs_to_replace"),
@@ -121,7 +121,7 @@ void regclass_transformations(py::module m) {
The transformation replaces the provided pairs Parameter and Result with openvino Memory operations ReadValue and Assign.
:param pairs_to_replace: a dictionary of names of the provided Parameter and Result operations.
- :type pairs_to_replace: Dict[str, str]
+ :type pairs_to_replace: dict[str, str]
)");
make_stateful.def("__repr__", [](const ov::pass::MakeStateful& self) {
return Common::get_simple_repr(self);
diff --git a/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp b/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp
index c16d87fce52..eb9e3eac65e 100644
--- a/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp
+++ b/src/bindings/python/src/pyopenvino/graph/preprocess/pre_post_process.cpp
@@ -51,7 +51,7 @@ static void regclass_graph_PreProcessSteps(py::module m) {
Input tensor must have ov.Type.f32 data type.
:param values: Values to subtract.
- :type values: List[float]
+ :type values: list[float]
:return: Reference to itself to allow chaining of calls in client's code in a builder-like manner.
:rtype: openvino.preprocess.PreProcessSteps
)");
@@ -83,7 +83,7 @@ static void regclass_graph_PreProcessSteps(py::module m) {
Input tensor must have ov.Type.f32 data type.
:param values: Values which are used in division.
- :type values: List[float]
+ :type values: list[float]
:return: Reference to itself to allow chaining of calls in client's code in a builder-like manner.
:rtype: openvino.preprocess.PreProcessSteps
)");
diff --git a/src/bindings/python/tests/test_runtime/test_model.py b/src/bindings/python/tests/test_runtime/test_model.py
index aecefa0cd7c..97b6a116555 100644
--- a/src/bindings/python/tests/test_runtime/test_model.py
+++ b/src/bindings/python/tests/test_runtime/test_model.py
@@ -243,16 +243,16 @@ def test_model_sink_ctors():
node = ops.assign(add, "var_id_667")
res = ops.result(add, "res")
- # Model(List[openvino._pyopenvino.op.Result], List[ov::Output<ov::Node>],
- # List[openvino._pyopenvino.op.Parameter], str = '')
+ # Model(list[openvino._pyopenvino.op.Result], list[ov::Output<ov::Node>],
+ # list[openvino._pyopenvino.op.Parameter], str = '')
model = Model(results=[res], sinks=[node.output(0)], parameters=[input_data], name="TestModel")
model.validate_nodes_and_infer_types()
sinks = ["Assign"]
assert sinks == [sink.get_type_name() for sink in model.get_sinks()]
assert model.sinks[0].get_output_shape(0) == Shape([2, 2])
- # Model(List[ov::Output<ov::Node>, List[ov::Output<ov::Node>],
- # List[openvino._pyopenvino.op.Parameter], str = '')
+ # Model(list[ov::Output<ov::Node>, list[ov::Output<ov::Node>],
+ # list[openvino._pyopenvino.op.Parameter], str = '')
model = Model(results=[res.output(0)], sinks=[node.output(0)], parameters=[input_data], name="TestModel")
model.validate_nodes_and_infer_types()
assert model.sinks[0].get_output_shape(0) == Shape([2, 2])
@@ -268,15 +268,15 @@ def test_model_sink_ctors():
assign = ops.assign(add, variable_1)
res = ops.result(add, "res")
- # Model(List[openvino._pyopenvino.op.Result], List[ov::Output<ov::Node>],
- # List[openvino._pyopenvino.op.Parameter], List[openvino._pyopenvino.op.util.Variable], str = '')
+ # Model(list[openvino._pyopenvino.op.Result], list[ov::Output<ov::Node>],
+ # list[openvino._pyopenvino.op.Parameter], list[openvino._pyopenvino.op.util.Variable], str = '')
model = Model(results=[res], sinks=[assign.output(0)], parameters=[input_data], variables=[variable_1], name="TestModel")
model.validate_nodes_and_infer_types()
assert model.sinks[0].get_output_shape(0) == Shape([2, 2])
assert sinks == [sink.get_type_name() for sink in model.get_sinks()]
- # Model(List[ov::Output<ov::Node>, List[ov::Output<ov::Node>],
- # List[openvino._pyopenvino.op.Parameter], List[openvino._pyopenvino.op.util.Variable], str = '')
+ # Model(list[ov::Output<ov::Node>, list[ov::Output<ov::Node>],
+ # list[openvino._pyopenvino.op.Parameter], list[openvino._pyopenvino.op.util.Variable], str = '')
model = Model(results=[res.output(0)], sinks=[assign.output(0)], parameters=[input_data], variables=[variable_1], name="TestModel")
model.validate_nodes_and_infer_types()
assert model.sinks[0].get_output_shape(0) == Shape([2, 2])
diff --git a/src/bindings/python/tests/test_runtime/test_ovdict.py b/src/bindings/python/tests/test_runtime/test_ovdict.py
index d2209b75871..572f8605d55 100644
--- a/src/bindings/python/tests/test_runtime/test_ovdict.py
+++ b/src/bindings/python/tests/test_runtime/test_ovdict.py
@@ -2,7 +2,6 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from collections.abc import Mapping
import numpy as np
import pytest
diff --git a/src/bindings/python/tests/test_transformations/test_compression.py b/src/bindings/python/tests/test_transformations/test_compression.py
index 6532f2d1cf1..1e825dad329 100644
--- a/src/bindings/python/tests/test_transformations/test_compression.py
+++ b/src/bindings/python/tests/test_transformations/test_compression.py
@@ -2,8 +2,6 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import List
-
import numpy as np
from openvino.op import Parameter, Constant
from openvino.opset13 import add, multiply
@@ -37,7 +35,7 @@ def make_model(add_consts, mul_consts):
return ov.Model([mul1], [parameter1])
-def get_constants(model, request, tmp_path) -> List[Constant]:
+def get_constants(model, request, tmp_path) -> list[Constant]:
model_fname, _ = create_filenames_for_ir(request.node.name, tmp_path)
ov.save_model(model, model_fname)
core = ov.Core()
diff --git a/src/bindings/python/tests/utils/helpers.py b/src/bindings/python/tests/utils/helpers.py
index 491bb2d6c5e..919b01b4186 100644
--- a/src/bindings/python/tests/utils/helpers.py
+++ b/src/bindings/python/tests/utils/helpers.py
@@ -2,7 +2,7 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import Tuple, Union, List
+from typing import Union
import os
import sys
@@ -18,7 +18,7 @@ from openvino import Model, Core, Shape, Tensor, Type
import openvino.opset13 as ops
-def _compare_models(model_one: Model, model_two: Model, compare_names: bool = True) -> Tuple[bool, str]: # noqa: C901 the function is too complex
+def _compare_models(model_one: Model, model_two: Model, compare_names: bool = True) -> tuple[bool, str]: # noqa: C901 the function is too complex
"""Function to compare OpenVINO model (ops names, types and shapes).
Note that the functions uses get_ordered_ops, so the topological order of ops should be also preserved.
@@ -26,7 +26,7 @@ def _compare_models(model_one: Model, model_two: Model, compare_names: bool = Tr
:param model_one: The first model to compare.
:param model_two: The second model to compare.
:param compare_names: Flag to control friendly names checking. Default: True
- :return: Tuple which consists of bool value (True if models are equal, otherwise False)
+ :return: tuple which consists of bool value (True if models are equal, otherwise False)
and string with the message to reuse for debug/testing purposes. The string value
is empty when models are equal.
"""
@@ -113,7 +113,7 @@ def plugins_path(device, lib_path):
return plugins_paths
-def generate_image(shape: Tuple = (1, 3, 32, 32), dtype: Union[str, np.dtype] = "float32") -> np.array:
+def generate_image(shape: tuple = (1, 3, 32, 32), dtype: Union[str, np.dtype] = "float32") -> np.array:
np.random.seed(42)
return np.random.rand(*shape).astype(dtype)
@@ -174,7 +174,7 @@ def get_model_with_template_extension():
return core, core.read_model(ir)
-def get_relu_model(input_shape: List[int] = None, input_dtype=np.float32) -> openvino.Model:
+def get_relu_model(input_shape: list[int] = None, input_dtype=np.float32) -> openvino.Model:
if input_shape is None:
input_shape = [1, 3, 32, 32]
param = ops.parameter(input_shape, input_dtype, name="data")
@@ -188,7 +188,7 @@ def get_relu_model(input_shape: List[int] = None, input_dtype=np.float32) -> ope
def generate_relu_compiled_model(
device,
- input_shape: List[int] = None,
+ input_shape: list[int] = None,
input_dtype=np.float32,
) -> openvino.CompiledModel:
if input_shape is None:
@@ -209,7 +209,7 @@ def decrypt_base64(src):
def generate_relu_compiled_model_with_config(
device,
config,
- input_shape: List[int] = None,
+ input_shape: list[int] = None,
input_dtype=np.float32,
) -> openvino.CompiledModel:
if input_shape is None:
@@ -219,13 +219,13 @@ def generate_relu_compiled_model_with_config(
return core.compile_model(model, device, config)
-def generate_model_and_image(device, input_shape: List[int] = None):
+def generate_model_and_image(device, input_shape: list[int] = None):
if input_shape is None:
input_shape = [1, 3, 32, 32]
return (generate_relu_compiled_model(device, input_shape), generate_image(input_shape))
-def generate_add_model(input_shape: List[int] = None, input_dtype=np.float32) -> openvino.Model:
+def generate_add_model(input_shape: list[int] = None, input_dtype=np.float32) -> openvino.Model:
if input_shape is None:
input_shape = [2, 1]
param1 = ops.parameter(Shape(input_shape), dtype=np.float32, name="data1")
@@ -236,7 +236,7 @@ def generate_add_model(input_shape: List[int] = None, input_dtype=np.float32) ->
def generate_add_compiled_model(
device,
- input_shape: List[int] = None,
+ input_shape: list[int] = None,
input_dtype=np.float32,
) -> openvino.CompiledModel:
if input_shape is None:
@@ -257,7 +257,7 @@ def generate_model_with_memory(input_shape, data_type) -> openvino._pyopenvino.M
return model
-def generate_concat_compiled_model(device, input_shape: List[int] = None, ov_type=Type.f32, numpy_dtype=np.float32):
+def generate_concat_compiled_model(device, input_shape: list[int] = None, ov_type=Type.f32, numpy_dtype=np.float32):
if input_shape is None:
input_shape = [5]
@@ -274,7 +274,7 @@ def generate_concat_compiled_model(device, input_shape: List[int] = None, ov_typ
return core.compile_model(model, device)
-def generate_concat_compiled_model_with_data(device, input_shape: List[int] = None, ov_type=Type.f32, numpy_dtype=np.float32):
+def generate_concat_compiled_model_with_data(device, input_shape: list[int] = None, ov_type=Type.f32, numpy_dtype=np.float32):
if input_shape is None:
input_shape = [5]
@@ -322,7 +322,7 @@ def create_filenames_for_ir(test_name, tmp_path, is_xml_path=False, is_bin_path=
:param test_name: Name used in generating.
:param is_xml_path: True if xml file should be pathlib.Path object, otherwise return string.
:param is_bin_path: True if bin file should be pathlib.Path object, otherwise return string.
- :return: Tuple with two objects representing xml and bin files.
+ :return: tuple with two objects representing xml and bin files.
"""
filename = create_filename_for_test(test_name)
path_to_xml = tmp_path / Path(filename + ".xml")
diff --git a/src/frontends/onnx/tests/runtime.py b/src/frontends/onnx/tests/runtime.py
index a2ce9a500d3..026320b94fb 100644
--- a/src/frontends/onnx/tests/runtime.py
+++ b/src/frontends/onnx/tests/runtime.py
@@ -5,7 +5,7 @@
"""Provide a layer of abstraction for an OpenVINO runtime environment."""
import logging
-from typing import Dict, List, Union
+from typing import Union
import numpy as np
@@ -51,7 +51,7 @@ class Runtime(object):
self.backend = Core()
assert backend_name in self.backend.available_devices, 'The requested device "' + backend_name + '" is not supported!'
- def set_config(self, config: Dict[str, str]) -> None:
+ def set_config(self, config: dict[str, str]) -> None:
"""Set the runtime configuration."""
self.backend.set_property(device_name=self.backend_name, properties=config)
@@ -126,7 +126,7 @@ class Computation(object):
params_string = ", ".join([param.name for param in self.parameters])
return f"<Computation: {self.model.get_name()}({params_string})>"
- def __call__(self, *input_values: NumericData) -> List[NumericData]:
+ def __call__(self, *input_values: NumericData) -> list[NumericData]:
"""Run computation on input values and return result."""
# Input validation
if len(input_values) < len(self.parameters):
diff --git a/src/frontends/onnx/tests/tests_python/test_zoo_models.py b/src/frontends/onnx/tests/tests_python/test_zoo_models.py
index 5edcf67050f..00f4ba34f52 100644
--- a/src/frontends/onnx/tests/tests_python/test_zoo_models.py
+++ b/src/frontends/onnx/tests/tests_python/test_zoo_models.py
@@ -6,7 +6,8 @@ import logging
import pprint
from operator import itemgetter
from pathlib import Path
-from typing import Sequence, Any
+from typing import Any
+from collections.abc import Sequence
import numpy as np
from tests.tests_python.utils import OpenVinoOnnxBackend
diff --git a/src/frontends/onnx/tests/tests_python/utils/__init__.py b/src/frontends/onnx/tests/tests_python/utils/__init__.py
index 9f92d3cca9a..cbb2a6a704b 100644
--- a/src/frontends/onnx/tests/tests_python/utils/__init__.py
+++ b/src/frontends/onnx/tests/tests_python/utils/__init__.py
@@ -3,7 +3,8 @@
# SPDX-License-Identifier: Apache-2.0
from string import ascii_uppercase
-from typing import Any, Dict, Iterable, List, Optional, Text
+from collections.abc import Iterable
+from typing import Any, Optional, Text
import numpy as np
import onnx
@@ -16,7 +17,7 @@ from tests.tests_python.utils.onnx_helpers import import_onnx_model
def run_node(onnx_node, data_inputs, **kwargs):
- # type: (onnx.NodeProto, List[np.ndarray], Dict[Text, Any]) -> List[np.ndarray]
+ # type: (onnx.NodeProto, list[np.ndarray], dict[Text, Any]) -> list[np.ndarray]
"""Convert ONNX node to a graph node and perform computation on input data.
:param onnx_node: ONNX NodeProto describing a computation node
@@ -28,7 +29,7 @@ def run_node(onnx_node, data_inputs, **kwargs):
def run_model(onnx_model, data_inputs):
- # type: (onnx.ModelProto, List[np.ndarray]) -> List[np.ndarray]
+ # type: (onnx.ModelProto, list[np.ndarray]) -> list[np.ndarray]
"""Convert ONNX model to a graph model and perform computation on input data.
:param onnx_model: ONNX ModelProto describing an ONNX model
diff --git a/src/frontends/onnx/tests/tests_python/utils/model_importer.py b/src/frontends/onnx/tests/tests_python/utils/model_importer.py
index d9f5d93982b..92d70e3e9ec 100644
--- a/src/frontends/onnx/tests/tests_python/utils/model_importer.py
+++ b/src/frontends/onnx/tests/tests_python/utils/model_importer.py
@@ -8,25 +8,20 @@ import onnx.backend.test
import unittest
import dataclasses
-from collections import defaultdict, namedtuple
+from collections import defaultdict
+from collections.abc import Callable, Sequence
from onnx import numpy_helper, NodeProto, ModelProto
from onnx.backend.base import Backend, BackendRep
from onnx.backend.test.case.test_case import TestCase as OnnxTestCase
from onnx.backend.test.runner import TestItem
from pathlib import Path
+from re import Pattern
from tests.tests_python.utils.onnx_helpers import import_onnx_model
from typing import (
Any,
- Dict,
- List,
Optional,
- Pattern,
- Set,
Text,
- Type,
Union,
- Callable,
- Sequence,
)
# add post-processing function as part of test data
@@ -38,17 +33,17 @@ ExtOnnxTestCase = dataclasses.make_dataclass(cls_name="TestCaseExt",
class ModelImportRunner(onnx.backend.test.BackendTest):
def __init__(
self,
- backend: Type[Backend],
- models: List[Dict[str, Path]],
+ backend: type[Backend],
+ models: list[dict[str, Path]],
parent_module: Optional[str] = None,
data_root: Optional[Path] = "",
) -> None:
self.backend = backend
self._parent_module = parent_module
- self._include_patterns = set() # type: Set[Pattern[Text]]
- self._exclude_patterns = set() # type: Set[Pattern[Text]]
- self._test_items = defaultdict(dict) # type: Dict[Text, Dict[Text, TestItem]]
- self._xfail_patterns = set() # type: Set[Pattern[Text]]
+ self._include_patterns = set() # type: set[Pattern[Text]]
+ self._exclude_patterns = set() # type: set[Pattern[Text]]
+ self._test_items = defaultdict(dict) # type: dict[Text, dict[Text, TestItem]]
+ self._xfail_patterns = set() # type: set[Pattern[Text]]
strings = [str(data_root), ".onnx", "/", "\\", "-"]
for model in models:
@@ -145,7 +140,7 @@ class ModelImportRunner(onnx.backend.test.BackendTest):
def _add_model_import_test(self, model_test: ExtOnnxTestCase) -> None:
# model is loaded at runtime, note sometimes it could even
# never loaded if the test skipped
- model_marker = [None] # type: List[Optional[Union[ModelProto, NodeProto]]]
+ model_marker = [None] # type: list[Optional[Union[ModelProto, NodeProto]]]
def run_import(test_self: Any, device: Text) -> None:
model = ModelImportRunner._load_onnx_model(model_test.model_dir, model_test.model)
@@ -157,7 +152,7 @@ class ModelImportRunner(onnx.backend.test.BackendTest):
def _add_model_execution_test(self, model_test: ExtOnnxTestCase) -> None:
# model is loaded at runtime, note sometimes it could even
# never loaded if the test skipped
- model_marker = [None] # type: List[Optional[Union[ModelProto, NodeProto]]]
+ model_marker = [None] # type: list[Optional[Union[ModelProto, NodeProto]]]
def run_execution(test_self: Any, device: Text) -> None:
model = ModelImportRunner._load_onnx_model(model_test.model_dir, model_test.model)
diff --git a/src/frontends/onnx/tests/tests_python/utils/onnx_backend.py b/src/frontends/onnx/tests/tests_python/utils/onnx_backend.py
index d64a22ae376..7193b079cf1 100644
--- a/src/frontends/onnx/tests/tests_python/utils/onnx_backend.py
+++ b/src/frontends/onnx/tests/tests_python/utils/onnx_backend.py
@@ -8,7 +8,8 @@ See ONNX documentation for details:
https://github.com/onnx/onnx/blob/master/docs/Implementing%20an%20ONNX%20backend.md
"""
-from typing import Any, Dict, List, Optional, Sequence, Text, Tuple
+from typing import Any, Optional, Text
+from collections.abc import Sequence
import numpy
import onnx
@@ -21,14 +22,14 @@ from tests.tests_python.utils.onnx_helpers import import_onnx_model
class OpenVinoOnnxBackendRep(BackendRep):
- def __init__(self, graph_model, device="CPU"): # type: (List[Model], str) -> None
+ def __init__(self, graph_model, device="CPU"): # type: (list[Model], str) -> None
super().__init__()
self.device = device
self.graph_model = graph_model
self.runtime = get_runtime()
self.computation = self.runtime.computation(graph_model)
- def run(self, inputs, **kwargs): # type: (Any, **Any) -> Tuple[Any, ...]
+ def run(self, inputs, **kwargs): # type: (Any, **Any) -> tuple[Any, ...]
"""Run computation on model."""
return self.computation(*inputs)
@@ -66,7 +67,7 @@ class OpenVinoOnnxBackend(Backend):
inputs, # type: Any
device="CPU", # type: Text
**kwargs, # type: Any
- ): # type: (...) -> Tuple[Any, ...]
+ ): # type: (...) -> tuple[Any, ...]
return cls.prepare(model, device, **kwargs).run(inputs)
@classmethod
@@ -75,14 +76,14 @@ class OpenVinoOnnxBackend(Backend):
node, # type: onnx.NodeProto
inputs, # type: Any
device="CPU", # type: Text
- outputs_info=None, # type: Optional[Sequence[Tuple[numpy.dtype, Tuple[int, ...]]]]
- **kwargs, # type: Dict[Text, Any]
- ): # type: (...) -> Optional[Tuple[Any, ...]]
+ outputs_info=None, # type: Optional[Sequence[tuple[numpy.dtype, tuple[int, ...]]]]
+ **kwargs, # type: dict[Text, Any]
+ ): # type: (...) -> Optional[tuple[Any, ...]]
"""Prepare and run a computation on an ONNX node."""
# default values for input/output tensors
input_tensor_types = [np_dtype_to_tensor_dtype(node_input.dtype) for node_input in inputs]
output_tensor_types = [onnx.TensorProto.FLOAT for _ in range(len(node.output))]
- output_tensor_shapes = [()] # type: List[Tuple[int, ...]]
+ output_tensor_shapes = [()] # type: list[tuple[int, ...]]
if outputs_info is not None:
output_tensor_types = [
diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_deformable_conv.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_deformable_conv.py
index 3c1ab0c9ac8..a1edd815ad4 100644
--- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_deformable_conv.py
+++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_deformable_conv.py
@@ -3,7 +3,6 @@
#
import numpy as np
import sys
-from typing import List
from save_model import saveModel
diff --git a/tests/e2e_tests/common/logger.py b/tests/e2e_tests/common/logger.py
index 7b48eaf05be..1970ba73df7 100644
--- a/tests/e2e_tests/common/logger.py
+++ b/tests/e2e_tests/common/logger.py
@@ -9,7 +9,8 @@ import os
import re
import weakref
from datetime import datetime
-from typing import cast, List, Union, Tuple, Generator
+from typing import cast, Union
+from collections.abc import Generator
from e2e_tests.common import config
@@ -40,7 +41,7 @@ class Chunks(Generator):
generator yielding tuple: no of part, number of parts, and part of the input list
"""
- def __init__(self, seq: List[str], max_number_of_elements: int = 1000) -> None:
+ def __init__(self, seq: list[str], max_number_of_elements: int = 1000) -> None:
super().__init__()
self.seq = tuple(seq)
assert max_number_of_elements > 0, "Incorrect number of elements, should be more than zero"
@@ -49,13 +50,13 @@ class Chunks(Generator):
self.current_chunk = 0
self.index_iterator = iter(range(0, len(self.seq), self.chunk_len))
- def __next__(self) -> Tuple[int, int, list]:
+ def __next__(self) -> tuple[int, int, list]:
return self.send(None)
def __iter__(self) -> 'Chunks':
return self
- def send(self, ignored_value) -> Tuple[int, int, list]:
+ def send(self, ignored_value) -> tuple[int, int, list]:
index = next(self.index_iterator)
return_chunk = self.current_chunk, self.no_of_chunks, list(self.seq[index:index + self.chunk_len])
self.current_chunk += 1
@@ -166,7 +167,7 @@ class Logger(logging.Logger):
return record
def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False,
- list_of_strings: List[str] = None,
+ list_of_strings: list[str] = None,
chunk_len: int = 1000,
chunk_msg: str = None,
final_msg: str = None):
@@ -182,7 +183,7 @@ class Logger(logging.Logger):
return super().findCaller(stack_info=stack_info)
def log_list_of_strings(self, level, chunk_msg, args, exc_info=None, extra=None, stack_info=False,
- list_of_strings: List[str] = None,
+ list_of_strings: list[str] = None,
chunk_len: int = 1000,
final_msg: str = None):
fn, lno, func, sinfo = self.findCaller(stack_info=stack_info)
diff --git a/tests/e2e_tests/common/multiprocessing_utils.py b/tests/e2e_tests/common/multiprocessing_utils.py
index 64b0290381f..a8d445e0669 100644
--- a/tests/e2e_tests/common/multiprocessing_utils.py
+++ b/tests/e2e_tests/common/multiprocessing_utils.py
@@ -10,7 +10,8 @@ import traceback
from logging.handlers import QueueHandler
from multiprocessing import Process, Queue, TimeoutError, ProcessError
from queue import Empty as QueueEmpty
-from typing import Callable, Union
+from typing import Union
+from collections.abc import Callable
if platform.system() == "Darwin":
# Fix for MacOS
diff --git a/tests/layer_tests/common/utils/multiprocessing_utils.py b/tests/layer_tests/common/utils/multiprocessing_utils.py
index ab508ea61ab..23a5c4d02f5 100644
--- a/tests/layer_tests/common/utils/multiprocessing_utils.py
+++ b/tests/layer_tests/common/utils/multiprocessing_utils.py
@@ -9,7 +9,8 @@ import sys
import traceback
from multiprocessing import Process, Queue, TimeoutError, ProcessError
from queue import Empty as QueueEmpty
-from typing import Callable, Union
+from typing import Union
+from collections.abc import Callable
if platform.system() == "Darwin":
# Fix for MacOS
diff --git a/tests/layer_tests/ovc_python_api_tests/test_pytorch.py b/tests/layer_tests/ovc_python_api_tests/test_pytorch.py
index 9bd9ccda103..8b70da3f0ba 100644
--- a/tests/layer_tests/ovc_python_api_tests/test_pytorch.py
+++ b/tests/layer_tests/ovc_python_api_tests/test_pytorch.py
@@ -4,7 +4,6 @@
import os
import tempfile
import unittest
-from typing import Tuple, List
import numpy as np
import pytest
@@ -736,7 +735,7 @@ def create_pytorch_module_with_compressed_int8_constant(tmp_dir):
def create_pytorch_module_with_nested_inputs(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, z: Tuple[torch.Tensor, torch.Tensor]):
+ def forward(self, z: tuple[torch.Tensor, torch.Tensor]):
z1, z2 = z
zeros1 = torch.zeros((1, 1))
zeros2 = torch.zeros((1, 5, 1))
@@ -761,7 +760,7 @@ def create_pytorch_module_with_nested_inputs(tmp_dir):
def create_pytorch_module_with_nested_inputs_compress_to_fp16_default(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, z: Tuple[torch.Tensor, torch.Tensor]):
+ def forward(self, z: tuple[torch.Tensor, torch.Tensor]):
z1, z2 = z
zeros1 = torch.zeros((1, 1))
zeros2 = torch.zeros((1, 5, 1))
@@ -787,7 +786,7 @@ def create_pytorch_module_with_nested_inputs_compress_to_fp16_default(tmp_dir):
def create_pytorch_module_with_nested_inputs2(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor]):
+ def forward(self, x: torch.Tensor, z: tuple[torch.Tensor, torch.Tensor]):
z1, z2 = z
zeros1 = torch.zeros((1, 1))
zeros2 = torch.zeros((1, 5, 1))
@@ -815,7 +814,7 @@ def create_pytorch_module_with_nested_inputs2(tmp_dir):
def create_pytorch_module_with_nested_inputs3(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, z: Tuple[torch.Tensor, torch.Tensor], x: torch.Tensor):
+ def forward(self, z: tuple[torch.Tensor, torch.Tensor], x: torch.Tensor):
z1, z2 = z
zeros1 = torch.zeros((1, 1))
zeros2 = torch.zeros((1, 5, 1))
@@ -843,7 +842,7 @@ def create_pytorch_module_with_nested_inputs3(tmp_dir):
def create_pytorch_module_with_nested_inputs4(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor], y: torch.Tensor):
+ def forward(self, x: torch.Tensor, z: tuple[torch.Tensor, torch.Tensor], y: torch.Tensor):
z1, z2 = z
zeros1 = torch.zeros((1, 1))
zeros2 = torch.zeros((1, 5, 1))
@@ -874,7 +873,7 @@ def create_pytorch_module_with_nested_inputs4(tmp_dir):
def create_pytorch_module_with_nested_inputs5(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, x: torch.Tensor, z: Tuple[torch.Tensor, torch.Tensor], y: torch.Tensor):
+ def forward(self, x: torch.Tensor, z: tuple[torch.Tensor, torch.Tensor], y: torch.Tensor):
z1, z2 = z
zeros1 = torch.zeros((1, 1))
zeros2 = torch.zeros((1, 5, 1))
@@ -904,7 +903,7 @@ def create_pytorch_module_with_nested_inputs5(tmp_dir):
def create_pytorch_module_with_nested_inputs6(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, x: torch.Tensor, y: torch.Tensor = None, z: Tuple[torch.Tensor, torch.Tensor] = None):
+ def forward(self, x: torch.Tensor, y: torch.Tensor = None, z: tuple[torch.Tensor, torch.Tensor] = None):
z1, z2 = z
zeros1 = torch.zeros((1, 1))
zeros2 = torch.zeros((1, 5, 1))
@@ -933,7 +932,7 @@ def create_pytorch_module_with_nested_inputs6(tmp_dir):
def create_pytorch_module_with_nested_list_and_single_input(tmp_dir):
class PTModel(torch.nn.Module):
- def forward(self, x: List[torch.Tensor]):
+ def forward(self, x: list[torch.Tensor]):
x0 = x[0]
x0 = torch.cat([x0, torch.zeros(1, 1)], 1)
return x0 + torch.ones((1, 1))
diff --git a/tests/layer_tests/py_frontend_tests/test_torch_decoder.py b/tests/layer_tests/py_frontend_tests/test_torch_decoder.py
index d072b5d9f6f..452ffaf9525 100644
--- a/tests/layer_tests/py_frontend_tests/test_torch_decoder.py
+++ b/tests/layer_tests/py_frontend_tests/test_torch_decoder.py
@@ -658,11 +658,11 @@ def test_pytorch_decoder_can_convert_float_scalar_tensor():
def test_pytorch_decoder_can_convert_tensor_list():
from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
from openvino import PartialShape, Type
- from typing import List, Optional
+ from typing import Optional
class SomeTensor(torch.nn.Module):
def forward(self):
- l = torch.jit.annotate(List[Optional[torch.Tensor]], [
+ l = torch.jit.annotate(list[Optional[torch.Tensor]], [
torch.ones((1, 3, 3), dtype=torch.float),])
return l
@@ -695,11 +695,11 @@ def test_pytorch_decoder_can_convert_tensor_list():
@pytest.mark.precommit
def test_pytorch_decoder_can_convert_tensor_list_empty():
from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
- from typing import List, Optional
+ from typing import Optional
class SomeTensor(torch.nn.Module):
def forward(self):
- l = torch.jit.annotate(List[Optional[torch.Tensor]], [])
+ l = torch.jit.annotate(list[Optional[torch.Tensor]], [])
return l
model = get_scripted_model(SomeTensor())
diff --git a/tests/layer_tests/pytorch_tests/test_dict.py b/tests/layer_tests/pytorch_tests/test_dict.py
index 63f5d03e39a..30834d6bcbc 100644
--- a/tests/layer_tests/pytorch_tests/test_dict.py
+++ b/tests/layer_tests/pytorch_tests/test_dict.py
@@ -5,7 +5,6 @@ import numpy as np
import platform
import pytest
import torch
-from typing import Dict
from pytorch_layer_test_class import PytorchLayerTest
@@ -30,12 +29,12 @@ class TestDict(PytorchLayerTest):
class aten_dict_with_types(torch.nn.Module):
- def forward(self, x_dict: Dict[str, torch.Tensor]):
+ def forward(self, x_dict: dict[str, torch.Tensor]):
return x_dict["x1"].to(torch.float32) + x_dict["x2"].to(torch.float32)
class aten_dict_no_types(torch.nn.Module):
- def forward(self, x_dict: Dict[str, torch.Tensor]):
+ def forward(self, x_dict: dict[str, torch.Tensor]):
return x_dict["x1"] + x_dict["x2"]
diff --git a/tests/layer_tests/pytorch_tests/test_listunpack.py b/tests/layer_tests/pytorch_tests/test_listunpack.py
index fff3ad115b5..27dd1d46321 100644
--- a/tests/layer_tests/pytorch_tests/test_listunpack.py
+++ b/tests/layer_tests/pytorch_tests/test_listunpack.py
@@ -1,7 +1,6 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import List
import numpy as np
import pytest
@@ -69,7 +68,7 @@ class TestListUnpack(PytorchLayerTest):
super(prim_listunpack, self).__init__()
def forward(self, in1, in2, in3, in4):
- items: List[List[int]] = []
+ items: list[list[int]] = []
items.append(in1.size())
items.append(in2.size())
items.append(in3.size())
@@ -238,11 +237,10 @@ class TestListUnpackParameterSingle(PytorchLayerTest):
def create_model(self):
import torch
- from typing import List
class model(torch.nn.Module):
- def forward(self, x: List[torch.Tensor]):
+ def forward(self, x: list[torch.Tensor]):
x1, x2 = x
return x1, x2
@@ -265,11 +263,10 @@ class TestListUnpackParameterSingleMixed(PytorchLayerTest):
def create_model(self):
import torch
- from typing import List
class model(torch.nn.Module):
- def forward(self, y1, x: List[torch.Tensor], y2):
+ def forward(self, y1, x: list[torch.Tensor], y2):
x1, x2 = x
return x1, x2, y1, y2
@@ -288,11 +285,10 @@ class TestListUnpackParameterNested(PytorchLayerTest):
def create_model(self):
import torch
- from typing import List
class model(torch.nn.Module):
- def forward(self, x: List[List[torch.Tensor]]):
+ def forward(self, x: list[list[torch.Tensor]]):
x1, x2 = x
y1, y2 = x1
y3, y4 = x2
@@ -313,11 +309,10 @@ class TestListUnpackParameterMultiple(PytorchLayerTest):
def create_model(self):
import torch
- from typing import List
class model(torch.nn.Module):
- def forward(self, x: List[torch.Tensor], y: List[torch.Tensor]):
+ def forward(self, x: list[torch.Tensor], y: list[torch.Tensor]):
z1, z2 = x
z3, z4 = y
return z1, z2, z3, z4
diff --git a/tests/layer_tests/pytorch_tests/test_set_item.py b/tests/layer_tests/pytorch_tests/test_set_item.py
index ec5d709a9bb..866b55cb82a 100644
--- a/tests/layer_tests/pytorch_tests/test_set_item.py
+++ b/tests/layer_tests/pytorch_tests/test_set_item.py
@@ -14,14 +14,13 @@ class TestSetItem(PytorchLayerTest):
def create_model(self, idx):
import torch
- from typing import List
class aten_set_item(torch.nn.Module):
def __init__(self, idx):
super(aten_set_item, self).__init__()
self.idx = idx
- def forward(self, x: List[int]):
+ def forward(self, x: list[int]):
x[self.idx] = 0
return torch.tensor(x).to(torch.int)
diff --git a/tests/layer_tests/pytorch_tests/test_tuple_construct.py b/tests/layer_tests/pytorch_tests/test_tuple_construct.py
index 8777c4f342c..acd2fafa915 100644
--- a/tests/layer_tests/pytorch_tests/test_tuple_construct.py
+++ b/tests/layer_tests/pytorch_tests/test_tuple_construct.py
@@ -97,11 +97,10 @@ class TestTupleUnpackParameterSingle(PytorchLayerTest):
def create_model(self):
import torch
- from typing import Tuple
class model(torch.nn.Module):
- def forward(self, x: Tuple[torch.Tensor, torch.Tensor]):
+ def forward(self, x: tuple[torch.Tensor, torch.Tensor]):
x1, x2 = x
return x1, x2
@@ -124,11 +123,10 @@ class TestTupleUnpackParameterSingleMixed(PytorchLayerTest):
def create_model(self):
import torch
- from typing import Tuple
class model(torch.nn.Module):
- def forward(self, y1, x: Tuple[torch.Tensor, torch.Tensor], y2):
+ def forward(self, y1, x: tuple[torch.Tensor, torch.Tensor], y2):
x1, x2 = x
return x1, x2, y1, y2
@@ -147,11 +145,10 @@ class TestTupleUnpackParameterNested(PytorchLayerTest):
def create_model(self):
import torch
- from typing import Tuple
class model(torch.nn.Module):
- def forward(self, x: Tuple[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor, torch.Tensor]]):
+ def forward(self, x: tuple[tuple[torch.Tensor, torch.Tensor], tuple[torch.Tensor, torch.Tensor]]):
x1, x2 = x
y1, y2 = x1
y3, y4 = x2
@@ -172,11 +169,10 @@ class TestTupleUnpackParameterMultiple(PytorchLayerTest):
def create_model(self):
import torch
- from typing import Tuple
class model(torch.nn.Module):
- def forward(self, x: Tuple[torch.Tensor, torch.Tensor], y: Tuple[torch.Tensor, torch.Tensor]):
+ def forward(self, x: tuple[torch.Tensor, torch.Tensor], y: tuple[torch.Tensor, torch.Tensor]):
z1, z2 = x
z3, z4 = y
return z1, z2, z3, z4
@@ -194,13 +190,12 @@ class TestTupleIndex(PytorchLayerTest):
def create_model(self):
import torch
- from typing import Tuple
class model(torch.nn.Module):
def forward(self, x):
return self.some_func((x, x))
- def some_func(self, x: Tuple[torch.Tensor, torch.Tensor]):
+ def some_func(self, x: tuple[torch.Tensor, torch.Tensor]):
return x[1] * 2, x[0] * 3
return model(), None, "prim::TupleIndex"
@@ -217,13 +212,12 @@ class TestTcOutsideTuInsideIfBody(PytorchLayerTest):
def create_model(self):
import torch
- from typing import Tuple
class model(torch.nn.Module):
def forward(self, x, y):
return self.some_func((x, y))
- def some_func(self, x: Tuple[torch.Tensor, torch.Tensor]):
+ def some_func(self, x: tuple[torch.Tensor, torch.Tensor]):
if x[0].numel() > 10:
n, m = x
return n * m
diff --git a/tests/model_hub_tests/models_hub_common/multiprocessing_utils.py b/tests/model_hub_tests/models_hub_common/multiprocessing_utils.py
index e99b36fcc70..fab4d65e4d1 100644
--- a/tests/model_hub_tests/models_hub_common/multiprocessing_utils.py
+++ b/tests/model_hub_tests/models_hub_common/multiprocessing_utils.py
@@ -8,7 +8,8 @@ import sys
import traceback
from multiprocessing import Process, Queue, TimeoutError, ProcessError
from queue import Empty as QueueEmpty
-from typing import Callable, Union
+from typing import Union
+from collections.abc import Callable
def _mp_wrapped_func(func: Callable, func_args: list, queue: Queue, logger_queue: Queue):
diff --git a/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py b/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py
index 026ed9394aa..2912b2a961a 100644
--- a/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py
+++ b/tests/model_hub_tests/transformation_tests/generate_ref_diffs.py
@@ -44,11 +44,11 @@ from openvino._offline_transformations import paged_attention_transformation
from openvino._pyopenvino.op import _PagedAttentionExtension, Parameter, Result
from optimum.intel import OVModelForCausalLM
from optimum.intel.openvino import OVModelForVisualCausalLM
-from typing import Type, Union
+from typing import Union
nodes_to_compare = ("ScaledDotProductAttention", "PagedAttentionExtension", "Parameter", "ReadValue", "Assign")
-def get_models_list_type(file_name: str, cls: Union[Type[OVModelForCausalLM], Type[OVModelForVisualCausalLM]]):
+def get_models_list_type(file_name: str, cls: Union[type[OVModelForCausalLM], type[OVModelForVisualCausalLM]]):
models = []
for line_items in utils.parse_list_file(file_name):
if len(line_items) == 2:
diff --git a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py b/tests/model_hub_tests/transformation_tests/test_pa_transformation.py
index c91f3e227fa..ce6f9be75f1 100644
--- a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py
+++ b/tests/model_hub_tests/transformation_tests/test_pa_transformation.py
@@ -5,7 +5,7 @@ from openvino._offline_transformations import paged_attention_transformation
from openvino._pyopenvino.op import _PagedAttentionExtension
from optimum.intel import OVModelForCausalLM
from optimum.intel.openvino import OVModelForVisualCausalLM
-from typing import Type, Union
+from typing import Union
import openvino as ov
from models_hub_common.utils import retry
import models_hub_common.utils as utils
@@ -108,7 +108,7 @@ def apply_transformation_and_compare_diffs(ov_model: ov.Model,
def run_pa(tmp_path,
model_id,
model_link,
- cls: Union[Type[OVModelForCausalLM], Type[OVModelForVisualCausalLM]],
+ cls: Union[type[OVModelForCausalLM], type[OVModelForVisualCausalLM]],
use_block_indices_inputs,
use_score_outputs,
allow_score_aggregation,
diff --git a/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py b/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py
index 6d4fb66b3fe..2033ee5ec13 100644
--- a/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py
+++ b/tools/benchmark_tool/openvino/tools/benchmark/utils/inputs_filling.py
@@ -4,7 +4,6 @@
import os
import sys
import re
-from typing import Dict, List
import numpy as np
from collections import defaultdict
from pathlib import Path
@@ -68,7 +67,7 @@ def get_group_batch_sizes(app_input_info):
return batch_sizes
-def get_batch_sizes_per_input_map(app_input_info: List[AppInputInfo]):
+def get_batch_sizes_per_input_map(app_input_info: list[AppInputInfo]):
batch_sizes_map = {}
for info in app_input_info:
if info.layout.has_name('N'):
@@ -80,7 +79,7 @@ def get_batch_sizes_per_input_map(app_input_info: List[AppInputInfo]):
batch_sizes_map[info.name] = [1] * len(info.shapes)
return batch_sizes_map
-def verify_objects_to_be_used(objects_to_be_used_map: Dict[str, List[str]], info: AppInputInfo, total_frames: int, input_type_name: str):
+def verify_objects_to_be_used(objects_to_be_used_map: dict[str, list[str]], info: AppInputInfo, total_frames: int, input_type_name: str):
if objects_to_be_used_map[info.name] > total_frames and objects_to_be_used_map[info.name] % total_frames != 0:
objects_to_be_used_map[info.name] = objects_to_be_used_map[info.name] - objects_to_be_used_map[info.name] % total_frames
logger.warning(f"Number of provided {input_type_name} for input '{info.name}' is not a multiple of the number of "
@@ -144,7 +143,7 @@ def get_input_data(paths_to_input, app_input_info):
return DataQueue(data, get_group_batch_sizes(app_input_info))
-def get_image_tensors(image_paths: List[str], info: AppInputInfo, batch_sizes: List[int]) -> List[Tensor]:
+def get_image_tensors(image_paths: list[str], info: AppInputInfo, batch_sizes: list[int]) -> list[Tensor]:
if 'cv2' not in sys.modules:
logger.error("Loading images requires the opencv-python or opencv-python-headless package. "
"Please install it before continuing or run benchmark without "
@@ -215,7 +214,7 @@ def get_image_tensors(image_paths: List[str], info: AppInputInfo, batch_sizes: L
return tensors
-def get_numpy_tensors(numpy_paths: List[str], info: AppInputInfo, batch_sizes: List[int]) -> List[Tensor]:
+def get_numpy_tensors(numpy_paths: list[str], info: AppInputInfo, batch_sizes: list[int]) -> list[Tensor]:
num_shapes = len(info.shapes)
num_arrays = len(numpy_paths)
@@ -283,7 +282,7 @@ def get_numpy_tensors(numpy_paths: List[str], info: AppInputInfo, batch_sizes: L
return tensors
-def get_binary_tensors(binary_paths: List[str], info: AppInputInfo, batch_sizes: List[int]) -> List[Tensor]:
+def get_binary_tensors(binary_paths: list[str], info: AppInputInfo, batch_sizes: list[int]) -> list[Tensor]:
num_shapes = len(info.shapes)
num_binaries = len(binary_paths)
niter = max(num_shapes, num_binaries)
diff --git a/tools/benchmark_tool/openvino/tools/benchmark/utils/statistics_report.py b/tools/benchmark_tool/openvino/tools/benchmark/utils/statistics_report.py
index 2715fd7486e..0a010a8e92f 100644
--- a/tools/benchmark_tool/openvino/tools/benchmark/utils/statistics_report.py
+++ b/tools/benchmark_tool/openvino/tools/benchmark/utils/statistics_report.py
@@ -8,7 +8,7 @@ import csv
import numpy as np
from enum import Enum
from datetime import timedelta
-from typing import Dict, List, Tuple, Any
+from typing import Any
from .logging import logger
## statistics reports types
@@ -164,7 +164,7 @@ class JsonStatisticsReport(StatisticsReport):
StatisticsReport.__init__(self, config)
def dump(self):
- def list_to_dict(parameters: List[Tuple[str, str]]) -> Dict[str, str]:
+ def list_to_dict(parameters: list[tuple[str, str]]) -> dict[str, str]:
return {key: value for key, value in parameters}
filename = os.path.join(self.config.report_folder, 'benchmark_report.json')
@@ -185,7 +185,7 @@ class JsonStatisticsReport(StatisticsReport):
json.dump(json_statistics, file)
logger.info(f"Statistics report is stored to {file.name}")
- def dump_performance_counters(self, prof_info_list: List[List[Any]]): #ProfilingInfo
+ def dump_performance_counters(self, prof_info_list: list[list[Any]]): #ProfilingInfo
def profiling_info_to_dict_list(prof_info_list):
profiling_info_json_list = [0]*len(prof_info_list)
@@ -259,7 +259,7 @@ class JsonStatisticsReport(StatisticsReport):
logger.info(f'Performance counters report is stored to {filename}')
def dump_performance_counters_sorted(self, prof_sorted_info) -> None:
- def profiling_info_to_dict_list(prof_info_matrix: np.ndarray) -> List[Dict[str, str]]:
+ def profiling_info_to_dict_list(prof_info_matrix: np.ndarray) -> list[dict[str, str]]:
total, total_cpu = 0, 0
nodes_info_list = [0]*len(prof_info_matrix)
diff --git a/tools/ovc/openvino/tools/ovc/cli_parser.py b/tools/ovc/openvino/tools/ovc/cli_parser.py
index cad0b81e39f..bb4d1d4debe 100644
--- a/tools/ovc/openvino/tools/ovc/cli_parser.py
+++ b/tools/ovc/openvino/tools/ovc/cli_parser.py
@@ -7,7 +7,7 @@ import os
import pathlib
import re
from collections import OrderedDict, namedtuple
-from typing import List, Union
+from typing import Union
import openvino
from openvino import PartialShape, Dimension, Type # pylint: disable=no-name-in-module,import-error
@@ -202,8 +202,8 @@ def get_mo_convert_params():
return mo_convert_params
-def canonicalize_and_check_paths(values: Union[str, List[str], None], param_name,
- try_mo_root=False, check_existence=True) -> List[str]:
+def canonicalize_and_check_paths(values: Union[str, list[str], None], param_name,
+ try_mo_root=False, check_existence=True) -> list[str]:
if values is not None:
list_of_values = list()
if isinstance(values, str):
diff --git a/tools/ovc/openvino/tools/ovc/convert_impl.py b/tools/ovc/openvino/tools/ovc/convert_impl.py
index d699276d19a..1b62d0e6512 100644
--- a/tools/ovc/openvino/tools/ovc/convert_impl.py
+++ b/tools/ovc/openvino/tools/ovc/convert_impl.py
@@ -10,7 +10,7 @@ import traceback
import tracemalloc
from collections import OrderedDict
from pathlib import Path
-from typing import Iterable, Callable
+from collections.abc import Callable, Iterable
try:
import openvino_telemetry as tm
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py
index 4d89b67eb06..07471204329 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py
@@ -1,7 +1,7 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import Callable
+from collections.abc import Callable
from openvino import PartialShape # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.error import Error
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py b/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py
index ee85c57302e..b2544a6ba71 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py
@@ -1,8 +1,6 @@
# Copyright (C) 2018-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-from typing import List
-
from openvino.tools.ovc.error import Error
@@ -89,7 +87,7 @@ def apply_user_transformations(func: object, transforms: list):
available_transformations[name](func, **args)
-def apply_moc_legacy_transformations(func: object, params_with_custom_types: List[str]):
+def apply_moc_legacy_transformations(func: object, params_with_custom_types: list[str]):
from openvino._offline_transformations import \
apply_moc_legacy_transformations # pylint: disable=import-error,no-name-in-module
apply_moc_legacy_transformations(func, params_with_custom_types)
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py b/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py
index b8702dd59be..af052229a5c 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py
@@ -4,7 +4,6 @@
import argparse
import logging as log
import sys
-from typing import List
import numpy as np
import os
@@ -37,7 +36,7 @@ def get_enabled_and_disabled_transforms():
return enabled_transforms, disabled_transforms
-def raise_exception_for_input_output_cut(model_inputs_or_outputs: List[Place], new_nodes: List[dict], is_input: bool):
+def raise_exception_for_input_output_cut(model_inputs_or_outputs: list[Place], new_nodes: list[dict], is_input: bool):
for new_node in new_nodes:
node = new_node['node']
@@ -81,11 +80,11 @@ def moc_pipeline(argv: argparse.Namespace, moc_front_end: FrontEnd):
# a model is not processed further in json analysis mode
sys.exit(0)
- def check_places_are_same(places_original: List[Place], places_new: List[Place]):
+ def check_places_are_same(places_original: list[Place], places_new: list[Place]):
"""
Check if set of new places is same as original or not.
- :param places_original: List[Place] Original model places
- :param places_new: List[Place] New list of places
+ :param places_original: list[Place] Original model places
+ :param places_new: list[Place] New list of places
:return: True if new list of places is same as original
"""
return len(places_original) == len(places_new) and len(
@@ -150,7 +149,7 @@ def moc_pipeline(argv: argparse.Namespace, moc_front_end: FrontEnd):
input_model, argv.placeholder_shapes, argv.placeholder_data_types,
argv.output, {}, moc_front_end.get_name())
- def add_names_to_tensors(model: InputModel, places: List[Place]):
+ def add_names_to_tensors(model: InputModel, places: list[Place]):
"""
Adds additional names to some model input tensors. This helper should be used
when a model modification is going to happen.
diff --git a/tools/ovc/openvino/tools/ovc/utils.py b/tools/ovc/openvino/tools/ovc/utils.py
index 56125db1de7..d158c7d238c 100644
--- a/tools/ovc/openvino/tools/ovc/utils.py
+++ b/tools/ovc/openvino/tools/ovc/utils.py
@@ -7,7 +7,8 @@ import numpy as np
import os
import sys
from openvino.tools.ovc.error import Error
-from typing import Iterable, Union
+from collections.abc import Iterable
+from typing import Union
try:
import openvino_telemetry as tm