<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 11, 2017 at 3:29 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
And given that one of the key benefits of static analysis is that it<br>
*doesn't* run the code, I'd be surprised if mypy could ever trigger a<br>
runtime warning in the code under tests :)<br></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Actually there are a few cases where mypy *will* generate deprecation warnings: when the warning is produced by the standard Python parser. Mypy's parser (typed_ast) is a fork of the stdlib ast module and it preserves the code that generates such warnings. I found two cases in particular that generate them:</div><div class="gmail_extra"><br></div><div class="gmail_extra">- In Python 2 code, the `<>` operator gives "DeprecationWarning: <> not supported in 3.x; use !="/</div><div class="gmail_extra">- In Python 3 code, using `\u` escapes in a b'...' literal gives "DeprecationWarning: invalid escape sequence '\u'"</div><div class="gmail_extra"><br></div><div class="gmail_extra">In both cases these warnings are currently only generated if you run mypy with these warnings enabled, e.g. `python3 -Wd -m mypy <files>`. But this means that mypy would start generating these by default if those warnings were enabled everywhere by default (per Antoine's preference). And while it's debatable whether they are useful, there should at least be a way to turn them off (e.g. when checking Python 2 code that's never going to be ported). Running mypy in the above way is awkward; mypy would likely have to grow a new flag to control this.<br></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>