Skip to content

Fix #30149: Fix Pyright errors in utils/decorators.py #30194

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 5 commits into
base: master
Choose a base branch
from

Conversation

sanleo-wq
Copy link

Description

This PR fixes issue #30149 by resolving the Pyright errors in the src/openvino/utils/decorators.py file.

Changes made

  • Corrected return type annotation of _get_name function from Node to Optional[str]
  • Added proper type annotations to the methods in the MultiMethod class
  • Added safety checks for issubclass calls to prevent type errors
  • Fixed type annotations in the signature access
  • Added null check for better error handling

Testing

  • Removed src/openvino/utils/decorators.py from the exclusions in pyproject.toml
  • Ran Pyright which now reports no errors:

@sanleo-wq sanleo-wq requested a review from a team as a code owner April 17, 2025 15:31
@github-actions github-actions bot added the category: Python API OpenVINO Python bindings label Apr 17, 2025
@sys-openvino-ci sys-openvino-ci added the ExternalPR External contributor label Apr 17, 2025

from openvino import Node, Output
from openvino.utils.types import NodeInput, as_node, as_nodes


def _get_name(**kwargs: Any) -> Node:
def _get_name(**kwargs: Any) -> Optional[str]: # Corretto il tipo di ritorno
Copy link
Contributor

Choose a reason for hiding this comment

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

if needed, comments should be in english, please :)

Comment on lines 83 to 85
elif get_origin(type_arg) == list:
if issubclass(actual_type, list):
if isinstance(actual_type, type) and issubclass(actual_type, list):
return True
Copy link
Contributor

@mlukasze mlukasze Apr 18, 2025

Choose a reason for hiding this comment

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

it could be one-line condition, elif itself makes no sense here, imho, nesting for sure
@akuporos what's your opinion?

return True
return False

def matches_optional(self, optional_type, actual_type) -> bool: # type: ignore
def matches_optional(self, optional_type: Any, actual_type: Any) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change

@p-wysocki
Copy link
Contributor

p-wysocki commented Apr 18, 2025

Thank you for the PR! Could you please also regenerate .pyi files as mentioned in the issue description? All you need to do is build OpenVINO with -DENABLE_WHEEL=ON, install that wheel python -m pip install build/wheels/openvino... and either:

  • make any commit, and the .pyi files will be automatically regenerated and added to your commit
  • run python src/bindings/python/scripts/generate_stub_files.py and git add them manually

@mlukasze mlukasze dismissed their stale review April 22, 2025 05:11

requested changes done, removing roadblock, enabling CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Python API OpenVINO Python bindings ExternalPR External contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Good First Issue]: Fix pyright in: src/openvino/utils/decorators.py
4 participants