Browse Source

make runnable a class var (#1679)

Engel Nyst 1 year ago
parent
commit
a17308108c

+ 2 - 3
opendevin/events/action/action.py

@@ -1,13 +1,12 @@
 from dataclasses import dataclass
+from typing import ClassVar
 
 from opendevin.events.event import Event
 
 
 @dataclass
 class Action(Event):
-    @property
-    def runnable(self):
-        return False
+    runnable: ClassVar[bool] = False
 
     def to_memory(self):
         d = super().to_memory()

+ 2 - 5
opendevin/events/action/agent.py

@@ -1,5 +1,5 @@
 from dataclasses import dataclass, field
-from typing import Dict
+from typing import ClassVar, Dict
 
 from opendevin.core.schema import ActionType
 
@@ -24,10 +24,7 @@ class AgentRecallAction(Action):
     query: str
     thought: str = ''
     action: str = ActionType.RECALL
-
-    @property
-    def runnable(self) -> bool:
-        return True
+    runnable: ClassVar[bool] = True
 
     @property
     def message(self) -> str:

+ 2 - 4
opendevin/events/action/browse.py

@@ -1,4 +1,5 @@
 from dataclasses import dataclass
+from typing import ClassVar
 
 from opendevin.core.schema import ActionType
 
@@ -10,10 +11,7 @@ class BrowseURLAction(Action):
     url: str
     thought: str = ''
     action: str = ActionType.BROWSE
-
-    @property
-    def runnable(self) -> bool:
-        return True
+    runnable: ClassVar[bool] = True
 
     @property
     def message(self) -> str:

+ 4 - 9
opendevin/events/action/commands.py

@@ -1,4 +1,5 @@
 from dataclasses import dataclass
+from typing import ClassVar
 
 from opendevin.core.schema import ActionType
 
@@ -11,9 +12,7 @@ class CmdRunAction(Action):
     background: bool = False
     thought: str = ''
     action: str = ActionType.RUN
-
-    def runnable(self) -> bool:
-        return True
+    runnable: ClassVar[bool] = True
 
     @property
     def message(self) -> str:
@@ -32,9 +31,7 @@ class CmdKillAction(Action):
     id: int
     thought: str = ''
     action: str = ActionType.KILL
-
-    def runnable(self) -> bool:
-        return True
+    runnable: ClassVar[bool] = True
 
     @property
     def message(self) -> str:
@@ -49,9 +46,7 @@ class IPythonRunCellAction(Action):
     code: str
     thought: str = ''
     action: str = ActionType.RUN_IPYTHON
-
-    def runnable(self) -> bool:
-        return True
+    runnable: ClassVar[bool] = True
 
     def __str__(self) -> str:
         ret = '**IPythonRunCellAction**\n'

+ 3 - 8
opendevin/events/action/files.py

@@ -1,4 +1,5 @@
 from dataclasses import dataclass
+from typing import ClassVar
 
 from opendevin.core.schema import ActionType
 
@@ -18,10 +19,7 @@ class FileReadAction(Action):
     end: int = -1
     thought: str = ''
     action: str = ActionType.READ
-
-    @property
-    def runnable(self) -> bool:
-        return True
+    runnable: ClassVar[bool] = True
 
     @property
     def message(self) -> str:
@@ -36,10 +34,7 @@ class FileWriteAction(Action):
     end: int = -1
     thought: str = ''
     action: str = ActionType.WRITE
-
-    @property
-    def runnable(self) -> bool:
-        return True
+    runnable: ClassVar[bool] = True
 
     @property
     def message(self) -> str: