-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Unexpected '...'" reported from ellipsis in type alias, but understood anyway? #10242
Comments
That's my running result with python 3.8.8 & mypy 0.820+dev.641919f9496c8c62b9f45e7ec8402162667b7a11, it reports errors where
But I'm not quite undertstanding what should be the expected behavior. Do you mean that
Also, the same result is outputed
|
Python 3.9 added the ability to subscript built-in generic types (including builtins like That is, |
Thank you for explaination! It seems that it's truly a bug. In |
Currently my progress on this problem is that |
Related issue: x: tuple[str, ...] Checking this with mypy@master (0.820+dev.1e96f1df48a6e06ba598fa8230b96671b206cba0) and Python 3.9 works fine, checking it with Python 3.8 fails: "foo.pyi:1: error: Unexpected '...'". Adding python/typeshed#5192 fails because of this. |
Fixed on master |
Bug Report
The type
typing.Tuple[Foo, ...]
is accepted as meaning "tuple of Foo, arbitrary length", buttuple[Foo, ...]
is not, in the context of type aliases. It's apparently understood, but produces an error message anyway.To Reproduce
Create a file:
Then run
mypy
on the file.Actual Behavior
mypy
reports:test.py:4: error: Unexpected '...'
. It does not report an error on line 3 (alias defined fromTuple
) or 5 (the same type provided directly as an annotation rather than an alias, and also the use of the alias which produced an error). Iffoo
is defined as returning something that is not a tuple of integers, such as("argle",)
,mypy
does report that as an incompatible return value type.Your Environment
mypy.ini
(and other config files): I have not set up such configurationThe text was updated successfully, but these errors were encountered: