diff --git a/cli/openbb_cli/controllers/base_platform_controller.py b/cli/openbb_cli/controllers/base_platform_controller.py index 58985fc5772..9bd31ae99ee 100644 --- a/cli/openbb_cli/controllers/base_platform_controller.py +++ b/cli/openbb_cli/controllers/base_platform_controller.py @@ -158,11 +158,7 @@ class PlatformController(BaseController): title = f"{self.PATH}{translator.func.__name__}" if obbject: - max_obbjects_exceeded = ( - len(session.obbject_registry.obbjects) - >= session.settings.N_TO_KEEP_OBBJECT_REGISTRY - ) - if max_obbjects_exceeded: + if session.max_obbjects_exceeded(): session.obbject_registry.remove() # use the obbject to store the command so we can display it later on results @@ -214,7 +210,7 @@ class PlatformController(BaseController): figure=fig, ) - if max_obbjects_exceeded: + if session.max_obbjects_exceeded(): session.console.print( "[yellow]\nMaximum number of OBBjects reached. The oldest entry was removed.[yellow]" ) diff --git a/cli/openbb_cli/session.py b/cli/openbb_cli/session.py index be2a7938aa3..49da650bf8c 100644 --- a/cli/openbb_cli/session.py +++ b/cli/openbb_cli/session.py @@ -84,3 +84,9 @@ class Session(metaclass=SingletonMeta): def reset(self) -> None: pass + + def max_obbjects_exceeded(self) -> bool: + """Check if max obbjects exceeded.""" + return ( + len(self.obbject_registry.all) >= self.settings.N_TO_KEEP_OBBJECT_REGISTRY + )