<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 7, 2017 at 5:35 PM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 8 November 2017 at 10:03, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
> OK, so let's come up with a set of heuristics that does the right thing for<br>
> those cases specifically. I'd say whenever you're executing code from a<br>
> zipfile or some such it's not considered your own code (by default).<br>
<br>
</span>My current preferred heuristic is just to add a new default filter to the list:<br>
<br>
once::DeprecationWarning:__<wbr>main__<br>
<br>
Which says to warn specifically for the __main__ module, and continue<br>
ignoring everything else.<br></blockquote><div><br></div><div>OK, that sounds great.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That way ad hoc scripts and the REPL will get warnings by default,<br>
while zipapps and packages can avoid warnings by keeping their<br>
__main__.py simple, and importing a CLI helper function from another<br>
module. Entry point wrapper scripts will implicitly have the same<br>
effect for installed packages.<br></blockquote><div><br></div><div>That's fine.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If folks want to get warnings for other modules as well, then they can<br>
either pass "-Wd" to get warnings for everything, or else enable them<br>
selectively using the default main module filter as an example.<br></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Assuming that's how it already works, we're done here. :-)<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>