-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Description
Hi,
Is there a way to include annotated assignment in the code being executed?
sample_code = """
a: int = 1
"""
supported_builtins["_getattr_"] = safer_getattr
supported_builtins["_getiter_"] = default_guarded_getiter
supported_builtins["_iter_unpack_sequence_"] = guarded_iter_unpack_sequence
supported_builtins["dict"] = dict
supported_builtins["list"] = list
byte_code = compile_restricted(
sample_code,
filename='<inline code>',
mode='exec'
)
exec(byte_code, {'__builtins__':supported_builtins}, {'input_arg': {"a":1})
Where I am looking to add type hints to my inline code "sample_code". It will throw exception saying " AnnAssign statements are not allowed.". Is there a way to get around this?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status