basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

Confusing error using intersection operator (`&`) in value position (eg `TypeVar` bounds)

Open DetachHead opened this issue 2 years ago • 0 comments

from typing import TypeVar

class Foo: ...
class Bar: ...

T = TypeVar("T", bound=Foo & Bar)
# error: TypeVar "bound" must be a type
# error: Unsupported left operand type for & ("type[Foo]")

Something more like "Use quoted types or basedtyping.Intersection".

DetachHead avatar Jun 27 '23 00:06 DetachHead