Skip to content

Commit 810264c

Browse files
Merge pull request #161 from dotflow-io/feature/133
🪲 BUG-#133: Fix co_varnames to only include parameters, not local variables
2 parents 054fcb4 + 66791fd commit 810264c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

dotflow/core/action.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,20 @@ def _call_func(self, is_async, *args, **kwargs):
199199

200200
def _set_params(self):
201201
if isinstance(self.func, FunctionType):
202-
self.params = list(self.func.__code__.co_varnames)
202+
code = self.func.__code__
203+
self.params = list(
204+
code.co_varnames[: code.co_argcount + code.co_kwonlyargcount]
205+
)
203206

204207
if (
205208
type(self.func) is type
206209
and hasattr(self.func, "__init__")
207210
and hasattr(self.func.__init__, "__code__")
208211
):
209-
self.params = list(self.func.__init__.__code__.co_varnames)
212+
code = self.func.__init__.__code__
213+
self.params = list(
214+
code.co_varnames[: code.co_argcount + code.co_kwonlyargcount]
215+
)
210216

211217
def _get_context(self, kwargs: dict):
212218
context = {}

0 commit comments

Comments
 (0)