Skip to content

TypeVar not compatible with object #13689

Closed
@Dreamsorcerer

Description

@Dreamsorcerer

In order to keep code type safe and declare that my code will work with any type, I have used object. But, when trying to use a TypeVar in another part of the code, it complains that it is incompatible with object.

My code looks roughly like:

jobs: Set[Job[object]] = set()

async def spawn(self, coro: Coroutine[object, object, _T]) -> Job[_T]:
    jobs.add(job)

I'm getting:

error: Argument 1 to "add" of "set" has incompatible type "Job[_T]"; expected "Job[object]"  [arg-type]

I don't think it's an invariance problem..

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions