[Python-Dev] Add more SyntaxWarnings?

Terry Reedy tjreedy at udel.edu
Thu Jan 24 15:18:05 EST 2019

https://bugs.python.org/issue15248 is about situations like the following:

 >>> [(1,2,3)
Traceback (most recent call last):
   File "<pyshell#4>", line 2, in <module>
TypeError: 'tuple' object is not callable

The original poster requested that the error message be augmented with 
something like "(missing preceding comma?)"

Ezio Melotti suggested a FAQ entry like

(I think such entries below in a separate doc and will try to post on 
python-ideas when I have a prototype.)

Serhiy Storchaka suggested a compiler SyntaxWarning and uploaded a 
proof-of-concept diff that handled the above and many similar cases. The 
diff is based on the idea that while we can only positively identify 
'callables' at runtime, we *can* negatively identify many non-callables 
when compiling.  Ditto for subscriptables and indexables.

Serhiy concluded with
"This patch was inspired by usability improvements in GCC 8.
I haven't created a pull request because I have doubts about that this 
should be in the compiler rather of a third-party linter. But if several 
other core developers will support this idea I'll continue working in 
this direction."

I was impressed with how clear and readable the patch is and consider it 
a plausible enhancement.  I would like other core developers to comment.

Terry Jan Reedy

More information about the Python-Dev mailing list