-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
|
||
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 |
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.
if needed, comments should be in english, please :)
elif get_origin(type_arg) == list: | ||
if issubclass(actual_type, list): | ||
if isinstance(actual_type, type) and issubclass(actual_type, list): | ||
return True |
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.
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: |
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.
unnecessary change
Thank you for the PR! Could you please also regenerate
|
requested changes done, removing roadblock, enabling CI
@@ -115,14 +114,14 @@ def __call__(self, *args, **kwargs) -> Any: # type: ignore | |||
break | |||
elif len(arg_types) == 0 and len(kwarg_types) != 0: | |||
for key, func in self.typemap.items(): | |||
func_signature = {arg_name: types.annotation for arg_name, types in signature(func).parameters.items()} | |||
func_signature = {arg_name: param.annotation for arg_name, param in signature(func).parameters.items()} |
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.
why did you rename variables here?
Hello @sanleo-wq, thank for your your PR! There are some unintended changes to There's no need to rebuild the project, you can just apply the changes to stub generation Python script from the linked PR and run Also, |
@@ -122,7 +121,7 @@ def __call__(self, *args, **kwargs) -> Any: # type: ignore | |||
break | |||
elif len(arg_types) != 0 and len(kwarg_types) != 0: | |||
for key, func in self.typemap.items(): | |||
func_signature = {arg_name: types.annotation for arg_name, types in signature(func).parameters.items()} | |||
func_signature = {arg_name: param.annotation for arg_name, param in signature(func).parameters.items()} |
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.
there is still param instead of types
Thank you for the investigation! The tasks for fixing |
Description
This PR fixes issue #30149 by resolving the Pyright errors in the
src/openvino/utils/decorators.py
file.Changes made
_get_name
function fromNode
toOptional[str]
MultiMethod
classissubclass
calls to prevent type errorsTesting
src/openvino/utils/decorators.py
from the exclusions inpyproject.toml