Use format_type for msg.type_not_iterable - #11490
Conversation
| .format(str(i), format_type_bare(rhs_t), format_type_bare(lhs_t))) | ||
| notes.append('Expression tuple item {} has type {}; {} expected; ' | ||
| .format(str(i), format_type(rhs_t), format_type(lhs_t))) | ||
| error_cnt += 1 |
There was a problem hiding this comment.
Changing from format_type_bare to format_type to keep consistency with other usage of format_type.
sobolevn
left a comment
There was a problem hiding this comment.
Thanks! I have a couple of questions 🙂
| () = [] # E: can't assign to () | ||
|
|
||
| [case testAssignEmptyBogus] | ||
| () = 1 # E: "Literal[1]?" object is not iterable |
There was a problem hiding this comment.
This is a significant change and I don't think that is an improvement. Literal[1] is more specific, I personally like it more.
There was a problem hiding this comment.
yeah, this is an interesting case. I think it's a different issue that we might need to modify the format_type.
| reveal_type(d2) # N: Revealed type is "Union[Any, builtins.float]" | ||
|
|
||
| e: Union[Any, Tuple[float, float], int] | ||
| (e1, e2) = e # E: "builtins.int" object is not iterable |
There was a problem hiding this comment.
There are a lot of places where builtins. is used, and some places where it is not used. I cannot tell what kind of principle is used here 😞
There was a problem hiding this comment.
mypy keeps the prefix in reveal_type for more verbose information. And according to the original discussion, it's better to discard builtins. to get concise error messages. Also, cpython dosen't output builtins. when error occurs.
Closes python#5072, follows up to python#11490
Description
Related #5072
Uses
format_typeto get a more concise output.