Skip to content

Commit 6818286

Browse files
committed
update other py files in repo
1 parent 63f1b5d commit 6818286

File tree

31 files changed

+105
-128
lines changed

31 files changed

+105
-128
lines changed

.github/actions/create_manifest/manifest_manager.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import yaml
77
from pathlib import Path
88
from copy import deepcopy
9-
from typing import Optional, Dict, List, Union, Iterator, Any
9+
from typing import Optional, Union, Any
10+
from collections.abc import Iterator
1011

1112

1213
class ManifestException(Exception):
@@ -43,7 +44,7 @@ def __init__(self, manifest_path: Optional[str] = None):
4344
self._manifest_file = self._manifest_file / self.default_manifest_name
4445

4546
self._manifest_version = "1.0"
46-
self._components: Dict[str, Component] = {}
47+
self._components: dict[str, Component] = {}
4748

4849
if manifest_path is not None:
4950
self._prepare_manifest()
@@ -81,7 +82,7 @@ def version(self) -> str:
8182
return self._manifest_version
8283

8384
@property
84-
def components(self) -> List[Component]:
85+
def components(self) -> list[Component]:
8586
return list(self._components.values())
8687

8788
def get_component(self, component_name: str) -> Optional[Component]:
@@ -131,7 +132,7 @@ def write_line_break(self, data=None):
131132
except Exception as ex:
132133
raise ManifestSavingError(ex) from ex
133134

134-
def as_dict(self) -> Dict[str, Union[str, Dict]]:
135+
def as_dict(self) -> dict[str, Union[str, dict]]:
135136
"""Return manifest as dictionary"""
136137
if not self._manifest_file.is_file():
137138
raise ManifestDoesNotExist(f'Cannot find manifest "{self._manifest_file}"')
@@ -204,7 +205,7 @@ def __init__(
204205
205206
:param name: Name of component
206207
:param version: Version of component
207-
:param repositories: List of repositories
208+
:param repositories: list of repositories
208209
:param product_type: Unique key to describe a product type (can include OS, arch, build variant, etc)
209210
:param target_arch: Target architecture
210211
:param build_type: Type of build (release, debug)
@@ -303,7 +304,7 @@ def build_event(self) -> str:
303304
return self._build_event
304305

305306
@property
306-
def repositories(self) -> List[Repository]:
307+
def repositories(self) -> list[Repository]:
307308
return list(self._repositories.values())
308309

309310
@property

.github/actions/validate_pyi_files/compare_pyi_files.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sys
99
import filecmp
1010
import difflib
11-
from typing import List, Set
1211

1312
# Due to numerous issues with stub generation reproducibility we need some skips.
1413
# The inconsistencies between generations most likely come from different environment/CMake setups.
@@ -21,9 +20,9 @@
2120
"openvino/tools/ovc/moc_frontend/extractor.pyi"
2221
]
2322

24-
def find_pyi_files(directory: str) -> Set[str]:
23+
def find_pyi_files(directory: str) -> set[str]:
2524
"""Recursively find all .pyi files in a directory."""
26-
pyi_files: List[str] = []
25+
pyi_files: list[str] = []
2726
for root, _, files in os.walk(directory):
2827
for file in files:
2928
if file.endswith(".pyi"):
@@ -35,8 +34,8 @@ def find_pyi_files(directory: str) -> Set[str]:
3534
def compare_pyi_files(generated_dir: str, committed_dir: str) -> None:
3635
"""Compare .pyi files between two directories."""
3736
# Find all .pyi files in both directories
38-
generated_files: Set[str] = find_pyi_files(generated_dir)
39-
committed_files: Set[str] = find_pyi_files(committed_dir)
37+
generated_files: set[str] = find_pyi_files(generated_dir)
38+
committed_files: set[str] = find_pyi_files(committed_dir)
4039

4140
# Assert that the number of .pyi files matches
4241
if len(generated_files) != len(committed_files):

.github/github_org_control/github_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
import re
1111
import sys
12-
import time
13-
import typing
12+
import time
1413
from pathlib import Path
14+
from collections.abc import Iterable
1515

1616
from github import Github, GithubException, RateLimitExceededException, IncompletableObject
1717
from github.PaginatedList import PaginatedList
@@ -317,7 +317,7 @@ def get_valid_github_users(self, emails):
317317

