Skip to content

Discrepancy between context and inferred type for list display in context containing complicated unions #2861

Closed
@LivInTheLookingGlass

Description

@LivInTheLookingGlass

I have a rather large type alias to figure out what the msgpack library can serialize.

from typing import (cast, Any, Callable, Dict, Iterable, Iterator, List, NamedTuple, Sequence, Tuple, Union)

_MsgPackable_ = Union[None, bool, int, float, str, bytes]
_MsgPackable = Union[_MsgPackable_, List[_MsgPackable_], Tuple[_MsgPackable_, ...], Dict[str, _MsgPackable_]]
MsgPackable = Union[_MsgPackable, List[_MsgPackable], Tuple[_MsgPackable, ...], Dict[str, _MsgPackable]]


def test_method():
    #type: () -> Iterator[MsgPackable]
    return ((x, x) for x in range(30))

However, the above generates an error from your library. Yet your documentation suggests that something like this should work.

I get that this is a fairly complex usage, but I'm unsure how else to do this sort of thing. Can you help?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions