From 72e8c1babc210a371e1db49c537becc945ec9c0f Mon Sep 17 00:00:00 2001 From: tehcoderer Date: Mon, 7 Aug 2023 09:28:00 -0400 Subject: [PATCH] Update package_builder.py --- .../core/openbb_core/app/static/package_builder.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py index fe7d66ac45e..dae45405308 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py @@ -103,7 +103,7 @@ class PackageBuilder: package_folder.mkdir(exist_ok=True) print(package_path) - with package_path.open("w") as file: + with package_path.open("w", encoding="utf-8", newline="\n") as file: file.write(module_code) @@ -178,7 +178,7 @@ class ImportDefinition: code += "\nimport pandas" code += "\nimport datetime" code += "\nimport pydantic" - code += "\nfrom pydantic import validate_arguments" + code += "\nfrom pydantic import validate_arguments, BaseModel" code += "\nfrom inspect import Parameter" code += "\nfrom typing import List, Dict, Union, Optional, Literal" code += "\nfrom openbb_core.app.utils import df_to_basemodel" @@ -527,9 +527,12 @@ class MethodDefinition: if hasattr(item_type, "__name__") else item_type._name ) - func_returns = ( - f"CommandOutput[{item_type.__module__}.{inner_type_name}]" - ) + result_type = f"{item_type.__module__}.{inner_type_name}" + + if "pydantic.main" in result_type: + result_type = "BaseModel" + + func_returns = f"CommandOutput[{result_type}]" return func_returns