def parse_ast(source, filename=None):
    if isinstance(source, text_type) and sys.version_info[0] == 2:
        # ast.parse() on Python 2 doesn't like encoding declarations
        # in Unicode strings
        source = CODING_COOKIE_RE.sub(r'\1', source, 1)
    return ast.parse(source, filename or '<unknown>')
Parse source into a Python AST, taking care of encoding.
dataset/ETHPy150Open alecthomas/importmagic/importmagic/util.py/parse_ast