-
Notifications
You must be signed in to change notification settings - Fork 276
Description
Describe the Bug
Hi pyrefly team,
first of all: big thanks for your work on this great new type checker. Really looking forward to the v1 release!
Today I ran pyrefly on an existing codebase using beanie, a pydantic-based ODM for mongoDB, and encountered a weird error I can't quite make sense of. I also couldn't reproduce it in pyright or mypy.
I could reduce it to a minimum example:
from abc import ABC, abstractmethod
from beanie import Document
class CustomModel[T: Document](ABC):
@abstractmethod
async def to_db(self) -> T:
passThrows the error Abstract methods for async generators should use def, not async def on the to_db function.
The Document class of beanie inherits from pydantics BaseModel in the end. When replacing the type var bound with the parent classes of Document the error disappears, so I guess there must be something in the Document class that let's pyrefly think it's an async generator (I checked the definition of the collections.abc.AsyncGenerator interface but couldn't find common parts).
Hope someone can identify the root cause of this error :)
Environment
Python 3.12.8
beanie 2.0.0
pyrefly 0.42.1
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response