Skip to content

Commit 6ea4550

Browse files
lalosonichi
andauthored
refactor: [conversable_agent] remove raise from property access (microsoft#2006)
* 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]>
1 parent 8e677b4 commit 6ea4550

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

autogen/agentchat/conversable_agent.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,10 @@ def description(self, description: str):
270270
self._description = description
271271

272272
@property
273-
def code_executor(self) -> CodeExecutor:
274-
"""The code executor used by this agent. Raise if code execution is disabled."""
273+
def code_executor(self) -> Optional[CodeExecutor]:
274+
"""The code executor used by this agent. Returns None if code execution is disabled."""
275275
if not hasattr(self, "_code_executor"):
276-
raise ValueError(
277-
"No code executor as code execution is disabled. "
278-
"To enable code execution, set code_execution_config."
279-
)
276+
return None
280277
return self._code_executor
281278

282279
def register_reply(

0 commit comments

Comments
 (0)