<div dir="ltr"><div>In this case I agree that a SyntaxWarning is a good idea, per Serhiy's patch. I would be even more conservative, and only warn if the first object is a tuple -- the case of the missing comma in the original example appears likely enough, but I don't expect people to write e.g. `[[1, 2], (3, 4)]` very often, so leaving the comma out there would be very unlikely.</div><div><br></div><div>Regarding the issue of when it's appropriate to issue a SyntaxWarning vs. when to leave it up to linters, again I would recommend great caution and only warn about code that is *definitely* going to fail when executed. (Or at least is *definitely* not going to please the programmer -- one of the first cases where we added a SyntaxWarning was actually `assert(condition, message)`, which "fails" by never failing. :-) But this is one of those cases.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 24, 2019 at 2:10 PM Neil Schemenauer <<a href="mailto:nas-python@arctrix.com">nas-python@arctrix.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2019-01-24, Terry Reedy wrote:<br>
> Serhiy Storchaka suggested a compiler SyntaxWarning and uploaded a<br>
> proof-of-concept diff that handled the above and many similar cases.<br>
<br>
I believe that in general we should give better errors or warnings<br>
if we can do it without huge difficulty. Serhiy's patch is quite<br>
simple. The same check *could* be done by a linting tool. Putting<br>
it in CPython will make it more widely available. These checks<br>
could be helpful to beginners who probably won't have linting tools<br>
setup.<br>
<br>
I think we should not make it an error, otherwise we have changed<br>
Python "the language". We don't want to force other Python<br>
implementations to do the same check. It might be hard for them to<br>
implement. So, SyntaxWarning seems like a reasonable compromise.<br>
<br>
Regards,<br>
<br>
Neil<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>