Chris Norman via code-quality email@example.com writes:
I have a suggestion which I suspect is already implemented I just don't know how to find the option:
Based on my unsterstanding of your request, I think it is not implemented and will not be.
Using Flake8, I want to be able to set up globals like you can with eslint. This should allow me to say that there are globals present in the file which aren't currently there.
I get that the use case is kind of non standard: I am evaling code […]
One reason why that is discouraged is exactly the problem you are encountering. Code which does not exist at the time of static analysis cannot be part of that static analysis.
By choosing to use ‘eval’ you are choosing to abandon the advantages of static analysis; not only static analysis of the run-time evaluated code but also of any code which interacts with that. A static analyser depends on having access to the complete syntax tree of the run-time program, without running it. You abandon that when you use ‘eval’.
For this reason, it is IMO best to acknowledge the severe reduction in quality assurance that you impose, by choosing ‘eval’. Either ensure everyone understands and accepts the reduction in effectiveness of code quality tools; or re-structure the program not to use ‘eval’.