Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:

I think the behavior is consistent between tuple and an empty subclass:

    >>> from typing import List
    >>> class T(tuple):
        pass

====== Empty tuple/T ======

    >>> List[()]
    Traceback (most recent call last):
    ...
    TypeError: Too few parameters for typing.List; actual 0, expected 1


    >>> List[T()]
    Traceback (most recent call last):
    ...
    TypeError: Too few parameters for typing.List; actual 0, expected 1


====== tuple/T whose only entry is 1 ======

    >>> List[(1,)]
    Traceback (most recent call last):
    ...
    TypeError: Parameters to generic types must be types. Got 1.


    >>> List[T((1,))]
    Traceback (most recent call last):
    ...
    TypeError: Parameters to generic types must be types. Got 1.


====== tuple/T whose only entry is "" ======

    >>> List[T(("",))]
    Traceback (most recent call last):
    ...
    SyntaxError: unexpected EOF while parsing

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    ...
    SyntaxError: Forward reference must be an expression -- got ''


    >>> List[("",)]
    Traceback (most recent call last):
    ...
    SyntaxError: unexpected EOF while parsing

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    ...
    SyntaxError: Forward reference must be an expression -- got ''


====== tuple/T whose only entry can rightly become a forward reference ======

    >>> List[("Foo",)]
    typing.List[ForwardRef('Foo')]


    >>> List[T(("Foo",))]
    typing.List[ForwardRef('Foo')]


Your ``return tuple.__new__(cls, ("",))`` constructor is just always
returning the same as ``T(("",))``

----------
nosy: +Dennis Sweeney

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

Reply via email to