Skip to content

Commit

Permalink
Update violation docs for yield from violation.
Browse files Browse the repository at this point in the history
Address issue wemake-services#1057. Update violation docs to make it easier for developers to understand how to refactor more complex yield statements.
  • Loading branch information
andreaestrada committed Dec 8, 2019
1 parent 673a064 commit 0e77833
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ to the project during `#hactoberfest`. List of awesome people:
- Adds `flake8-eradicate` plugin
- Adds `flake8-print` plugin for development
- Removes `delegate` concept from the codebase
- Add additional yield from example to violations documentation

## Version 0.0.13 aka The Jones Complexity

Expand Down
11 changes: 11 additions & 0 deletions wemake_python_styleguide/violations/refactoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,17 @@ class ImplicitYieldFromViolation(ASTViolation):
for item in some():
yield item
# Correct:
yield from (
value[index:index + chunk_size]
for index in range(0, len(value), chunk_size)
)
# Wrong:
def chunks(value, chunk_size):
for index in range(0, len(value), chunk_size):
yield value[index:index + chunk_size]
.. versionadded:: 0.13.0
"""
Expand Down

0 comments on commit 0e77833

Please sign in to comment.