diff --git a/pymbolic/mapper/optimize.py b/pymbolic/mapper/optimize.py index 778da00f4fe5fb2fc94f051f55bc3696efba4ad9..e32f0843cc1405a26dff26e4da89f30b36878bfe 100644 --- a/pymbolic/mapper/optimize.py +++ b/pymbolic/mapper/optimize.py @@ -325,7 +325,11 @@ def optimize_mapper( # }}} - code_str = ast.unparse(cls_ast) + code_str = ( + # Incoming code *may* rely on deferred evaluation of annotations. + # Since we're not checking whether it does, turn it on just in case. + "from __future__ import annotations\n" + + ast.unparse(cls_ast)) if print_modified_code_file: print(code_str, file=print_modified_code_file)