-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix #30150: Fix Pyright errors in frontend/frontend.py #30195
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
Thank you for the PR! Could you please also regenerate
|
Co-authored-by: Anastasia Kuporosova <anastasia.kuporosova@intel.com>
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.
Thank you for the PR! Looks good to me.
# type: ignore | ||
from . import _op_base | ||
from . import _ov_api | ||
from . import _pyopenvino | ||
from . import exceptions | ||
from . import experimental | ||
from . import frontend | ||
from . import helpers | ||
from . import op | ||
from . import opset1 | ||
from . import opset10 | ||
from . import opset11 | ||
from . import opset12 | ||
from . import opset13 | ||
from . import opset14 | ||
from . import opset15 | ||
from . import opset16 | ||
from . import opset2 | ||
from . import opset3 | ||
from . import opset4 | ||
from . import opset5 | ||
from . import opset6 | ||
from . import opset7 |
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.
looks a lot undesired changes
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.
looks a lot undesired changes among different files
@@ -21,7 +21,7 @@ def create_regex_pattern(errors): | |||
return "|".join([re.escape(error) for error in errors]) | |||
|
|||
def sanitize_file(file_path): | |||
with open(file_path, 'r') as file: | |||
with open(file_path, 'r', encoding='utf-8') as file: |
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 was it needed? Not saying it's unnecessary, I'm curious - it's a new script and something may be missing.
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.
Because when i ran the file whit the command: python src/bindings/python/scripts/generate_stub_files.py
give e this errors:
Traceback (most recent call last):
File "openvino\src\bindings\python\scripts\generate_pyapi_stubs.py", line 101, in
main()
File "openvino\src\bindings\python\scripts\generate_pyapi_stubs.py", line 98, in main
sanitize_file(file_path)
File "openvino\src\bindings\python\scripts\generate_pyapi_stubs.py", line 25, in sanitize_file
content = file.readlines()
File "Lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2010: character maps to
The error occurs because the script tries to read files using the default encoding cp1252 in Windows, but some files contain Unicode characters that aren't supported by this encoding.
By explicitly specifying encoding='utf-8' I was able to generate the pyi files.
Thank you for the investigation! The tasks for fixing |
Description
This PR fixes issue #30150 by resolving the Pyright errors in the
src/openvino/frontend/frontend.py
file.Changes made
cast()
from the typing moduleOptional[FrontEnd]
instead ofUnion[FrontEnd, None]
for better readability# type: ignore
comments with explanations where there is an inherent type incompatibility betweenopenvino.Model
andopenvino._pyopenvino.Model
pyproject.toml
Testing
src/openvino/frontend/frontend.py
from the exclusions inpyproject.toml