Skip to content

yield from is not allowed in async function #146

Closed
@wyuenho

Description

Desired change

Do not warning if a SIM104 is encountered inside an async function or method.

  • Rule(s): SIM104
  • Adjustment: In which way should it/they be adjusted?
    Do not warning if a SIM104 is encountered inside an async function or method.

Explanation

Why is the adjustment necessary / better?

The suggested fix to replace a for yield loop with a yield from statement is invalid inside an async function.

Example

This is an example where the mentioned rule(s) would currently be suboptimal:

async fib(limit=10):
    if limit == 1:
        yield 0
    if limit == 2:
        yield 0
        yield 1
    i, j = 0, 1
    for _ in range(2, limit):
        n = i + j
        yield n
        i, j = j, n

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions