Static code analysis #259
Replies: 3 comments 7 replies
-
I think it's a good idea. It would be worth writing guidelines for contributors as well. |
Beta Was this translation helpful? Give feedback.
-
It could be helpful, IMHO runtime analysis would be more useful, allow me to explain. The main issue with .PYI files is that the output from boost::python is not PEP compliant The stubs are now generated by Grzegorz’s awesome generator. Here’s an example of the raw output from the C++ module @command
def doit():
print(Ax.AcadTable.setCellGridLineWeight.__doc__)
# setCellGridLineWeight( (AcadTable)arg1, (int)arg2, (int)arg3, (AcCellEdgeMask)arg4, (AcLineWeight)arg5) -> None :
# ![(self, row:int, col:int, mask:PyAx.AcCellEdgeMask, lw:PyAx.AcLineWeight)]!<[{-1}]>
# C++ signature :
# void setCellGridLineWeight(class PyAcadTable {lvalue},int,int,enum PyAcCellEdgeMask,enum PyAcLineWeight) output: def setCellGridLineWeight(self, row:int, col:int, mask:PyAx.AcCellEdgeMask, lw:PyAx.AcLineWeight, /) -> None:
pass The point of failure is that I hand enter the signatures inside C++ and inject them into the raw output ( inside the ![(… )]! markers). So linting might help shed light on some issues, they won’t tell us if it’s actually correct, unless it’s comparing with the C++ source, which is best done at runtime IMHO, A useful tool might. I found I probably need to go back and fully qualify argument names, me using ‘val’ is not much better than ‘arg1’, ‘arg2’ |
Beta Was this translation helpful? Give feedback.
-
@rdesparbes
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I find this project very interesting, and I am very impressed with the work that has been achieved here.
I think the project would greatly benefit from setting up some sort of static code analysis for the Python part:
A CI that runs the tests would be pretty hard to set up because of the necessity to have a running CAD app in the environment, but static analysis would be easier to set up, and would provide some guarantees on the code and the .pyi files.
I already investigated mypy and ruff locally, and managed to find and fix some issues with the generation of the .pyi files, using these tools.
What do you think about it?
I am willing to work on this, but I want to be sure that we share the same views on this and that we choose the most adapted tools for that
Beta Was this translation helpful? Give feedback.
All reactions