@core.flake8ext
def hacking_no_locals(logical_line, physical_line, tokens, noqa):
    'Do not use locals() or self.__dict__ for string formatting.\n\n    Okay: \'locals()\'\n    Okay: \'locals\'\n    Okay: locals()\n    Okay: print(locals())\n    H501: print("%(something)" % locals())\n    H501: LOG.info(_("%(something)") % self.__dict__)\n    Okay: print("%(something)" % locals())  # noqa\n    '
    if noqa:
        return
    for_formatting = False
    for (token_type, text, start, _, _) in tokens:
        if ((text == '%') and (token_type == tokenize.OP)):
            for_formatting = True
        if (for_formatting and (token_type == tokenize.NAME)):
            for (k, v) in LOCALS_TEXT_MAP.items():
                if ((text == k) and (v in logical_line)):
                    (yield (start[1], ('H501: Do not use %s for string formatting' % v)))
Do not use locals() or self.__dict__ for string formatting.

Okay: 'locals()'
Okay: 'locals'
Okay: locals()
Okay: print(locals())
H501: print("%(something)" % locals())
H501: LOG.info(_("%(something)") % self.__dict__)
Okay: print("%(something)" % locals())  # noqa
@core.flake8ext
def hacking_no_locals(logical_line, physical_line, tokens, noqa):
    'Do not use locals() or self.__dict__ for string formatting.\n\n    Okay: \'locals()\'\n    Okay: \'locals\'\n    Okay: locals()\n    Okay: print(locals())\n    H501: print("%(something)" % locals())\n    H501: LOG.info(_("%(something)") % self.__dict__)\n    Okay: print("%(something)" % locals())  # noqa\n    '
    if noqa:
        return
    for_formatting = False
    for (token_type, text, start, _, _) in tokens:
        if ((text == '%') and (token_type == tokenize.OP)):
            for_formatting = True
        if (for_formatting and (token_type == tokenize.NAME)):
            for (k, v) in LOCALS_TEXT_MAP.items():
                if ((text == k) and (v in logical_line)):
                    (yield (start[1], ('H501: Do not use %s for string formatting' % v)))