basedpyright
basedpyright copied to clipboard
Union operator results in incorrect type with `_SpecialForm`
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.
A solution would be to catch the unions with
SpecialForms and result inobjectinstead.
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)