From edb19e02e4ef3a8ed2573a69718a79204fa9165a Mon Sep 17 00:00:00 2001 From: Faraphel Date: Tue, 2 Aug 2022 18:03:40 +0200 Subject: [PATCH] added a safe type function (disable the creation of class) --- source/safe_eval.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/safe_eval.py b/source/safe_eval.py index 5985ed0..ffaf65b 100644 --- a/source/safe_eval.py +++ b/source/safe_eval.py @@ -56,6 +56,14 @@ class SafeFunction: if callable(attr): raise AttributeError(f"getattr can't be used for functions (tried: {attr})") return attr + @staticmethod + def type(obj: any) -> any: + """ + Safe type, can only be used to determinate the type of an object + (It can be used to create new class by using all the 3 args) + """ + return type(obj) + def replace_macro(template: str, macros: dict[str, str]) -> str: """