Skip to content

Commit

Permalink
fix: merge locals() with globals() for context forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Oct 9, 2024
1 parent e7230bb commit 41b99fb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/promplate/prompt/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import cached_property, partial
from pathlib import Path
from sys import path as sys_path
from sys import version_info
from textwrap import dedent
from typing import TYPE_CHECKING, Any, Literal, Protocol

Expand Down Expand Up @@ -87,7 +88,8 @@ def _on_special_token(self, token, sync: bool):
@staticmethod
def _make_context(text: str):
"""generate context parameter if specified otherwise use locals() by default"""

if version_info >= (3, 13):
return f"globals() | locals() | dict({text[text.index(' ') + 1:]})" if " " in text else "globals() | locals()"
return f"locals() | dict({text[text.index(' ') + 1:]})" if " " in text else "locals()"

def compile(self, sync=True, indent_str="\t"):
Expand Down

0 comments on commit 41b99fb

Please sign in to comment.