<div dir="ltr"><div><div>There's a proposal to change one detail of PEP 484. It currently says:<br><br><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;color:rgb(106,115,125);border-left:0.25em solid rgb(223,226,229);font-family:-apple-system,system-ui,"segoe ui",helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji","segoe ui symbol";font-size:14px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">An optional type is also automatically assumed when the default value is<br style="box-sizing:border-box"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:11.9px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">None</code>, for example::</p><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:11.9px;margin-top:0px;margin-bottom:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:1.45;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:11.9px;padding:0px;margin:0px;background:transparent none repeat scroll 0% 0%;border-radius:3px;word-break:normal;white-space:pre;border-width:0px;border-style:none;border-color:currentcolor;display:inline;overflow:visible;line-height:inherit">  def handle_employee(e: Employee = None): ...
</code></pre><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">This is equivalent to::</p><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:11.9px;margin-top:0px;margin-bottom:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:1.45;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:11.9px;padding:0px;margin:0px;background:transparent none repeat scroll 0% 0%;border-radius:3px;word-break:normal;white-space:pre;border-width:0px;border-style:none;border-color:currentcolor;display:inline;overflow:visible;line-height:inherit">  def handle_employee(e: Optional[Employee] = None) -> None: ...
</code></pre></blockquote><br class="gmail-Apple-interchange-newline"></div>Now that we've got some experience actually using Optional with mypy (originally mypy ignored Optional), we're beginning to think that this was a bad idea. There's more discussion at <a href="https://github.com/python/typing/issues/275">https://github.com/python/typing/issues/275</a> and an implementation of the change (using a command-line flag) in <a href="https://github.com/python/mypy/pull/3248">https://github.com/python/mypy/pull/3248</a>.<br><br></div>Thoughts? Some function declarations will become a bit more verbose, but we gain clarity (many users of annotations don't seem to be familiar with this feature) and consistency (since this rule doesn't apply to variable declarations and class attribute declarations).<br clear="all"><div><div><div><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/%7Eguido" target="_blank">python.org/~guido</a>)</div>
</div></div></div></div>