Skip to content

propagate type context through await #3158

@styfore

Description

@styfore

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    asyncIssues related to checking code using async/awaitbidirectional inferenceInference of types that takes into account the context of a declared type or expected typebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions