You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid definition of Tuple in return reports on a confusing line number #3177
This may be because mypy's parser considers decorator a part of the function definition and assigns the function type the first line of the function definition.
Yes, I assumed that that was the case but for someone like me that's new to typing in Python and using mypy to verify it, it was confusing. Now that I now that you're supposed to do Tuple(bool, str) and that (bool, str) is invalid I would know how to fix it. But it took me a few minutes of thinking "there's not even a tuple on that line" before I realized what I was supposed to do.
On a related note, it is also confusing that you can't using the normal tuple syntax for typing.
mypy's parser considers decorator a part of the function definition and assigns the function type the first line of the function definition.
Yes, that's why, and I agree it would be better to pin-point errors to the specific line where they occur.
it is also confusing that you can't using the normal tuple syntax for typing.
Presuming you're referring to the idea of writing (int, str) instead of Tuple[int, str], that ship has sailed -- there are some edge cases here that wouldn't work well (unfortunately I don't have time to rehash the discussion, it's probably in one of the mega-threads we had in 2014/2015 about PEP 484.
Activity
ilevkivskyi commentedon Apr 14, 2017
This may be because mypy's parser considers decorator a part of the function definition and assigns the function type the first line of the function definition.
daveisfera commentedon Apr 14, 2017
Yes, I assumed that that was the case but for someone like me that's new to typing in Python and using mypy to verify it, it was confusing. Now that I now that you're supposed to do
Tuple(bool, str)and that(bool, str)is invalid I would know how to fix it. But it took me a few minutes of thinking "there's not even a tuple on that line" before I realized what I was supposed to do.On a related note, it is also confusing that you can't using the normal tuple syntax for typing.
gvanrossum commentedon Apr 15, 2017
Yes, that's why, and I agree it would be better to pin-point errors to the specific line where they occur.
Presuming you're referring to the idea of writing
(int, str)instead ofTuple[int, str], that ship has sailed -- there are some edge cases here that wouldn't work well (unfortunately I don't have time to rehash the discussion, it's probably in one of the mega-threads we had in 2014/2015 about PEP 484.patrickw276 commentedon May 22, 2017
I'm going to take a stab at this issue.
Use argument and return type line numbers for error messages (#3395)