-
Notifications
You must be signed in to change notification settings - Fork 276
propagate type context through await #3158
Copy link
Copy link
Closed
astral-sh/ruff
#24256Labels
asyncIssues related to checking code using async/awaitIssues related to checking code using async/awaitbidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typebugSomething isn't workingSomething isn't working
Milestone
Description
Summary
Summary
playground link
https://play.ty.dev/dbe21060-c0e8-4cec-96bc-d7d6565d121b
ty 0.0.26 reports a false positive invalid-assignment when an async function inside a class return a list[Self]. Works fin if just returning Self
how to reproduce
from typing import Self
class Parent:
async def get_list(self) -> list[Self]:
return [self]
async def test(self):
my_list: list[Parent] = await self.get_list()
class Child(Parent):
async def func2(self):
childs: list[Child] = await self.get_list()Version
ty 0.0.26
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
asyncIssues related to checking code using async/awaitIssues related to checking code using async/awaitbidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typebugSomething isn't workingSomething isn't working