Skip to content

peval doesn't propagate constants stored in dicts #1

Description

@KOLANICH
m = ast.parse("""
dic = {"name": "aa", "version": 10}
setup(name=dic["name"], version=dic["version"])
""")

import peval
from peval.components import fold
r, v = fold(m, {})
print(astor.to_source(r, indent_with='\t',), v)

My use case is automatic safe parsing of metadata from setup.py files. The plan is simple: process the AST with a constant and copy propagation optimizer, then extract the data from setup call.

Also: I had to comment out some asserts in expression.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions