Skip to content

PT012: and generators #19363

Open
Open
@spaceone

Description

@spaceone

I wonder whether PT012 is valid for generators, as one need to resolve them.
in a regular generator i can put list() or next() around it and for async, anext works or putting it into a list comprehension.

@pytest.mark.asyncio
async def test_foo():
    with pytest.raises(Bar):  # W: `pytest.raises()` block should contain a single simple statement
        async for entry in foo():
            assert not entry

So you might consider it invalid, but please consider if a exception makes sense here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions