noah <ngwood...@gmail.com> added the comment:

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

----------
nosy: +ngwood111 -levkivskyi, xtreak
versions: +Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34921>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to