Skip to content

False positive when raising an exc: Abstract methods for async generators should use def, not async def #2860

@stijndcl

Description

@stijndcl

Describe the Bug

Note that there was a similar issue a few months ago: #1624. However, that seems to be a slightly different case. The comments there might aid you in debugging this one though. I don't believe this is a duplicate (esp considering that one was fixed months ago).

Pyrefly version: 0.57.1 (latest as of time of writing)
Python version: 3.13.1

The below code:

from abc import ABC, abstractmethod


class Issue(ABC):
    @abstractmethod
    async def fn(self):
        raise NotImplementedError

incorrectly fails with

ERROR Abstract methods for async generators should use `def`, not `async def` [bad-function-definition]

Interestingly, this only happens when I raise an exception AND don't specify a return type. Replacing the raise NotImplementedError line with anything else (pass, docstring, actual code, ...) or adding a return type stops Pyrefly from complaining. I also can't reproduce this in the Sandbox.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions