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
Improving static type checking results #11
Comments
The main problem are types unions returned from lxml functions. I have to use "assert" with isinstance() to narrow union types: for scopeNode in scopes:
assert isinstance(scopeNode, etree._Element) <----------
if scopeNode.get("type").startswith("DU_"):
continue If this is accetable I can prepare PR in next few days.
|
I think I would prefer: for scopeNode in scopes:
if isinstance(scopeNode, etree._Element): # <----------
# some code here
elif isinstance(scopeNode, etree.xxxxx): # <----------
# some code here
else:
raise .... # <---------- as a coding pattern instead of assert statements. Because you have direct write access to this repository you can branch again from Note: You can also link your PR to this issues, so this issue gets closed when the PR is merged to the |
@por3bski I wanted to ask you if you maybe have an idea how to improved the static type checking results for the code when it comes to using
lxml
.I added
lxml-stubs
to the dependencies ondev
branch, but still the results are not so good with respect to types fromlxml
.See installation of lxml-stubs
Here is the mypy output: https://github.com/edaa-org/pyEDAA.UCIS/runs/4947176046?check_suite_focus=true#step:5:10
Here is the matching HTML report: https://edaa-org.github.io/pyEDAA.UCIS/typing/index.html
I'm also using
lxml
in other places, but never investigated what to improve in such a situation.The text was updated successfully, but these errors were encountered: