When executing filter part of a chain, the library mistakenly assumes that a function has more arguments than it really does.
It's my first time using the library, but this behaviour is errogenic. The error seems to come from helper.py _getargcount function that at some point erronously assumes that "all args are handleable".
I hope that the provided by me preinvestigation will help to track the bug source and resolve the issue
Note: if the filter iteratee is replaced with the corresponding lambda [lambda car: self.is_off_road(car)], everything works fine.
Exception
Traceback (most recent call last):
File "/usr/share/pycharm/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/share/pycharm/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File ".../main.py", line 42, in
model.update()
File ".../model.py", line 104, in update
self._move_all_cars()
File ".../model.py", line 138, in _move_all_cars
.value()
^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 48, in value
return self(self._value)
^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 108, in call
value = self._value.unwrap(value)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/proxpxd/obecny_semestr/agent-based-systems/NagelSchreckenberg/.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 144, in unwrap
wrapper._value = wrapper.value.unwrap(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 152, in unwrap
return wrapper.method(value, *wrapper.args, **wrapper.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/collections.py", line 300, in filter
return [value for istrue, value, , _ in iteriteratee(collection, predicate) if is_true]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/collections.py", line 300, in
return [value for istrue, value, , _ in iteriteratee(collection, predicate) if is_true]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/helpers.py", line 111, in iteriteratee
yield callit(cbk, item, key, obj, argcount=argcount), item, key, obj
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/helpers.py", line 43, in callit
return iteratee(args[:argstop])
^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/functions.py", line 518, in call
return not self.func(args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Model.init..() takes 1 positional argument but 3 were given
When executing filter part of a chain, the library mistakenly assumes that a function has more arguments than it really does. It's my first time using the library, but this behaviour is errogenic. The error seems to come from helper.py _getargcount function that at some point erronously assumes that "all args are handleable".
I hope that the provided by me preinvestigation will help to track the bug source and resolve the issue
Code parts
self.is_on_road = lambda car: 0 <= car.position <= Config.road_length self.is_off_road = negate(self.is_on_road)
py_(self.cars).filter(self.is_off_road).value()
Note: if the filter iteratee is replaced with the corresponding lambda [lambda car: self.is_off_road(car)], everything works fine.
Exception
Traceback (most recent call last): File "/usr/share/pycharm/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/pycharm/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File ".../main.py", line 42, in
model.update()
File ".../model.py", line 104, in update
self._move_all_cars()
File ".../model.py", line 138, in _move_all_cars
.value()
^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 48, in value
return self(self._value)
^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 108, in call
value = self._value.unwrap(value)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/proxpxd/obecny_semestr/agent-based-systems/NagelSchreckenberg/.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 144, in unwrap
wrapper._value = wrapper.value.unwrap(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/chaining/chaining.py", line 152, in unwrap
return wrapper.method(value, *wrapper.args, **wrapper.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/collections.py", line 300, in filter
return [value for istrue, value, , _ in iteriteratee(collection, predicate) if is_true]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/collections.py", line 300, in
return [value for istrue, value, , _ in iteriteratee(collection, predicate) if is_true]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/helpers.py", line 111, in iteriteratee
yield callit(cbk, item, key, obj, argcount=argcount), item, key, obj
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/helpers.py", line 43, in callit
return iteratee(args[:argstop])
^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../.venv/lib/python3.11/site-packages/pydash/functions.py", line 518, in call
return not self.func(args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Model.init..() takes 1 positional argument but 3 were given