Skip to content

Commit

Permalink
refactor: [conversable_agent] remove raise from property access (#2006)
Browse files Browse the repository at this point in the history
* refactor: [conversable_agent] remove raise from property access

raising exception seems drastic, can we return None and let the called fail in case it receives a None?

* Update conversable_agent.py

---------

Co-authored-by: Chi Wang <[email protected]>
  • Loading branch information
lalo and sonichi authored Mar 15, 2024
1 parent 08ba070 commit 146d49b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,10 @@ def description(self, description: str):
self._description = description

@property
def code_executor(self) -> CodeExecutor:
"""The code executor used by this agent. Raise if code execution is disabled."""
def code_executor(self) -> Optional[CodeExecutor]:
"""The code executor used by this agent. Returns None if code execution is disabled."""
if not hasattr(self, "_code_executor"):
raise ValueError(
"No code executor as code execution is disabled. "
"To enable code execution, set code_execution_config."
)
return None
return self._code_executor

def register_reply(
Expand Down

0 comments on commit 146d49b

Please sign in to comment.