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 ngwood111
Recipients itoijala, ngwood111
Date 2018-10-07.18:28:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538936934.25.0.545547206417.issue34921@psf.upfronthosting.co.za>
In-reply-to
Content
Is this a feature request? Because it doesn't look like a bug to me. Where NoReturn is defined it says it's supposed to fail in static type checkers.

Anyway, I'm not entirely sure on the whole process of contributing but here goes:

The code ultimately fails at _type_check.
According to _type_check, "special forms like Union are not valid, while Union[int, str] is OK, etc."

NoReturn isn't subscriptable.

So basically the code is getting to this point and executing

    _type_check(NoReturn, msg)

which fails on any special form.

If you try to force NoReturn to have additional parameters it will fail at __getitem__ because NoReturn is not subscriptable.

Any is also not subscriptable, but it's specifically handled in the _type_check() function ala:

    if (isinstance(arg, _SpecialForm) and arg is not Any or ...

if you wanted to add NoReturn you could do something like

    if (isinstance(arg, _SpecialForm) and arg not in [Any, NoReturn] or ...

Tested it and it works fine on 3.7 and 3.8 for me!

I've submitted a pull request with my proposed fix
History
Date User Action Args
2018-10-07 18:28:54ngwood111setrecipients: + ngwood111, itoijala
2018-10-07 18:28:54ngwood111setmessageid: <1538936934.25.0.545547206417.issue34921@psf.upfronthosting.co.za>
2018-10-07 18:28:54ngwood111linkissue34921 messages
2018-10-07 18:28:54ngwood111create