basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

Union operator results in incorrect type with `_SpecialForm`

Open KotlinIsland opened this issue 1 year ago • 1 comments

from typing import Never
from types import UnionType
a: UnionType = int | Never  # no error

erm... UnionType????? you clearly know that this is a typing.Union (_GenericAlias/_UnionGenericAlias to be specific)

A solution would be to catch the unions with SpecialForms and result in object instead.

KotlinIsland avatar Apr 09 '24 05:04 KotlinIsland

A solution would be to catch the unions with SpecialForms and result in object instead.

i like this solution. all this internal runtime type system stuff is a complete mess and should not be exposed to the user at all (related: https://github.com/DetachHead/basedpyright/issues/266#issuecomment-2044121395)

DetachHead avatar Apr 09 '24 05:04 DetachHead