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
Run Pylint Against Node Trees Even If They Are Not External Files #3129
Comments
@tbpassin This idea is reasonable. Doing it cleanly and safly will likely take considerable work. I've delegated this issue to you :-) |
Why am I not surprised?? Any tips on gottchas to look out for? |
The problem might be straightforward. Leo already can run pyflakes checks on But the problem is likely intractable. Leo has beautify-files, blacken-files and pylint commands, but not beautify-tree, blacken-tree or not (as you propose) pylint-tree commands. External programs such as black and pylint require syntactically correct python code. Sure, you could write part of an outline to a temp file, but what good would that do?
Summary The problem is likely intractable because external programs such as black and pylint don't understand Leo's outline structure. Leo's pylint-files and blacken-files commands do understand outline structure enough to create clickable links that work. My advice is to let well enough alone. Edward P.S. A long time ago I wrote horror-show code that related (iirc!!) to this general topic. For a while the horror code resided in the attic. I can't find it now. Perhaps deleting the code was a mistake. It might have served as a cautionary tale. EKR |
It's the line numbers that I see as a potential stumbling block. The temp file would be (I think) exactly the same as what the subtree would be if it were made to be an external file, so I thought that the numbering code would work just as well. That remains to be tested, though. |
The easy part is done - getting the command to run against a subtree that isn't an external file. Now about those line number links ... we'll have to see. I have got an idea or two. |
This may not be too hard after all. I think the goal is to replace the file name in the strings returned by pylint (or another process managed by the bpm). If we are checking a subtree that is not an external file, then the returned strings will contain the temp file path instead of the external file path. We need to change them before the strings get to This substitution needs to made in the So we need to make sure that the idle handler can get root_node and filename. That shouldn't be too hard. At first glance, the modifications to existing code should be minor. If that's true, then the bpm will be able to run any of the bpm processes (not just pylint) against a subtree once they have been modified to go against a subtree that's not an external file. This is starting to sound practical. |
A status report: Pylint can be run against an arbitrary subtree of Python, and it displays the usual clickable links. It still works as it used to for external file trees. I've got one bug that somehow is preventing it from running on a non-external tree more than once. That should be fairly easy to set right. This enhancement required a few coordinated changes to the Pylint class, to the BPM, and to the |
@tbpassin Well done, you! |
Log pane (the link is clickable and goes to the right line):
Also, the bug mentioned above is fixed. I will do some more testing before submitting a PR. |
Status update:
|
Implemented by 3140. |
It would be useful to be able to run pylint against code trees even if they were not external files. An example use case would be for a complicated Leo command or script. It seems to me that the pylint command could write the subtree to a file and run pylint against that. It would be almost identical to launching it against an external file tree.
The text was updated successfully, but these errors were encountered: