wemake-services / wemake-services/wemake-python-styleguide
nested higher-order functions
Open
Nobody has claimed this yet.
rule request
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 430
- Avg merge
- 5h 14m
- Merged PRs (30d)
- 34
Description
Hi! @sobolevn
What do you think about this code:
res = reduce(
lambda acc, x: acc + x,
filter(
lambda x: x > 5,
map(
lambda x: x + 1,
map(
lambda x: x * 2,
filter(lambda x: x % 2 == 0, numbers)
)
)
),
0
)
How about adding rules to simplify nesting?
It's should be like this:
step1 = filter(lambda x: x % 2 == 0, numbers)
step2 = map(lambda x: x * 2, step1)
step3 = map(lambda x: x + 1, step2)
step4 = filter(lambda x: x > 5, step3)
please, assign me , if you think it should be a violation :)
Contributor guide
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
No implementation files or tests are identified. Start by reviewing the project's existing rule conventions and decide whether the nested map, filter, and reduce example defines a precise violation; done requires an agreed rule scope and tests covering the proposed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100