318318
def invite_users(self, users):
319319
"""Invites users to GitHub organization and prints status"""
320-
if not isinstance(users, typing.Iterable):
320+
if not isinstance(users, Iterable):
321321
users = [users]
322322
print(f"\nInvite {len(users)} users:")
323323

@@ -341,7 +341,7 @@ def invite_users(self, users):
341341

342342
def remove_users(self, users):
343343
"""Removes users from GitHub organization"""
344-
if not isinstance(users, typing.Iterable):
344+
if not isinstance(users, Iterable):
345345
users = [users]
346346
print(f"\nRemove {len(users)} users:")
347347

docs/openvino_sphinx_theme/openvino_sphinx_theme/directives/code.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import os.path
2-
from pathlib import Path
3-
import sys
42
from sphinx.directives.code import LiteralInclude, LiteralIncludeReader, container_wrapper
53
from sphinx.util import logging
64
from docutils.parsers.rst import Directive, directives
7-
from typing import List, Tuple
85
from docutils.nodes import Node
96
from docutils import nodes
107
from sphinx.util import parselinenos
11-
import requests
12-
import re
13-
import json
148
import html
159
import csv
1610

@@ -21,7 +15,7 @@ class DoxygenSnippet(LiteralInclude):
2115

2216
option_spec = dict({'fragment': directives.unchanged_required}, **LiteralInclude.option_spec)
2317

24-
def run(self) -> List[Node]:
18+
def run(self) -> list[Node]:
2519
if 'fragment' in self.options:
2620
self.options['start-after'] = self.options['fragment']
2721
self.options['end-before'] = self.options['fragment']
@@ -152,7 +146,7 @@ class DataTable(Directive):
152146
'data-order': directives.unchanged
153147
}
154148

155-
def run(self) -> List[Node]:
149+
def run(self) -> list[Node]:
156150
current_directory = os.path.dirname(os.path.abspath(self.state.document.current_source))
157151
csv_file = os.path.normpath(os.path.join(current_directory, self.options['file']))
158152
if os.path.isfile(csv_file) is False:

samples/python/model_creation_sample/model_creation_sample.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: Apache-2.0
55
import logging as log
66
import sys
7-
import typing
87
from functools import reduce
98

109
import numpy as np
@@ -17,7 +16,7 @@
1716
def create_model(model_path: str) -> ov.Model:
1817
"""Create a model on the fly from the source code using openvino."""
1918

20-
def shape_and_length(shape: list) -> typing.Tuple[list, int]:
19+
def shape_and_length(shape: list) -> tuple[list, int]:
2120
length = reduce(lambda x, y: x * y, shape)
2221
return shape, length
2322

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import sys
77
import errno
88
import subprocess # nosec
9-
import typing
109
import platform
1110
import re
1211
import shutil
@@ -791,7 +790,7 @@ def concat_files(input_files, output_file):
791790
os.makedirs(PACKAGE_DIR, exist_ok=True)
792791

793792
packages = find_namespace_packages(PACKAGE_DIR)
794-
package_data: typing.Dict[str, list] = {}
793+
package_data: dict[str, list] = {}
795794
ext_modules = find_prebuilt_extensions(get_install_dirs_list(PY_INSTALL_CFG))
796795
entry_points = find_entry_points(PY_INSTALL_CFG)
797796

