-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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): |
There was a problem hiding this comment.
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.
23099c7
to
9b17eee
Compare
9b17eee
to
6867fab
Compare
src/bindings/python/src/openvino/frontend/pytorch/fx_decoder.py
Outdated
Show resolved
Hide resolved
b4bd475
to
d473359
Compare
d692d67
to
63f1b5d
Compare
be329ae
to
6818286
Compare
6818286
to
f84422d
Compare
There was a problem hiding this 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 |
Details:
Tickets: