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
Note that the reported column is the "i" in "List", which appears to be off in general.
The workaround is to split the return into an assignment (with the annotation), and then returning the variable. But I think it would be nice if the annotation would work with the return statement already.
If that's not going to be supported, the error should be more descriptive probably.
One can use the cast operation here but due to the differences in using cast versus the type comment it might be preferable to use the type comment. Thought I'd add a +1 from me as well.
Mypy doesn't implement it's own parser, so this would need to be added to CPython for it to be supported. I don't think that it's a likely addition, however, since comment-based type annotations are primarily for backwards compatibility with older Python versions, and the variable annotation syntax introduced in Python 3.6 is recommended for new code.
Given
t-return.py
:mypy --show-column-numbers t-return.py
shows:Note that the reported column is the "i" in "List", which appears to be off in general.
The workaround is to split the return into an assignment (with the annotation), and then returning the variable. But I think it would be nice if the annotation would work with the return statement already.
If that's not going to be supported, the error should be more descriptive probably.
mypy 0.770+dev.9101707bd0c96624d09cb31fe573d7e25c89a35c.dirty
The text was updated successfully, but these errors were encountered: