Add more SyntaxWarnings?
https://bugs.python.org/issue15248 is about situations like the following:
[(1,2,3) (4,5,6)] Traceback (most recent call last): File "
", line 2, in <module> (4,5,6)] 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 https://docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlo... (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. https://developers.redhat.com/blog/2018/03/15/gcc-8-usability-improvements/ 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
participants (14)
-
Chris Angelico
-
Chris Barker - NOAA Federal
-
Eric V. Smith
-
Greg Ewing
-
Guido van Rossum
-
MRAB
-
Neil Schemenauer
-
Nick Coghlan
-
Oleg Broytman
-
Paul Sokolovsky
-
Stefan Behnel
-
Stephen J. Turnbull
-
Steven D'Aprano
-
Terry Reedy