[issue40582] Inconsistent exceptions caused by typing + tuple subclasses

2020-05-10 Thread Guido van Rossum
Guido van Rossum added the comment: I recommend taking this to a user forum or list. I see no but in typing.py here. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___

[issue40582] Inconsistent exceptions caused by typing + tuple subclasses

2020-05-10 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +gvanrossum, levkivskyi ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: h

[issue40582] Inconsistent exceptions caused by typing + tuple subclasses

2020-05-10 Thread Ruairidh MacLeod
Ruairidh MacLeod added the comment: The original code for this was: ``` from typing import List from unittest.mock import call def f(n: List[call]): ... ``` Which produces "SyntaxError: Forward reference must be an expression -- got ''". I think my only query is whether this behavior is ok,

[issue40582] Inconsistent exceptions caused by typing + tuple subclasses

2020-05-09 Thread Dennis Sweeney
Dennis Sweeney 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 pa

[issue40582] Inconsistent exceptions caused by typing + tuple subclasses

2020-05-09 Thread Ruairidh MacLeod
New submission from Ruairidh MacLeod : When incorrectly defining a function with a typed List[T] argument where T is a tuple instance, a TypeError is correctly raised: t = (1,) def f(a: List[t]): ... # => TypeError: Parameters to generic types must be types. Got 1. When t is an instance of a