Drop __annotations__ from task data (#834)

This commit is contained in:
jbirddog 2023-12-27 11:50:01 -05:00 committed by GitHub
parent 1789f9d6be
commit b1206c5b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -160,6 +160,7 @@ class MissingProcessInfoError(Exception):
class TaskDataBasedScriptEngineEnvironment(TaskDataEnvironment): # type: ignore
def __init__(self, environment_globals: dict[str, Any]):
self._last_result: dict[str, Any] = {}
self._non_user_defined_keys = {"__annotations__"}
super().__init__(environment_globals)
def execute(
@ -169,6 +170,9 @@ class TaskDataBasedScriptEngineEnvironment(TaskDataEnvironment): # type: ignore
external_context: dict[str, Any] | None = None,
) -> bool:
super().execute(script, context, external_context)
for key in self._non_user_defined_keys:
if key in context:
context.pop(key)
self._last_result = context
return True
@ -199,7 +203,7 @@ class NonTaskDataBasedScriptEngineEnvironment(BasePythonScriptEngineEnvironment)
def __init__(self, environment_globals: dict[str, Any]):
self.state: dict[str, Any] = {}
self.non_user_defined_keys = set([*environment_globals.keys()] + ["__builtins__"])
self.non_user_defined_keys = set([*environment_globals.keys()] + ["__builtins__", "__annotations__"])
super().__init__(environment_globals)
def evaluate(