
Hi everyone, I've been using pyflakes and now flake8 for a while and honestly it's probably the second-most used program on my computer, second only to Python. I am a very happy customer and want to extend my warmest gratitude to the creators and maintainers! I have a suggestion which I suspect is already implemented I just don't know how to find the option: 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 found in an arbitrary, and of coruse that code is inheriting the globals and locals from the main script. To this end, I want to be able to do more than just put # noqa: F821 at the end of each line that contains one of the locals.. that is very inconvenient and runs the high risk of suppressing a real live issue. Is this already done? If not should I open an issue on Gitlab? I'd be more than happy to dig in and try make a fix for this myself but I have no idea how flake8 works ETC, so if I could be given some pointers on where to start that would be awesome, even if those pointers are simply RTFM! :) Thank you all so much, and I hope everyone is having a wonderful day.

Chris Norman via code-quality <code-quality@python.org> 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.
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’. -- \ “I disapprove of what you say, but I will defend to the death | `\ your right to say it.” —Evelyn Beatrice Hall, _The Friends of | _o__) Voltaire_, 1906 | Ben Finney

Hey Chris, On Sun, Feb 11, 2018 at 09:19:11PM +0000, Chris Norman via code-quality wrote:
It's a bit of a hack, but what you can do is something like: config = config # noqa: F821 or if you use pylint as well: config = config # noqa: F821 pylint: disable=E0602,C0103 at the top of your script, and flake8 won't complain about it anymore elsewhere. FWIW I wouldn't mind having a better way to do this either. It's a somewhat common thing in projects using Python for configuration that you have some config object injected into the namespace of your script, and I'd much rather continue using flake8 in my editor for it (or rather, for any *.py file) than not benefiting from it at all ;-) By the way, your "subscribe" email went to the list. Command mails like this should go to the address you get when adding "-request" to the list address, i.e. code-quality-request@python.org here. I *think* you are subscribed now or you probably couldn't post, but I'm not sure. Florian -- https://www.qutebrowser.org | me@the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc I love long mails! | https://email.is-not-s.ms/

Chris Norman via code-quality <code-quality@python.org> 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.
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’. -- \ “I disapprove of what you say, but I will defend to the death | `\ your right to say it.” —Evelyn Beatrice Hall, _The Friends of | _o__) Voltaire_, 1906 | Ben Finney

Hey Chris, On Sun, Feb 11, 2018 at 09:19:11PM +0000, Chris Norman via code-quality wrote:
It's a bit of a hack, but what you can do is something like: config = config # noqa: F821 or if you use pylint as well: config = config # noqa: F821 pylint: disable=E0602,C0103 at the top of your script, and flake8 won't complain about it anymore elsewhere. FWIW I wouldn't mind having a better way to do this either. It's a somewhat common thing in projects using Python for configuration that you have some config object injected into the namespace of your script, and I'd much rather continue using flake8 in my editor for it (or rather, for any *.py file) than not benefiting from it at all ;-) By the way, your "subscribe" email went to the list. Command mails like this should go to the address you get when adding "-request" to the list address, i.e. code-quality-request@python.org here. I *think* you are subscribed now or you probably couldn't post, but I'm not sure. Florian -- https://www.qutebrowser.org | me@the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc I love long mails! | https://email.is-not-s.ms/
participants (4)
-
Ben Finney
-
Chris Norman
-
Florian Bruhin
-
Marius Gedminas