def parse_py(codelet):
    """
    Adds 'symbols' field to the codelet after parsing the python code.

    :param codelet: The codelet object to parsed.

    :type code: Codelet
    """

    def strip_encoding(lines):
        """Strips the encoding line from a file, which breaks the parser."""
        it = iter(lines)
        try:
            first = next(it)
            if not encoding_re.match(first):
                yield first
            second = next(it)
            if not encoding_re.match(second):
                yield second
        except __HOLE__:
            return
        for line in it:
            yield line

    try:
        tree = ast.parse("\n".join(strip_encoding(codelet.code.splitlines())))
    except SyntaxError:
        ## TODO: add some logging here?
        return {}

    walker = _TreeWalker()
    walker.visit(tree)
    return walker.symbols
dataset/ETHPy150Open earwig/bitshift/bitshift/parser/python.py/parse_py