Skip to content

False Positive PT012 for async iterator #9730

@nmzgnv

Description

@nmzgnv

What's wrong

I want to test that async iterator raises error.

with pytest.raises(KeyError, match='unknown'):
    async for _ in gpt.generate(gpt_request):
        pass

Receive unexpected error PT012 'pytest.raises()' block should contain a single simple statement, but the statement is already simple.

How it should work

not raise PT012 for simple async for loops as with empty context managers https://github.com/m-burst/flake8-pytest-style/blob/master/docs/rules/PT012.md

System information

  • Operating system: mac OS Ventura 13.5
  • Python version: 3.11.4
  • ruff version: v0.1.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing 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