-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
MessageBuilder.format inconsistently surrounds types with quotes #3409
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
Comments
I think this is on purpose. See this comment in # No type arguments. Place the type name in quotes to avoid
# potential for confusion: otherwise, the type name could be
# interpreted as a normal word. The idea is that type with arguments (i.e. with |
The reasoning in that comment could be a good idea, but I think it'd be hard to do consistently -- and certainly we don't do it consistently today. For example this error message in the quoted test:
I took a quick look at how C compilers format types in error messages. Both Clang and GCC seem to consistently quote all types, with single quotes, both simple and complicated: https://gcc.gnu.org/wiki/ClangDiagnosticsComparison So I think we should be consistent too. We're also inconsistent on single vs. double quotes (see again the quoted test), which would also be good to fix but I think is a lower level of issue. |
I agree. @Nurdok woul you like to make a PR removing the check (and comment) I mentioned above? |
@ilevkivskyi I tidied up the messages lib to put double quotes everywhere. |
This is a refreshed version of #3430 (credits @mistermocha). Fixes #3409. Tidying up inconsistent quotes around returned types for formatting. See #3409 for background.
When working on #3402, using
msg.format
for types usually surrounded them with quotes, e.g., in testtestUnionAttributeAccess
, callingmsg.format
while printing generates the following:However, in one test case, ``, the type is not surrounded by quotes (see last line, I attached the entire test case for context):
Notice how
Node[int]
is not surrounded by quotes. The relevantformat
function is defined inmypy/messages.py
.(Sorry for only reproducing this in an unrelated test, I don't have enough knowledge on the code base to create the relevant type object directly).
The text was updated successfully, but these errors were encountered: