Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take dialects from syntax tree strings #31

Open
fgrunewald opened this issue Nov 17, 2024 · 1 comment
Open

Take dialects from syntax tree strings #31

fgrunewald opened this issue Nov 17, 2024 · 1 comment

Comments

@fgrunewald
Copy link
Collaborator

import ast
dialect_str = 'a, /, b, c=3, *, d, e=5'
input_str = f'def f({dialect_str}): pass'

tree = ast.parse(input_str)
# Disect the tree here to get to the juicy function object whose Signature we want

See PR #25

@pckroon
Copy link
Collaborator

pckroon commented Nov 18, 2024

Specifically, the idea is to format the dialect in the same format python functions define their arguments.
The easy and slightly terrifying solution would be eval(def f({dialect_str}): pass), with the user provided dialect_str (and then getting the function, and pulling out its signature). But then you're executing user provided code, which is always a bad idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants