This Engineering Notebook post tells how I am studying pylint, mypy, and 
pyflakes.

*Background*

This post 
<https://groups.google.com/g/leo-editor/c/pdIXFl3UFBE/m/VtX57H6XAQAJ> 
contains my discussion with gemini3 about fast linting. 

#4472 <https://github.com/leo-editor/leo-editor/issues/4472> contains the 
summary of my initial prototypes. They all failed quickly :-) In 
particular, using mypy stubs (stubgen) doesn't seem feasible: stubgen fails 
on leoApp.py and fails quite slowly.

#4472 <https://github.com/leo-editor/leo-editor/issues/4472> now recommends 
trying to improve pyflakes. pyflakes's code is way simpler and faster than 
pyflakes.

*A new way to study code*

In the past, I have cloned or forked repos that I have wanted to study. 
Now, however, I study tools directly in Python/Lib/site-packages. This is 
feasible because Leo's Python importers now *always* work perfectly!  Here 
are the steps I just used to study pyflakes:

- Do `git init` in Python 3.14's site-packages/pyflakes directory.
- Add all the files and commit. I'll never push this commit, or any others.
- Create  site-packages/pyflakes/pyflakes.leo
- Import all the pyflakes source files as *live* @clean nodes.
- Write all the imported using Ctrl+Shift+w (write-at-file-nodes).
- Verify that git status reports only that pyflakes.leo has changed.

I now have a safe way to study *and modify* any of the pyflakes files. I 
can revert to the original files using `git checkout .`

*Frozen modules*

Frozen modules can cause problems even when using Python's `-X 
frozen_modules=off` command-line argument. In particular, that command-line 
argument doesn't seem to work well with stubgen. I can add traces to 
stubgen itself, but not to the mypy modules that stubgen calls.  Happily, 
pyflakes doesn't use frozen modules.

*One workflow to study them all*

*study.cmd* contains:

@echo off
cd C:\Python\Python3.14\Lib\site-packages
leo pyflakes/pyflakes.leo mypy/mypy.leo pylint\pylint.leo 
astroid\astroid.leo 

I also define commands to switch to the local repos. For example, 
*cd-pyflakes.cmd*:

@echo off
cd C:\Python\Python3.14\Lib\site-packages\pyflakes

*Summary*

All the tools I've mentioned analyze code by traversing parse trees. But 
the details are bewilderingly different for each tool. I'll use study.cmd 
to compare and contrast the tools.

I am not interested in heroic solutions. Improving pyflakes seems like the 
only way forward.

There is no guarantee of success, but the study itself should be 
interesting.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/42298ca2-c8c4-4c3d-b235-d6406bd4671en%40googlegroups.com.

Reply via email to