-
Notifications
You must be signed in to change notification settings - Fork 223
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
Vulture : use pyflakes as an initial parse basis #605
Comments
Maybe @RJ722 & @MacBox7 can help with mentoring this project next year, if @jendrikseipp agrees with the concept. cc @myint |
Interesting. Is this project about changing Pyflakes, Vulture, or both? I suppose the added functionality for pyflakes can be seen in the test cases you added in the POC. Could you please say how Vulture's functionality could be extended by this, maybe with a concrete example? |
Hi @jendrikseipp , I would view this as a potential pyflakes + vulture project. The POC above would be merged to pyflakes before this GSoC project (perhaps a little bit revised, and maybe reduced). That POC adds only limited use of the dead scopes it detects; limited intentially by the purpose of pyflakes. One part of the project is enhancing vulture to use pyflakes to do the initial parse of files. There are two ways this could be done.
pyflakes handles a lot of corner cases which I very strongly doubt vulture handles yet, having looked at the vulture visitor. By using the pyflakes ast parser, vulture will benefit from those corner cases being solved. If it helps, I can spend a bit of time finding some of the bigger ones which impact vulture more (I have one below). But really the problem is that there are lots of tiny little ones which wouldnt be considered very important for There is still one very large 'corner' case which pyflakes doesnt handle well, and that is e.g. vulture has standard confidence that variable def a():
b = 100
del b
a() However it doesnt see that the following is an error, while pyflakes does detect this problem: def a():
b = 100
del b
return b
a() But more importantly it cant see that the first def a():
b = 100
del b
b = 200
return b
a() pyflakes also doesnt catch that So this is one example where we might enhance pyflakes and vulture at the same time, if vulture was layered on top of pyflakes. I had a crack at enhancing this in pyflakes a few years ago (PyCQA/pyflakes#37), but it isnt a priority for me, and it is not a lazy-day project, so it keeps falling off the to-do list. I have been incrementally solving problems with that patch, and @MacBox7 this year solved two of structural problems which complicated better del support, i.e. node<->scope links (PyCQA/pyflakes#339) and builtins (PyCQA/pyflakes#351). If we decided to go ahead with a
|
I am quite reluctant about making Vulture depend on Pyflakes since external dependencies usually incur a lot of extra maintenance cost. This is even worse when depending on the internal Pyflakes code instead of its command line interface. I'd only consider depending on Pyflakes if we see that it would add a lot of value to Vulture. The |
Pyflakes does a lot of analysis which can be used by vulture.
pyflakes has long ago decided that it will not report dead code.
However it does need to report other problems caused by dead code, and this can be done by tracking dead code.
There is a POC at
https://github.com/jayvdb/pyflakes/tree/dead-code
vulture can use this base on which to do more sophisticated analysis which is beyond scope of vulture.
One of the key benefits of using pyflakes is errors in the code can be detected by pyflakes base and vulture can fail when those errors would make vulture results unreliable.
The text was updated successfully, but these errors were encountered: