num_required_args gives unexpected answer on composed methods
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 280
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 4
Description
using:
- Python 3.6
- toolz 0.9.0
>>> from toolz import compose, num_required_args
>>> int_identity = compose(ord, chr)
>>> req_args = num_required_args(int_identity)
>>> assert req_args == 1, req_args
AssertionError: 0
Note that cytoolz returns a different value on the same test: None. While technically acceptable, I think 1 is the best answer. Our likely workaround for now is:
from toolz.functoolz import Compose, num_required_args
def enhanced_num_required_args(func):
if isinstance(func, Compose):
return enhanced_num_required_args(func.first)
else:
return num_required_args(func)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Python 3.6 example with compose and num_required_args, then read the definitions of Compose and num_required_args mentioned in the issue. Done means the composed int_identity case reports 1, with tests covering the expected behavior and the existing cytoolz distinction considered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100