src/frontends/onnx/tests/runtime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""Provide a layer of abstraction for an OpenVINO runtime environment."""
66

77
import logging
8-
from typing import Dict, List, Union
8+
from typing import Union
99

1010
import numpy as np
1111

@@ -51,7 +51,7 @@ def __init__(self, backend_name: str) -> None:
5151
self.backend = Core()
5252
assert backend_name in self.backend.available_devices, 'The requested device "' + backend_name + '" is not supported!'
5353

54-
def set_config(self, config: Dict[str, str]) -> None:
54+
def set_config(self, config: dict[str, str]) -> None:
5555
"""Set the runtime configuration."""
5656
self.backend.set_property(device_name=self.backend_name, properties=config)
5757

@@ -126,7 +126,7 @@ def __repr__(self) -> str:
126126
params_string = ", ".join([param.name for param in self.parameters])
127127
return f"<Computation: {self.model.get_name()}({params_string})>"
128128

129-
def __call__(self, *input_values: NumericData) -> List[NumericData]:
129+
def __call__(self, *input_values: NumericData) -> list[NumericData]:
130130
"""Run computation on input values and return result."""
131131
# Input validation
132132
if len(input_values) < len(self.parameters):

src/frontends/onnx/tests/tests_python/test_zoo_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import pprint
77
from operator import itemgetter
88
from pathlib import Path
9-
from typing import Sequence, Any
9+
from typing import Any
10+
from collections.abc import Sequence
1011
import numpy as np
1112

1213
from tests.tests_python.utils import OpenVinoOnnxBackend

src/frontends/onnx/tests/tests_python/utils/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
from string import ascii_uppercase
6-
from typing import Any, Dict, Iterable, List, Optional, Text
6+
from collections.abc import Iterable
7+
from typing import Any, Optional, Text
78

89
import numpy as np
910
import onnx
@@ -16,7 +17,7 @@
1617

1718

1819
def run_node(onnx_node, data_inputs, **kwargs):
19-
# type: (onnx.NodeProto, List[np.ndarray], Dict[Text, Any]) -> List[np.ndarray]
20+
# type: (onnx.NodeProto, list[np.ndarray], dict[Text, Any]) -> list[np.ndarray]
2021
"""Convert ONNX node to a graph node and perform computation on input data.
2122
2223
:param onnx_node: ONNX NodeProto describing a computation node
@@ -28,7 +29,7 @@ def run_node(onnx_node, data_inputs, **kwargs):
2829

2930

3031
def run_model(onnx_model, data_inputs):
31-
# type: (onnx.ModelProto, List[np.ndarray]) -> List[np.ndarray]
32+
# type: (onnx.ModelProto, list[np.ndarray]) -> list[np.ndarray]
3233
"""Convert ONNX model to a graph model and perform computation on input data.
3334
3435
:param onnx_model: ONNX ModelProto describing an ONNX model

src/frontends/onnx/tests/tests_python/utils/model_importer.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,20 @@
88
import unittest
99
import dataclasses
1010

11-
from collections import defaultdict, namedtuple
11+
from collections import defaultdict
12+
from collections.abc import Callable, Sequence
1213
from onnx import numpy_helper, NodeProto, ModelProto
1314
from onnx.backend.base import Backend, BackendRep
1415
from onnx.backend.test.case.test_case import TestCase as OnnxTestCase
1516
from onnx.backend.test.runner import TestItem
1617
from pathlib import Path
18+
from re import Pattern
1719
from tests.tests_python.utils.onnx_helpers import import_onnx_model
1820
from typing import (
1921
Any,
20-
Dict,
21-
List,
2222
Optional,
23-
Pattern,
24-
Set,
2523
Text,
26-
Type,
2724
Union,
28-
Callable,
29-
Sequence,
3025
)
3126

3227
# add post-processing function as part of test data
@@ -38,17 +33,17 @@
3833
class ModelImportRunner(onnx.backend.test.BackendTest):
3934
def __init__(
4035
self,
41-
backend: Type[Backend],
42-
models: List[Dict[str, Path]],
36+
backend: type[Backend],
37+
models: list[dict[str, Path]],
4338
parent_module: Optional[str] = None,
4439
data_root: Optional[Path] = "",
4540
) -> None:
4641
self.backend = backend
4742
self._parent_module = parent_module
48-
self._include_patterns = set() # type: Set[Pattern[Text]]
49-
self._exclude_patterns = set() # type: Set[Pattern[Text]]
50-
self._test_items = defaultdict(dict) # type: Dict[Text, Dict[Text, TestItem]]
51-
self._xfail_patterns = set() # type: Set[Pattern[Text]]
43+
self._include_patterns = set() # type: set[Pattern[Text]]
44+
self._exclude_patterns = set() # type: set[Pattern[Text]]
45+
self._test_items = defaultdict(dict) # type: dict[Text, dict[Text, TestItem]]
46+
self._xfail_patterns = set() # type: set[Pattern[Text]]
5247

5348
strings = [str(data_root), ".onnx", "/", "\\", "-"]
5449
for model in models:
@@ -145,7 +140,7 @@ def _execute_pb_data(
145140
def _add_model_import_test(self, model_test: ExtOnnxTestCase) -> None:
146141
# model is loaded at runtime, note sometimes it could even
147142
# never loaded if the test skipped
148-
model_marker = [None] # type: List[Optional[Union[ModelProto, NodeProto]]]
143+
model_marker = [None] # type: list[Optional[Union[ModelProto, NodeProto]]]
149144

150145
def run_import(test_self: Any, device: Text) -> None:
151146
model = ModelImportRunner._load_onnx_model(model_test.model_dir, model_test.model)
@@ -157,7 +152,7 @@ def run_import(test_self: Any, device: Text) -> None:
157152
def _add_model_execution_test(self, model_test: ExtOnnxTestCase) -> None:
158153
# model is loaded at runtime, note sometimes it could even
159154
# never loaded if the test skipped
160-
model_marker = [None] # type: List[Optional[Union[ModelProto, NodeProto]]]
155+
model_marker = [None] # type: list[Optional[Union[ModelProto, NodeProto]]]
161156

162157
def run_execution(test_self: Any, device: Text) -> None:
163158
model = ModelImportRunner._load_onnx_model(model_test.model_dir, model_test.model)

src/frontends/onnx/tests/tests_python/utils/onnx_backend.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
https://github.com/onnx/onnx/blob/master/docs/Implementing%20an%20ONNX%20backend.md
99
"""
1010

