Discussion around a proper implementation of control-flow in pylint #4795
Labels
Control flow
Requires control flow understanding
Discussion 🤔
Enhancement ✨
Improvement to a component
Needs design proposal 🔒
This is a huge feature, some discussion should happen before a PR is proposed
Current problem
The main limitation regarding control flow is the fact that the variable checkers rely on
NamesConsumer
's to_consume/consumed states, and these are updated "all-or-nothing" per variable, with additional special-case checks here and there. To give a simpler example, pylint doesn't report any error on:Desired solution
I don't know the history of the Variables checker, but it seems to me like pylint will keep running into issues around control flow as long as this basic approach is used. I wouldn't say that this is a limitation of the AST visitor pattern though. I think improvements could be made by doing any of (in order of increasing code complexity and running time, but also correctness IMO):
NamesConsumer
so that variables can be processed more than once.VariablesChecker
checks on the graph rather than the AST itself.But all of these would be really significant changes so I'm not exactly advocating for them, just thought I'd mention. Personally I'm still very happy using pylint with the current functionality!
[1] Example:
Additional context
This issue is taken entirely from a comment by @david-yz-liu here and will serve as the reference for discussion regarding control-flow implementation.
The text was updated successfully, but these errors were encountered: