[code-quality] Flake8 "globals"

Florian Bruhin me at the-compiler.org
Mon Feb 12 03:47:20 EST 2018


Hey Chris,

On Sun, Feb 11, 2018 at 09:19:11PM +0000, Chris Norman via code-quality wrote:
> 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.

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 at 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 at 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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/code-quality/attachments/20180212/114ab453/attachment.sig>


More information about the code-quality mailing list