11-
from typing import Any, Dict, List, Optional, Sequence, Text, Tuple
11+
from typing import Any, Optional, Text
12+
from collections.abc import Sequence
1213

1314
import numpy
1415
import onnx
@@ -21,14 +22,14 @@
2122

2223

2324
class OpenVinoOnnxBackendRep(BackendRep):
24-
def __init__(self, graph_model, device="CPU"): # type: (List[Model], str) -> None
25+
def __init__(self, graph_model, device="CPU"): # type: (list[Model], str) -> None
2526
super().__init__()
2627
self.device = device
2728
self.graph_model = graph_model
2829
self.runtime = get_runtime()
2930
self.computation = self.runtime.computation(graph_model)
3031

31-
def run(self, inputs, **kwargs): # type: (Any, **Any) -> Tuple[Any, ...]
32+
def run(self, inputs, **kwargs): # type: (Any, **Any) -> tuple[Any, ...]
3233
"""Run computation on model."""
3334
return self.computation(*inputs)
3435

@@ -66,7 +67,7 @@ def run_model(
6667
inputs, # type: Any
6768
device="CPU", # type: Text
6869
**kwargs, # type: Any
69-
): # type: (...) -> Tuple[Any, ...]
70+
): # type: (...) -> tuple[Any, ...]
7071
return cls.prepare(model, device, **kwargs).run(inputs)
7172

7273
@classmethod
@@ -75,14 +76,14 @@ def run_node(
7576
node, # type: onnx.NodeProto
7677
inputs, # type: Any
7778
device="CPU", # type: Text
78-
outputs_info=None, # type: Optional[Sequence[Tuple[numpy.dtype, Tuple[int, ...]]]]
79-
**kwargs, # type: Dict[Text, Any]
80-
): # type: (...) -> Optional[Tuple[Any, ...]]
79+
outputs_info=None, # type: Optional[Sequence[tuple[numpy.dtype, tuple[int, ...]]]]
80+
**kwargs, # type: dict[Text, Any]
81+
): # type: (...) -> Optional[tuple[Any, ...]]
8182
"""Prepare and run a computation on an ONNX node."""
8283
# default values for input/output tensors
8384
input_tensor_types = [np_dtype_to_tensor_dtype(node_input.dtype) for node_input in inputs]
8485
output_tensor_types = [onnx.TensorProto.FLOAT for _ in range(len(node.output))]
85-
output_tensor_shapes = [()] # type: List[Tuple[int, ...]]
86+
output_tensor_shapes = [()] # type: list[tuple[int, ...]]
8687

8788
if outputs_info is not None:
8889
output_tensor_types = [

src/frontends/paddle/tests/test_models/gen_scripts/generate_deformable_conv.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44
import numpy as np
55
import sys
6-
from typing import List
76

87
from save_model import saveModel
98

0 commit comments

Comments
 (0)