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

>>> [(1,2,3)
     (4,5,6)]
Traceback (most recent call last):
  File "<pyshell#4>", 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-unboundlocalerror-when-the-variable-has-a-value

(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

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to