Skip to content
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

Typing error with DataHelper.get_element_text #15

Closed
cmutel opened this issue Jan 15, 2023 · 3 comments
Closed

Typing error with DataHelper.get_element_text #15

cmutel opened this issue Jan 15, 2023 · 3 comments

Comments

@cmutel
Copy link
Member

cmutel commented Jan 15, 2023

DataHelper.get_element_text is supposed to always return a str, but calls get_element, which can return None. Pyright is not happy.

@sami-m-g
Copy link
Member

@cmutel DataHelper.get_element_text is set to return a default value of Defaults.TYPE_DEFAULTS[str] in that case.

@cmutel
Copy link
Member Author

cmutel commented Jan 15, 2023

Don't shoot me, I am just the messenger!
Screenshot 2023-01-15 at 15 43 20
I don't think this is a real issue, we know a "text" element which follows the XSD will be a str, and if falsely will get a replacement with Defaults.TYPE_DEFAULTS[str]; I wonder if there is a way to get pyright to realize this. BTW, pyright is from Microsoft so somehow I am holding you a bit responsible :p

@sami-m-g
Copy link
Member

I found the issue which was that Defaults.TYPE_DEFAULTS[str] itself was declared as Any since Defaults.TYPE_DEFAULTS holds the defaults for different data types hence the return type is Any. b679357 resolved this by wrapping Defaults.TYPE_DEFAULTS[str] with a str().

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants