mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
reverting treating models as props
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import inspect
|
||||
from typing import Callable, Dict, Type
|
||||
from typing import Dict, Type
|
||||
|
||||
# TODO: this needs to be done differently
|
||||
from openbb_core.app.static.container import Container
|
||||
@@ -69,11 +69,6 @@ class ArgparseClassProcessor:
|
||||
) -> Dict[str, ArgparseTranslator]:
|
||||
methods = {}
|
||||
|
||||
def make_prop_as_callable(name):
|
||||
# This is necessary because lambda functions capture variables by reference,
|
||||
# not by value, leading to all lambdas using the last value of name from the loop.
|
||||
return lambda: getattr(target, name)
|
||||
|
||||
for name, member in inspect.getmembers(target):
|
||||
if name.startswith("__") or name.startswith("_"):
|
||||
continue
|
||||
@@ -82,13 +77,6 @@ class ArgparseClassProcessor:
|
||||
methods[f"{class_name}_{name}"] = ArgparseTranslator(
|
||||
func=member, add_help=add_help
|
||||
)
|
||||
if isinstance(getattr(target.__class__, name, None), property):
|
||||
prop_as_callable: Callable = make_prop_as_callable(name)
|
||||
prop_as_callable.__doc__ = getattr(target.__class__, name).__doc__
|
||||
prop_as_callable.__name__ = name
|
||||
methods[name] = ArgparseTranslator(
|
||||
func=prop_as_callable, add_help=add_help
|
||||
)
|
||||
elif isinstance(member, Container):
|
||||
methods = {
|
||||
**methods,
|
||||
|
||||
Reference in New Issue
Block a user