This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jack__d
Recipients jack__d, ktbarrett
Date 2021-06-28.23:30:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1624923014.45.0.0827580043996.issue44529@roundup.psfhosted.org>
In-reply-to
Content
I think this already works unless you are using TypeVars::

    t = Union[str, int]

    isinstance(1, t)    # True
    isinstance('1', t)  # True

If you are using TypeVars, though, it cannot work:

    T = TypeVar('my_type')
    thing = Union[T, str]

    isinstance('hi', thing)  # Exception

This makes sense, because ``T`` is just a name, not related to an actual object.

Sorry if I'm missing something, because I did try the non-working example and my exception actually says, "issubclass() arg 2 must be a class, a tuple of classes, or a union." The exception makes sense, but its difference from yours might mean I'm doing something differently.
History
Date User Action Args
2021-06-28 23:30:14jack__dsetrecipients: + jack__d, ktbarrett
2021-06-28 23:30:14jack__dsetmessageid: <1624923014.45.0.0827580043996.issue44529@roundup.psfhosted.org>
2021-06-28 23:30:14jack__dlinkissue44529 messages
2021-06-28 23:30:13jack__dcreate