Skip to content

[PyOV] Replace deprecated typing types #30762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

akuporos
Copy link
Contributor

@akuporos akuporos commented May 28, 2025

Details:

  • Replace deprecated typing types in the openvino repo
  • List of deprecated may be found here

Tickets:

@akuporos akuporos requested review from a team as code owners May 28, 2025 08:00
@akuporos akuporos requested review from akopytko, Copilot, p-wysocki and almilosz and removed request for a team and akopytko May 28, 2025 08:00
@akuporos akuporos added this to the 2025.3 milestone May 28, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request updates the OpenVINO Python bindings by replacing deprecated typing types (e.g. List, Dict) with their built‑in counterparts (e.g. list, dict) in type hints and docstrings.

  • Updated type hints across multiple opset files and frontend utility modules
  • Adjusted string-based type annotations in documentation and type checks
  • Ensured consistency in naming conventions for type hints and related comments

Reviewed Changes

Copilot reviewed 64 out of 64 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/bindings/python/src/openvino/opset15/ops.py Replaced Optional[List[int]] with Optional[list[int]] for parameter type hints
src/bindings/python/src/openvino/opset14/ops.py Updated type hint annotations from List[int] to list[int]
src/bindings/python/src/openvino/opset11/ops.py Replaced deprecated typing.List use with built‑in list in type hints
src/bindings/python/src/openvino/opset10/ops.py Replaced Optional[List[int]] with Optional[list[int]] in function signatures
src/bindings/python/src/openvino/opset1/ops.py Updated type annotations and adjusted docstrings to reflect list usage
src/bindings/python/src/openvino/frontend/tensorflow/utils.py Removed List and Dict from type imports in favor of built‑in types
src/bindings/python/src/openvino/frontend/pytorch/utils.py Modified string matching to detect list types in annotations
src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py Updated type hint and return value using DecoderType.list instead of DecoderType.List
src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/* Replaced typing.List and typing.Dict with their built‑in counterparts in type hints
src/bindings/python/src/openvino/_ov_api.py and _op_base.py Adjusted type hints using built‑in types (list, dict, tuple) across API modules
src/bindings/python/docs/code_examples.md Updated docstring examples to use lowercase built‑in type names
Comments suppressed due to low confidence (2)

src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py:272

  • [nitpick] Please confirm that replacing 'DecoderType.List' with 'DecoderType.list' aligns with the intended naming conventions and that the member 'list' is defined as required.
return OVAny(DecoderType.list(self._get_known_type_for_value(element_type)))

src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py:91

  • [nitpick] Verify that the change from 'DecoderType.List' to 'DecoderType.list' is consistent across the codebase and that 'DecoderType.list' is the proper identifier per the updated API.
return OVAny(DecoderType.list(BaseFXDecoder.get_type_for_value(value[0])))

@@ -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):
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a string literal to detect list type annotations can be brittle; consider leveraging proper type checking utilities or annotations introspection for improved robustness.

Copilot uses AI. Check for mistakes.

@github-actions github-actions bot added category: Python API OpenVINO Python bindings category: docs OpenVINO documentation category: TF FE OpenVINO TensorFlow FrontEnd category: PyTorch FE OpenVINO PyTorch Frontend category: JAX FE OpenVINO JAX FrontEnd labels May 28, 2025
@akuporos akuporos force-pushed the akup/typing-improvement branch 2 times, most recently from 23099c7 to 9b17eee Compare May 28, 2025 08:30
@akuporos akuporos force-pushed the akup/typing-improvement branch from 9b17eee to 6867fab Compare May 28, 2025 08:36
@akuporos akuporos force-pushed the akup/typing-improvement branch 5 times, most recently from b4bd475 to d473359 Compare June 2, 2025 20:09
@akuporos akuporos requested a review from a team as a code owner June 2, 2025 20:09
@akuporos akuporos force-pushed the akup/typing-improvement branch from d692d67 to 63f1b5d Compare June 2, 2025 21:24
@akuporos akuporos requested review from a team as code owners June 2, 2025 21:59
@akuporos akuporos requested review from eaidova, artanokhov and mvafin and removed request for a team June 2, 2025 21:59
@github-actions github-actions bot added category: samples OpenVINO Runtime Samples category: CI OpenVINO public CI category: tools OpenVINO C++ / Python tools category: ONNX FE OpenVINO ONNX FrontEnd category: dependency_changes Pull requests that update a dependency file category: PDPD FE OpenVINO PaddlePaddle FrontEnd no-match-files category: docker_env labels Jun 2, 2025
@akuporos akuporos force-pushed the akup/typing-improvement branch from be329ae to 6818286 Compare June 2, 2025 22:12
@akuporos akuporos force-pushed the akup/typing-improvement branch from 6818286 to f84422d Compare June 2, 2025 23:11
@github-actions github-actions bot removed the category: dependency_changes Pull requests that update a dependency file label Jun 2, 2025
@akuporos akuporos requested a review from Copilot June 2, 2025 23:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces deprecated typing types with built-in generic types across the OpenVINO codebase to modernize type annotations and ensure compliance with the latest Python syntax.

  • Replaced typing.List, typing.Dict, and similar types with list, dict, etc.
  • Updated function signatures, return types, and docstring annotations accordingly.

Reviewed Changes

Copilot reviewed 94 out of 94 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/bindings/python/src/openvino/opset1/ops.py Replaced deprecated List types with list type hints
src/bindings/python/src/openvino/frontend/tensorflow/utils.py Updated type unions from typing.List/Dict to list/dict
src/bindings/python/src/openvino/frontend/pytorch/utils.py Adjusted type checking of annotations using string checks for "list"
src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py Modified return annotations from List[int] to list[int]
src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/partition.py Converted typing.List/Dict to list/dict in function signatures
src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/op_support.py Updated mapping type annotations to use collections.abc.Mapping
src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/execute.py Removed unused Callable import and maintained type annotations consistency
src/bindings/python/src/openvino/frontend/pytorch/torchdynamo/decompositions.py Adjusted comments and type annotations for list types
src/bindings/python/src/openvino/frontend/pytorch/patch_functions.py Changed tuple annotation from Tuple to tuple for consistency
src/bindings/python/src/openvino/frontend/pytorch/module_extension.py Switched type annotations for classes and callables to built-in generics and collections.abc
src/bindings/python/src/openvino/frontend/pytorch/inlined_extension.py Updated type annotation imports and usage of Callable
src/bindings/python/src/openvino/frontend/jax/jaxpr_decoder.py Replaced deprecated list types in function signatures and return types
src/bindings/python/src/openvino/_ov_api.py Updated multiple type annotations (list, dict, Iterable, etc.) to built-in generics and collections.abc
src/bindings/python/src/openvino/_op_base.py Modified complex union and tuple types to use built-in generic types
src/bindings/python/docs/code_examples.md Updated docstring type hints from List to list for consistency
samples/python/model_creation_sample/model_creation_sample.py Adjusted tuple type annotations in helper function to use tuple instead of typing.Tuple
docs/openvino_sphinx_theme/openvino_sphinx_theme/directives/code.py Converted return type annotations for directive methods to list
.github/github_org_control/github_api.py Replaced typing.Iterable with collections.abc.Iterable
.github/actions/validate_pyi_files/compare_pyi_files.py Updated set and list annotations to use built-in generic types
.github/actions/create_manifest/manifest_manager.py Replaced deprecated type annotations with built-in generics in manifest management

@akuporos akuporos requested a review from rkazants June 3, 2025 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: CI OpenVINO public CI category: docs OpenVINO documentation category: JAX FE OpenVINO JAX FrontEnd category: ONNX FE OpenVINO ONNX FrontEnd category: OVC OVC tool category: PDPD FE OpenVINO PaddlePaddle FrontEnd category: Python API OpenVINO Python bindings category: PyTorch FE OpenVINO PyTorch Frontend category: samples OpenVINO Runtime Samples category: TF FE OpenVINO TensorFlow FrontEnd category: tools OpenVINO C++ / Python tools no-match-files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants