Skip to content

Covariance error inferred for lambda has no associated line number #4270

Closed
@rkr-at-dbx

Description

@rkr-at-dbx
from typing import TypeVar, Generic, Callable

_Tco = TypeVar('_Tco', covariant=True)

class Thing(Generic[_Tco]):

    def chain(self, func):
        # type: (Callable[[_Tco], None]) -> None
        pass

    def end(self):
        # type: () -> None

        return self.chain(lambda _: None)

example.py: error: Cannot use a covariant type variable as a parameter

This error has no associated line number. (If the lambda is expanded into an explicit inner function typed as (_Tco) -> None, the line number is present.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions